package com.newfiber.api.pc.controller.zhz; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.newfiber.api.core.annotation.SysLog; import com.newfiber.api.core.commons.*; import com.newfiber.api.pc.model.entity.ProSiteInfoEntity; import com.newfiber.api.pc.model.meet.MeetArea; import com.newfiber.api.pc.model.meet.MeetAreaSite; import com.newfiber.api.pc.model.vo.MeetAreaSiteVo; import com.newfiber.api.pc.service.MeetAreaService; import com.newfiber.api.pc.service.MeetAreaSiteService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @Author:zzh * @CreateDate:2020/11/24 14:35 * @Description: */ @RestController @RequestMapping("/meet/area") @Api(value = "MeetAreaController",tags = "区域管理") public class MeetAreaController { @Autowired private MeetAreaService meetAreaService; @Autowired private MeetAreaSiteService meetAreaSiteService; @PostMapping("/list") @ApiOperation("分页获取所有区域信息") @SysLog(actionType = "4",value = "分页获取所有区域信息") public ResultObj<PageResultObject<MeetArea>> queryPage(@RequestBody PageRequestObject<String> pageRequestObject){ return new ResultObj<PageResultObject<MeetArea>>(ResultCode.OK,meetAreaService.queryPage(pageRequestObject)); } @PostMapping("/queryList") @ApiOperation("查询所有的区域数据") @SysLog(actionType = "4",value = "查询所有的区域数据") public ResultObj<List<MeetArea>> queryList(){ return new ResultObj<List<MeetArea>>(ResultCode.OK,meetAreaService.selectList(null)); } @PostMapping("/selectById") @ApiOperation("查看该区域的详情,主要是查看该区域下配置的站点信息") @SysLog(actionType = "4",value = "查看该区域的详情,主要是查看该区域下配置的站点信息") public ResultObj<MeetAreaSiteVo> selectById(@RequestParam("id")Integer id){ return new ResultObj<MeetAreaSiteVo>(ResultCode.OK,meetAreaService.selectAreaById(id)); } @PostMapping("/delete") @ApiOperation("删除区域数据") @SysLog(actionType = "2",value = "删除区域数据") public ResultObj delete(@RequestParam("id")Integer id ){ if(StringUtils.isEmpty(id)){ throw new CustomException(ResultCode.PARAM_NULL); } boolean b = meetAreaService.deleteById(id); EntityWrapper<MeetAreaSite> wrapper = new EntityWrapper<>(); wrapper.eq("area_id",id); boolean del = meetAreaSiteService.delete(wrapper); if(b){ return ResultObj.ok(); } return new ResultObj(ResultCode.DELETE_ERROR); } @PostMapping("/add") @ApiOperation("添加区域") @SysLog(actionType = "1",value = "添加区域") public ResultObj addDuty(@RequestParam("areaName") String areaName){ if(!StringUtils.isEmpty(areaName)){ MeetArea meetArea = new MeetArea(); meetArea.setAreaName(areaName); boolean insert = meetAreaService.insert(meetArea); if(insert){ return ResultObj.ok(); } } return new ResultObj(ResultCode.PARAM_NULL); } @PostMapping("/update") @ApiOperation("修改区域") @SysLog(actionType = "3",value = "修改区域") public ResultObj updateDuty(@RequestBody MeetArea meetArea){ if(!StringUtils.isEmpty(meetArea)){ boolean delete = meetAreaService.updateById(meetArea); if(delete){ return ResultObj.ok(); } } return new ResultObj(ResultCode.PARAM_NULL); } @PostMapping("/findNotArea") @ApiOperation("查询没有分配区域的站点数据") @SysLog(actionType = "4",value = "查询没有分配区域的站点数据") public ResultObj<PageResultObject<ProSiteInfoEntity>> queryNoAreaSite(@RequestBody PageRequestObject<String> pageRequestObject){ return new ResultObj<>(ResultCode.OK,meetAreaSiteService.queryNoAreaSite(pageRequestObject)); } }