基于Java+SpringMVC+vue+element实现前后端分离校园失物招领系统详细设计

/** * 失物信息 * 后端接口 * @author * @email * @date 2022-03-06 13:11:28 */ @RestController @RequestMapping("/shiwuxinxi") public class ShiwuxinxiController { @Autowired private ShiwuxinxiService shiwuxinxiService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ShiwuxinxiEntity shiwuxinxi, HttpServletRequest request){ String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("yonghu")) { shiwuxinxi.setYonghuming((String)request.getSession().getAttribute("username")); } EntityWrapper<ShiwuxinxiEntity> ew = new EntityWrapper<ShiwuxinxiEntity>(); PageUtils page = shiwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shiwuxinxi), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ShiwuxinxiEntity shiwuxinxi, HttpServletRequest request){ EntityWrapper<ShiwuxinxiEntity> ew = new EntityWrapper<ShiwuxinxiEntity>(); PageUtils page = shiwuxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shiwuxinxi), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( ShiwuxinxiEntity shiwuxinxi){ EntityWrapper<ShiwuxinxiEntity> ew = new EntityWrapper<ShiwuxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( shiwuxinxi, "shiwuxinxi")); return R.ok().put("data", shiwuxinxiService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(ShiwuxinxiEntity shiwuxinxi){ EntityWrapper< ShiwuxinxiEntity> ew = new EntityWrapper< ShiwuxinxiEntity>(); ew.allEq(MPUtil.allEQMapPre( shiwuxinxi, "shiwuxinxi")); ShiwuxinxiView shiwuxinxiView = shiwuxinxiService.selectView(ew); return R.ok("查询失物信息成功").put("data", shiwuxinxiView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ ShiwuxinxiEntity shiwuxinxi = shiwuxinxiService.selectById(id); return R.ok().put("data", shiwuxinxi); } /** * 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ ShiwuxinxiEntity shiwuxinxi = shiwuxinxiService.selectById(id); return R.ok().put("data", shiwuxinxi); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody ShiwuxinxiEntity shiwuxinxi, HttpServletRequest request){ shiwuxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(shiwuxinxi); shiwuxinxiService.insert(shiwuxinxi); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody ShiwuxinxiEntity shiwuxinxi, HttpServletRequest request){ shiwuxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(shiwuxinxi); shiwuxinxiService.insert(shiwuxinxi); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody ShiwuxinxiEntity shiwuxinxi, HttpServletRequest request){ //ValidatorUtils.validateEntity(shiwuxinxi); shiwuxinxiService.updateById(shiwuxinxi);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ shiwuxinxiService.deleteBatchIds(Arrays.asList(ids)); return R.ok(); } /** * 提醒接口 */ @RequestMapping("/remind/{columnName}/{type}") public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("column", columnName); map.put("type", type); if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); Date remindStartDate = null; Date remindEndDate = null; if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); map.put("remindstart", sdf.format(remindStartDate)); } if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); map.put("remindend", sdf.format(remindEndDate)); } } Wrapper<ShiwuxinxiEntity> wrapper = new EntityWrapper<ShiwuxinxiEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } String tableName = request.getSession().getAttribute("tableName").toString(); if(tableName.equals("yonghu")) { wrapper.eq("yonghuming", (String)request.getSession().getAttribute("username")); } int count = shiwuxinxiService.selectCount(wrapper); return R.ok().put("count", count); } }
上一篇:软考76-上午题-【面向对象技术3-设计模式】-创建型设计模式01-二、创建型设计模式


下一篇:uniapp+uview实现城市选择器