| | |
| | | package com.jilongda.manage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.manage.authority.model.SecUser; |
| | | import com.jilongda.manage.authority.service.SecUserService; |
| | | import com.jilongda.manage.model.TOptometrist; |
| | | import com.jilongda.manage.query.TOptometristQuery; |
| | | import com.jilongda.manage.query.TicketQuery; |
| | | import com.jilongda.manage.service.TOptometristService; |
| | | import com.jilongda.manage.vo.TOptometristVO; |
| | | 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.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "验光师管理") |
| | | @RestController |
| | | @RequestMapping("/t-optometrist") |
| | | public class TOptometristController { |
| | | @Autowired |
| | | private TOptometristService optometristService; |
| | | @Autowired |
| | | private SecUserService secUserService; |
| | | |
| | | @ApiOperation(value = "验光师列表") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TOptometristVO>> pageList(@RequestBody TOptometristQuery query) { |
| | | PageInfo<TOptometristVO> optometristVOPageInfo = optometristService.pageList1(query); |
| | | return ApiResult.success(optometristVOPageInfo); |
| | | } |
| | | |
| | | @ApiOperation(value = "通过门店id查询验光师列表") |
| | | @PostMapping(value = "/queryListByStoreId") |
| | | public ApiResult<List<TOptometrist>> queryListByStoreId(@RequestParam Integer storeId) { |
| | | List<TOptometrist> optometristVOPageInfo = optometristService.list(Wrappers.lambdaQuery(TOptometrist.class) |
| | | .eq(TOptometrist::getStoreId,storeId)); |
| | | return ApiResult.success(optometristVOPageInfo); |
| | | } |
| | | @ApiOperation(value = "验光师详情") |
| | | @GetMapping(value = "/detail") |
| | | public ApiResult<TOptometrist> detail(Integer id) { |
| | | return ApiResult.success(optometristService.getById(id)); |
| | | } |
| | | @ApiOperation(value = "验光师添加") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@Validated @RequestBody TOptometrist dto) { |
| | | Long count = optometristService.lambdaQuery().eq(TOptometrist::getPhone, dto.getPhone()) |
| | | .eq(TOptometrist::getStatus, 1).count(); |
| | | if (count>0){ |
| | | return ApiResult.failed("当前号码已存在"); |
| | | } |
| | | List<SecUser> list = secUserService.lambdaQuery().eq(SecUser::getPhone, dto.getPhone()).list(); |
| | | if (!list.isEmpty())return ApiResult.failed("当前号码在员工管理已存在"); |
| | | optometristService.save(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @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个字"); |
| | | } |
| | | |
| | | Long count = optometristService.lambdaQuery().eq(TOptometrist::getPhone, dto.getPhone()) |
| | | .ne(TOptometrist::getId,dto.getId()) |
| | | .eq(TOptometrist::getStatus, 1).count(); |
| | | if (count>0){ |
| | | return ApiResult.failed("当前号码已存在"); |
| | | } |
| | | List<SecUser> list = secUserService.lambdaQuery().eq(SecUser::getPhone, dto.getPhone()).list(); |
| | | if (!list.isEmpty())return ApiResult.failed("当前号码在员工管理已存在"); |
| | | optometristService.updateById(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "验光师上下架") |
| | | @GetMapping(value = "/upAndDown") |
| | | 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)); |
| | | } |
| | | } |
| | | |