| | |
| | | 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; |
| | |
| | | @ApiOperation(value = "验光师添加") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@RequestBody TOptometrist dto) { |
| | | if (StringUtils.hasLength(dto.getName())&&dto.getName().length()>15){ |
| | | return ApiResult.failed("验光师名称不能超过15个字"); |
| | | } |
| | | TOptometrist one = optometristService.lambdaQuery().eq(TOptometrist::getPhone, dto.getPhone()) |
| | | .eq(TOptometrist::getStatus, 1).one(); |
| | | if (one!=null){ |
| | |
| | | @ApiOperation(value = "验光师编辑") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update(@RequestBody TOptometrist dto) { |
| | | if (StringUtils.hasLength(dto.getName())&&dto.getName().length()>15){ |
| | | return ApiResult.failed("验光师名称不能超过15个字"); |
| | | } |
| | | |
| | | TOptometrist one = optometristService.lambdaQuery().eq(TOptometrist::getPhone, dto.getPhone()) |
| | | .ne(TOptometrist::getId,dto.getId()) |
| | | .eq(TOptometrist::getStatus, 1).one(); |
| | |
| | | |
| | | @ApiOperation(value = "验光师上下架") |
| | | @GetMapping(value = "/upAndDown") |
| | | public ApiResult<Boolean> upAndDown(@RequestParam Integer id, |
| | | public ApiResult upAndDown(@RequestParam Integer id, |
| | | @RequestParam Integer status) { |
| | | TOptometrist optometrist = optometristService.getById(id); |
| | | if (status==1){ |
| | | // 启用之前 先查询有没有手机号相同的验光师正在启用状态 |
| | | TOptometrist oldOptometrist = optometristService.lambdaQuery().eq(TOptometrist::getPhone, optometrist.getPhone()).eq(TOptometrist::getStatus, 1).one(); |
| | | if (oldOptometrist!=null){ |
| | | return ApiResult.failed("当前手机号正在使用"); |
| | | } |
| | | } |
| | | return ApiResult.success(optometristService.upAndDown(id,status)); |
| | | } |
| | | } |