您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“如何實現基于Java SSM的健康管理小程序”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“如何實現基于Java SSM的健康管理小程序”這篇文章吧。
開發語言:Java
框架:ssm
JDK版本:JDK1.8
服務器:tomcat7
數據庫:mysql 5.7(一定要5.7版本)
數據庫工具:Navicat11
開發軟件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
瀏覽器:谷歌瀏覽器
(1)用戶管理。主要實現了健康管理小程序的用戶管理功能。
(2)登錄注冊。小程序端可以登錄注冊。
(3)健康目標。完成健康目標的設定
(4)商城。在線購買健康相關的商品。
(5)個人信息查看。查看各種信息。
(6)后臺管理。管理小程序端的各種信息。
@RestController @RequestMapping("/address") public class AddressController { @Autowired private AddressService addressService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理員")) { address.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理員")) { address.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( AddressEntity address){ EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>(); ew.allEq(MPUtil.allEQMapPre( address, "address")); return R.ok().put("data", addressService.selectListView(ew)); } /** * 查詢 */ @RequestMapping("/query") public R query(AddressEntity address){ EntityWrapper< AddressEntity> ew = new EntityWrapper< AddressEntity>(); ew.allEq(MPUtil.allEQMapPre( address, "address")); AddressView addressView = addressService.selectView(ew); return R.ok("查詢地址成功").put("data", addressView); } /** * 后端詳情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ AddressEntity address = addressService.selectById(id); return R.ok().put("data", address); } /** * 前端詳情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ AddressEntity address = addressService.selectById(id); return R.ok().put("data", address); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody AddressEntity address, HttpServletRequest request){ address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(address); address.setUserid((Long)request.getSession().getAttribute("userId")); Long userId = (Long)request.getSession().getAttribute("userId"); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId)); } address.setUserid(userId); addressService.insert(address); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody AddressEntity address, HttpServletRequest request){ address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(address); address.setUserid((Long)request.getSession().getAttribute("userId")); Long userId = (Long)request.getSession().getAttribute("userId"); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId)); } address.setUserid(userId); addressService.insert(address); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody AddressEntity address, HttpServletRequest request){ //ValidatorUtils.validateEntity(address); if(address.getIsdefault().equals("是")) { addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", request.getSession().getAttribute("userId"))); } addressService.updateById(address);//全部更新 return R.ok(); } /** * 獲取默認地址 */ @RequestMapping("/default") public R defaultAddress(HttpServletRequest request){ Wrapper<AddressEntity> wrapper = new EntityWrapper<AddressEntity>().eq("isdefault", "是").eq("userid", request.getSession().getAttribute("userId")); AddressEntity address = addressService.selectOne(wrapper); return R.ok().put("data", address); } /** * 刪除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ addressService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); }
/** * 登錄相關 */ @RequestMapping("config") @RestController public class ConfigController{ @Autowired private ConfigService configService; /** * 列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 信息 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 詳情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 根據name獲取信息 */ @RequestMapping("/info") public R infoByName(@RequestParam String name){ ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); return R.ok().put("data", config); } /** * 保存 */ @PostMapping("/save") public R save(@RequestBody ConfigEntity config){ // ValidatorUtils.validateEntity(config); configService.insert(config); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody ConfigEntity config){ // ValidatorUtils.validateEntity(config); configService.updateById(config);//全部更新 return R.ok(); } /** * 刪除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ configService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } }
@RestController @RequestMapping("/orders") public class OrdersController { @Autowired private OrdersService ordersService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理員")) { orders.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>(); PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){ EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>(); PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( OrdersEntity orders){ EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>(); ew.allEq(MPUtil.allEQMapPre( orders, "orders")); return R.ok().put("data", ordersService.selectListView(ew)); } /** * 查詢 */ @RequestMapping("/query") public R query(OrdersEntity orders){ EntityWrapper< OrdersEntity> ew = new EntityWrapper< OrdersEntity>(); ew.allEq(MPUtil.allEQMapPre( orders, "orders")); OrdersView ordersView = ordersService.selectView(ew); return R.ok("查詢訂單成功").put("data", ordersView); } /** * 后端詳情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ OrdersEntity orders = ordersService.selectById(id); return R.ok().put("data", orders); } /** * 前端詳情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ OrdersEntity orders = ordersService.selectById(id); return R.ok().put("data", orders); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody OrdersEntity orders, HttpServletRequest request){ orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(orders); orders.setUserid((Long)request.getSession().getAttribute("userId")); ordersService.insert(orders); return R.ok(); }
以上是“如何實現基于Java SSM的健康管理小程序”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。