| | |
| | | package com.jilongda.applet.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.applet.model.TOptometrist; |
| | | import com.jilongda.applet.model.TOptometry; |
| | | import com.jilongda.applet.model.TOptometryDetail; |
| | | import com.jilongda.applet.model.TStore; |
| | | import com.jilongda.applet.query.TOptometryQuery; |
| | | import com.jilongda.applet.service.TOptometristService; |
| | | import com.jilongda.applet.service.TOptometryDetailService; |
| | | import com.jilongda.applet.service.TOptometryService; |
| | | import com.jilongda.applet.service.TStoreService; |
| | | import com.jilongda.applet.utils.LoginInfoUtil; |
| | | import com.jilongda.applet.vo.TOptometryVO; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "验光单") |
| | | @RestController |
| | | @RequestMapping("/t-optometry") |
| | | public class TOptometryController { |
| | | |
| | | @Autowired |
| | | private TOptometryService tOptometryService; |
| | | @Autowired |
| | | private TOptometryDetailService optometryDetailService; |
| | | @Autowired |
| | | private TOptometristService optometristService; |
| | | @Autowired |
| | | private TStoreService storeService; |
| | | @Autowired |
| | | private LoginInfoUtil loginInfoUtil; |
| | | |
| | | @ApiOperation(value = "视光档案") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult pageList(@RequestBody TOptometryQuery query) { |
| | | Integer userId = loginInfoUtil.getUserId(); |
| | | query.setUserId(userId); |
| | | PageInfo<TOptometryVO> tOptometryVOPageInfo = tOptometryService.pageList(query); |
| | | return ApiResult.success(tOptometryVOPageInfo); |
| | | } |
| | | |
| | | @ApiOperation(value = "视光档案详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public ApiResult getDetailById(@RequestParam Integer id) { |
| | | TOptometry optometry = tOptometryService.getById(id); |
| | | TOptometryVO tOptometryVO = new TOptometryVO(); |
| | | BeanUtils.copyProperties(optometry, tOptometryVO); |
| | | TOptometrist optometrist = optometristService.getById(optometry.getOptometristId()); |
| | | if(Objects.nonNull(optometrist)){ |
| | | tOptometryVO.setOptometristName(optometrist.getName()); |
| | | } |
| | | TStore store = storeService.getById(optometry.getStoreId()); |
| | | if(Objects.nonNull(store)){ |
| | | tOptometryVO.setStoreName(store.getName()); |
| | | } |
| | | |
| | | List<TOptometryDetail> list = optometryDetailService.list(Wrappers.<TOptometryDetail>lambdaQuery().eq(TOptometryDetail::getOptometryId, id)); |
| | | List<TOptometryDetail> completeCorrectionList = new ArrayList<>(); |
| | | List<TOptometryDetail> prescriptionGlassesList = new ArrayList<>(); |
| | | List<TOptometryDetail> oldMirrorInformationList = new ArrayList<>(); |
| | | for (TOptometryDetail tOptometryDetail : list) { |
| | | switch (tOptometryDetail.getType()){ |
| | | case 1: |
| | | prescriptionGlassesList.add(tOptometryDetail); |
| | | break; |
| | | case 2: |
| | | completeCorrectionList.add(tOptometryDetail); |
| | | break; |
| | | default: |
| | | oldMirrorInformationList.add(tOptometryDetail); |
| | | break; |
| | | } |
| | | } |
| | | tOptometryVO.setCompleteCorrectionList(completeCorrectionList); |
| | | tOptometryVO.setPrescriptionGlassesList(prescriptionGlassesList); |
| | | tOptometryVO.setOldMirrorInformationList(oldMirrorInformationList); |
| | | return ApiResult.success(tOptometryVO); |
| | | } |
| | | |
| | | } |
| | | |