| package com.zy.acs.manager.manager.controller; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.zy.acs.framework.common.Cools; | 
| import com.zy.acs.framework.common.R; | 
| import com.zy.acs.manager.common.utils.ExcelUtil; | 
| import com.zy.acs.manager.common.annotation.OperationLog; | 
| import com.zy.acs.manager.common.domain.BaseParam; | 
| import com.zy.acs.manager.common.domain.KeyValVo; | 
| import com.zy.acs.manager.common.domain.PageParam; | 
| import com.zy.acs.manager.manager.entity.CodeGap; | 
| import com.zy.acs.manager.manager.service.CodeGapService; | 
| import com.zy.acs.manager.system.controller.BaseController; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.security.access.prepost.PreAuthorize; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import javax.servlet.http.HttpServletResponse; | 
| import java.util.*; | 
|   | 
| @RestController | 
| @RequestMapping("/api") | 
| public class CodeGapController extends BaseController { | 
|   | 
|     @Autowired | 
|     private CodeGapService codeGapService; | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @PostMapping("/codeGap/page") | 
|     public R page(@RequestBody Map<String, Object> map) { | 
|         BaseParam baseParam = buildParam(map, BaseParam.class); | 
|         PageParam<CodeGap, BaseParam> pageParam = new PageParam<>(baseParam, CodeGap.class); | 
|         return R.ok().add(codeGapService.page(pageParam, pageParam.buildWrapper(true))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @PostMapping("/codeGap/list") | 
|     public R list(@RequestBody Map<String, Object> map) { | 
|         return R.ok().add(codeGapService.list()); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @PostMapping({"/codeGap/many/{ids}", "/codeGaps/many/{ids}"}) | 
|     public R many(@PathVariable Long[] ids) { | 
|         return R.ok().add(codeGapService.listByIds(Arrays.asList(ids))); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @GetMapping("/codeGap/{id}") | 
|     public R get(@PathVariable("id") Long id) { | 
|         return R.ok().add(codeGapService.getById(id)); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:save')") | 
|     @OperationLog("Create CodeGap") | 
|     @PostMapping("/codeGap/save") | 
|     public R save(@RequestBody CodeGap codeGap) { | 
|         if (codeGap.getCode0() == null || codeGap.getCode1() == null) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         if (codeGap.getCode0().equals(codeGap.getCode1())) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         if (codeGapService.count(new LambdaQueryWrapper<CodeGap>() | 
|                 .eq(CodeGap::getCode0, codeGap.getCode0()) | 
|                 .eq(CodeGap::getCode1, codeGap.getCode1())) > 0 || | 
|                 codeGapService.count(new LambdaQueryWrapper<CodeGap>() | 
|                         .eq(CodeGap::getCode0, codeGap.getCode1()) | 
|                         .eq(CodeGap::getCode1, codeGap.getCode0())) > 0 | 
|         ) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         codeGap.setCreateBy(getLoginUserId()); | 
|         codeGap.setCreateTime(new Date()); | 
|         codeGap.setUpdateBy(getLoginUserId()); | 
|         codeGap.setUpdateTime(new Date()); | 
|         if (!codeGapService.save(codeGap)) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         return R.ok("Save Success").add(codeGap); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:update')") | 
|     @OperationLog("Update CodeGap") | 
|     @PostMapping("/codeGap/update") | 
|     public R update(@RequestBody CodeGap codeGap) { | 
|         if (codeGap.getCode0() == null || codeGap.getCode1() == null) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         if (codeGap.getCode0().equals(codeGap.getCode1())) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         if (codeGapService.count(new LambdaQueryWrapper<CodeGap>() | 
|                 .eq(CodeGap::getCode0, codeGap.getCode0()) | 
|                 .eq(CodeGap::getCode1, codeGap.getCode1())) > 0 || | 
|                 codeGapService.count(new LambdaQueryWrapper<CodeGap>() | 
|                         .eq(CodeGap::getCode0, codeGap.getCode1()) | 
|                         .eq(CodeGap::getCode1, codeGap.getCode0())) > 0 | 
|         ) { | 
|             return R.error("Save Fail"); | 
|         } | 
|         codeGap.setUpdateBy(getLoginUserId()); | 
|         codeGap.setUpdateTime(new Date()); | 
|         if (!codeGapService.updateById(codeGap)) { | 
|             return R.error("Update Fail"); | 
|         } | 
|         return R.ok("Update Success").add(codeGap); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:remove')") | 
|     @OperationLog("Delete CodeGap") | 
|     @PostMapping("/codeGap/remove/{ids}") | 
|     public R remove(@PathVariable Long[] ids) { | 
|         if (!codeGapService.removeByIds(Arrays.asList(ids))) { | 
|             return R.error("Delete Fail"); | 
|         } | 
|         return R.ok("Delete Success").add(ids); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @PostMapping("/codeGap/query") | 
|     public R query(@RequestParam(required = false) String condition) { | 
|         List<KeyValVo> vos = new ArrayList<>(); | 
|         LambdaQueryWrapper<CodeGap> wrapper = new LambdaQueryWrapper<>(); | 
|         if (!Cools.isEmpty(condition)) { | 
|             wrapper.like(CodeGap::getId, condition); | 
|         } | 
|         codeGapService.page(new Page<>(1, 30), wrapper).getRecords().forEach( | 
|                 item -> vos.add(new KeyValVo(item.getId(), item.getId())) | 
|         ); | 
|         return R.ok().add(vos); | 
|     } | 
|   | 
|     @PreAuthorize("hasAuthority('manager:codeGap:list')") | 
|     @PostMapping("/codeGap/export") | 
|     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|         ExcelUtil.build(ExcelUtil.create(codeGapService.list(), CodeGap.class), response); | 
|     } | 
|   | 
| } |