| | |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.dao.enums.AdministratorEnums; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | *客户模块 |
| | | * 客户模块 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | |
| | | private final ClientService clientService; |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addClient(@RequestBody ClientPrarm clientPrarm){ |
| | | public ResponseVO<Object> addClient(@RequestBody @Validated ClientPrarm clientPrarm) { |
| | | boolean b = clientService.addClient(clientPrarm); |
| | | if(b){ |
| | | if (b) { |
| | | return ResponseUtil.success("添加成功"); |
| | | }else { |
| | | } else { |
| | | return ResponseUtil.fail("添加失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping ("/update/{id}") |
| | | public ResponseVO<Object> updateClient(@PathVariable Long id,@RequestBody ClientPrarm clientPrarm){ |
| | | boolean b = clientService.updateClient(id,clientPrarm); |
| | | if(b){ |
| | | @PostMapping("/update/{id}") |
| | | public ResponseVO<Object> updateClient(@PathVariable Long id, @RequestBody @Validated ClientPrarm clientPrarm) { |
| | | boolean b = clientService.updateClient(id, clientPrarm); |
| | | if (b) { |
| | | return ResponseUtil.success("更新成功"); |
| | | }else { |
| | | } else { |
| | | return ResponseUtil.fail("更新失败"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteClient(@PathVariable Long id){ |
| | | public ResponseVO<Object> deleteClient(@PathVariable Long id) { |
| | | boolean b = clientService.deleteClient(id); |
| | | if(b){ |
| | | if (b) { |
| | | return ResponseUtil.success("删除成功"); |
| | | }else { |
| | | } else { |
| | | return ResponseUtil.fail("删除失败"); |
| | | } |
| | | } |
| | |
| | | public ResponseVO<Object> listLikeClient(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<Client> wrapper = Wrappers.lambdaQuery(Client.class); |
| | | if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())){ |
| | | wrapper.eq(Client::getSuperiorId,SecurityUtils.getUserId()); |
| | | if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | wrapper.eq(Client::getSuperiorId, SecurityUtils.getUserId()); |
| | | } |
| | | if(null!=keyword){ |
| | | wrapper.like(Client::getClientName,keyword) |
| | | .or(clientLambdaQueryWrapper -> clientLambdaQueryWrapper.like(Client::getMobile,keyword)) |
| | | .or(clientLambdaQueryWrapper -> clientLambdaQueryWrapper.like(Client::getLinkMan,keyword)); |
| | | if (null != keyword) { |
| | | wrapper.like(Client::getClientName, keyword) |
| | | .or(clientLambdaQueryWrapper -> clientLambdaQueryWrapper.like(Client::getMobile, keyword)) |
| | | .or(clientLambdaQueryWrapper -> clientLambdaQueryWrapper.like(Client::getLinkMan, keyword)); |
| | | } |
| | | return ResponseUtil.successPage(clientService.list(wrapper)); |
| | | } |