|  |  |  | 
|---|
|  |  |  | package com.matrix.system.app.action; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.pojo.PaginationVO; | 
|---|
|  |  |  | import com.matrix.core.tools.StringUtils; | 
|---|
|  |  |  | import com.matrix.system.app.dto.SkinCheckListDto; | 
|---|
|  |  |  | import com.matrix.system.app.mapper.SysSkinCheckRecordMapper; | 
|---|
|  |  |  | import com.matrix.system.app.vo.SkinCheckAnalysisItems; | 
|---|
|  |  |  | import com.matrix.system.app.vo.SkinCheckDetailVo; | 
|---|
|  |  |  | import com.matrix.system.app.vo.SkinCheckDiagnoseItemVo; | 
|---|
|  |  |  | import com.matrix.system.app.vo.SkinCheckListVo; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysSkinCheckRecord; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.SysSkinCheckRecordDao; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.CollectionUtils; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.bean.ShopProduct; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.dao.ShopProductDao; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponse; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponses; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/api/skinCheck") | 
|---|
|  |  |  | public class ApiSkinCheckAction { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysSkinCheckRecordDao sysSkinCheckRecordDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ShopProductDao shopProductDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取皮肤检测列表", notes = "获取皮肤检测列表") | 
|---|
|  |  |  | @PostMapping(value = "/findSkinCheckList") | 
|---|
|  |  |  | public AjaxResult findSkinCheckList(@RequestBody @Validated SkinCheckListDto skinCheckListDto) { | 
|---|
|  |  |  | SysSkinCheckRecord sysSkinCheckRecord = new SysSkinCheckRecord(); | 
|---|
|  |  |  | sysSkinCheckRecord.setUserId(skinCheckListDto.getVipId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PaginationVO pageVo = new PaginationVO(); | 
|---|
|  |  |  | pageVo.setOffset((skinCheckListDto.getPageNum() - 1) * skinCheckListDto.getPageSize()); | 
|---|
|  |  |  | pageVo.setLimit(skinCheckListDto.getPageSize()); | 
|---|
|  |  |  | pageVo.setSort("t1.create_time"); | 
|---|
|  |  |  | pageVo.setOrder("desc"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<SysSkinCheckRecord> dataList = sysSkinCheckRecordDao.selectInPage(sysSkinCheckRecord, pageVo); | 
|---|
|  |  |  | List<SkinCheckListVo> list = SysSkinCheckRecordMapper.INSTANCE.entitiesToListVos(dataList); | 
|---|
|  |  |  | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, list, | 
|---|
|  |  |  | sysSkinCheckRecordDao.selectTotalRecord(sysSkinCheckRecord)); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取皮肤检测详情", notes = "获取皮肤检测详情") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = SkinCheckDetailVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findSkinCheckDetail/{id}") | 
|---|
|  |  |  | public AjaxResult findSkinCheckDetail(@PathVariable("id") Long id) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysSkinCheckRecord sysSkinCheckRecord = sysSkinCheckRecordDao.selectById(id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysSkinCheckRecordMapper instance = SysSkinCheckRecordMapper.INSTANCE; | 
|---|
|  |  |  | SkinCheckDetailVo detail = instance.entityToDetailVo(sysSkinCheckRecord); | 
|---|
|  |  |  | detail.setSex(sysSkinCheckRecord.getSex()); | 
|---|
|  |  |  | List<SkinCheckDiagnoseItemVo> diagnoseItems = instance.entitiesToDiagnoseItems(sysSkinCheckRecord.getAnalysisDetail()); | 
|---|
|  |  |  | List<SkinCheckAnalysisItems> analysisItems = instance.entitiesToAnalysisItems(sysSkinCheckRecord.getSkinDetails()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | analysisItems.forEach(item -> { | 
|---|
|  |  |  | List<Integer> ids = StringUtils.strToCollToInteger(item.getProductIds(), ","); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(ids)){ | 
|---|
|  |  |  | List<String> shopProducts = shopProductDao.selectProductNameByIds(ids); | 
|---|
|  |  |  | item.setProducts(shopProducts); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | detail.setDiagnoseItems(diagnoseItems); | 
|---|
|  |  |  | detail.setAnalysisItems(analysisItems); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); | 
|---|
|  |  |  | ajaxResult.putInMap("detail", detail); | 
|---|
|  |  |  | return ajaxResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|