| | |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.your.entity.Area; |
| | | import cn.exrick.xboot.your.entity.Car; |
| | | import cn.exrick.xboot.your.service.IAreaService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | |
| | | @RequestMapping(value = "/getByPage", method = RequestMethod.GET) |
| | | @ApiOperation(value = "分页获取") |
| | | public Result<IPage<Area>> getByPage(String areaId,PageVo page) { |
| | | public Result<IPage<Area>> getByPage(String name,PageVo page) { |
| | | QueryWrapper<Area> wrapper = new QueryWrapper<>(); |
| | | if (!StrUtil.isEmpty(areaId)) |
| | | wrapper.eq("area_id",areaId); |
| | | if (!StrUtil.isEmpty(name)) |
| | | wrapper.like("a.name",name); |
| | | IPage<Area> data = iAreaService.page2(PageUtil.initMpPage(page),wrapper); |
| | | return new ResultUtil<IPage<Area>>().setData(data); |
| | | } |
| | |
| | | @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST) |
| | | @ApiOperation(value = "编辑或更新数据") |
| | | public Result<Area> saveOrUpdate(Area area) { |
| | | QueryWrapper<Area> wrapper = new QueryWrapper<>(); |
| | | if (!area.getUserId().equals("0")){ |
| | | wrapper.eq("user_id",area.getUserId()); |
| | | Area area1 = iAreaService.getOne(wrapper); |
| | | if (area1 != null && !area.getId().equals(area1.getId())){ |
| | | return new ResultUtil<Area>().setErrorMsg("该配送员已被其他片区绑定,请先解绑"); |
| | | } |
| | | } |
| | | |
| | | if (iAreaService.saveOrUpdate(area)) { |
| | | return new ResultUtil<Area>().setData(area); |
| | | } |