server/dmvisit_admin/src/main/java/com/doumee/api/system/SystemDictDataController.java
@@ -8,6 +8,8 @@ import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Constants; import com.doumee.dao.admin.request.LaborConfigDTO; import com.doumee.dao.admin.request.VisitConfigDTO; import com.doumee.dao.system.dto.QuerySystemDictDataDTO; import com.doumee.dao.system.model.SystemDictData; import com.doumee.dao.system.vo.SystemDictDataListVO; @@ -111,4 +113,47 @@ public ApiResponse<SystemDictData> getSystemDictData(@RequestParam String dictCode, @RequestParam String label) { return ApiResponse.success(systemDictDataBiz.queryByCode(dictCode,label)); } /** * 访客æ¥è®¿é ç½® * @return */ @ApiOperation(value = "访客æ¥è®¿é ç½®" ) @GetMapping("/getVisitConfigDTO") public ApiResponse<VisitConfigDTO> getVisitConfigDTO(){ return ApiResponse.success(systemDictDataService.getVisitConfigDTO()); }; /** * ä¿®æ¹è®¿å®¢æ¥è®¿é ç½® * @param visitConfigDTO */ @ApiOperation(value = "ä¿®æ¹è®¿å®¢æ¥è®¿é ç½®" ) @PostMapping("/updateVisitConfig") public ApiResponse updateVisitConfig(@RequestBody VisitConfigDTO visitConfigDTO){ systemDictDataService.updateVisitConfig(visitConfigDTO); return ApiResponse.success(null); }; /** * å³å¡æ¥è®¿é ç½® * @return */ @ApiOperation(value = "å³å¡æ¥è®¿é ç½®" ) @GetMapping("/getLaborConfigDTO") public ApiResponse<LaborConfigDTO> getLaborConfigDTO(){ return ApiResponse.success(systemDictDataService.getLaborConfigDTO()); }; /** * ä¿®æ¹å³å¡æ¥è®¿é ç½® * @param miniProgrammeDTO */ @ApiOperation(value = "ä¿®æ¹å³å¡æ¥è®¿é ç½®" ) @PostMapping("/updateLaborConfigDTO") public ApiResponse updateLaborConfigDTO(@RequestBody LaborConfigDTO miniProgrammeDTO){ systemDictDataService.updateLaborConfigDTO(miniProgrammeDTO); return ApiResponse.success(null); }; } server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,8 +1,13 @@ package com.doumee.core.utils; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.math.BigDecimal; import java.net.URLDecoder; import java.text.SimpleDateFormat; @@ -37,6 +42,10 @@ public static final String EDS_PWD ="!@#$%^&QWERTY" ; public static final String ROOT_PATH = ""; public static final String FILE_DIR = ""; // 访客æ¥è®¿é ç½® public static final String VISIT_CONFIG = "VISIT_CONFIG"; // å³å¡æ¥è®¿é ç½® public static final String LABOR_CONFIG = "LABOR_CONFIG"; public static Date getBirthdyByCardNo(String idCard){ @@ -255,7 +264,27 @@ } } /** * å¯¹è±¡é©¼å³°å±æ§è½¬ä¸å线 * @param object * @return * @throws JsonProcessingException */ public static String toUnderlineJSONString(Object object) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String reqJson = mapper.writeValueAsString(object); return reqJson; } public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); T reqJson = mapper.readValue(json, clazz); return reqJson; } } server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/LaborConfigDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,32 @@ package com.doumee.dao.admin.request; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author T14 */ @Data @ApiModel("å³å¡è®¿å®¢é ç½®") public class LaborConfigDTO { @ApiModelProperty(value = "æ¥è®¿é¢çº¦æ¹å¼") private String reservationWay = ""; @ApiModelProperty(value = "è¢«è®¿äººæ ¡éªæ¹å¼") private String checkVisit = ""; @ApiModelProperty(value = "å¥åº·è¯æ¯å¦å¿ å¡«") private String healthCard = ""; @ApiModelProperty(value = "å³å¡æ¯å¦çé¢") private String isAnswer = ""; @ApiModelProperty(value = "å³å¡çé¢ä¸»é¢") private String theme = ""; @ApiModelProperty(value = "å³å¡çé¢è¯´æ") private String description = ""; } server/dmvisit_service/src/main/java/com/doumee/dao/admin/request/VisitConfigDTO.java
@@ -1,8 +1,14 @@ package com.doumee.dao.admin.request; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; /** @@ -13,20 +19,42 @@ public class VisitConfigDTO { @ApiModelProperty(value = "æ¥è®¿é¢çº¦æ¹å¼") private Integer reservationWay; private String reservationWay = ""; @ApiModelProperty(value = "è¢«è®¿äººæ ¡éªæ¹å¼") private Integer checkVisit; private String checkVisit = ""; @ApiModelProperty(value = "å¥åº·è¯æ¯å¦å¿ å¡«") private Integer healthCard; private String healthCard = ""; @ApiModelProperty(value = "å³å¡æ¯å¦çé¢") private Integer isAnswer; private String isAnswer = ""; @ApiModelProperty(value = "å³å¡çé¢ä¸»é¢") private String theme; private String theme = ""; @ApiModelProperty(value = "å³å¡çé¢è¯´æ") private String description; private String description = ""; // /** // * å¯¹è±¡é©¼å³°å±æ§è½¬ä¸å线 // * @param object // * @return // * @throws JsonProcessingException // */ // public static String toUnderlineJSONString(Object object) throws JsonProcessingException { // ObjectMapper mapper = new ObjectMapper(); // mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); // mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // String reqJson = mapper.writeValueAsString(object); // return reqJson; // } // // // public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException { // ObjectMapper mapper = new ObjectMapper(); // mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); // T reqJson = mapper.readValue(json, clazz); // return reqJson; // } } server/dmvisit_service/src/main/java/com/doumee/service/system/SystemDictDataService.java
@@ -2,6 +2,8 @@ import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.dao.admin.request.LaborConfigDTO; import com.doumee.dao.admin.request.VisitConfigDTO; import com.doumee.dao.system.dto.QuerySystemDictDataDTO; import com.doumee.dao.system.model.SystemDictData; import com.doumee.dao.system.vo.SystemDictDataListVO; @@ -70,7 +72,7 @@ * @date 2023/03/21 14:49 */ List<SystemDictData> findList(SystemDictData systemDictData); /** * å页æ¥è¯¢ * @author Eva.Caesar Liu @@ -96,5 +98,28 @@ List<SystemDictData> findList(Integer dicId,List<String> codes); /** * 访客æ¥è®¿é ç½® * @return */ VisitConfigDTO getVisitConfigDTO(); /** * ä¿®æ¹è®¿å®¢æ¥è®¿é ç½® * @param miniProgrammeDTO */ void updateVisitConfig(VisitConfigDTO miniProgrammeDTO); /** * å³å¡æ¥è®¿é ç½® * @return */ LaborConfigDTO getLaborConfigDTO(); /** * ä¿®æ¹å³å¡æ¥è®¿é ç½® * @param miniProgrammeDTO */ void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO); } server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -1,9 +1,15 @@ package com.doumee.service.system.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.utils.Constants; import com.doumee.dao.admin.request.LaborConfigDTO; import com.doumee.dao.admin.request.VisitConfigDTO; import com.doumee.dao.system.SystemDictMapper; import com.doumee.dao.system.model.SystemDict; import com.fasterxml.jackson.core.JsonProcessingException; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.doumee.core.model.PageData; @@ -22,6 +28,7 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * åå ¸æ°æ®Serviceå®ç° @@ -34,6 +41,8 @@ @Autowired private SystemDictDataMapper systemDictDataMapper; @Autowired private SystemDictMapper systemDictMapper; @Override public Integer create(SystemDictData systemDictData) { systemDictDataMapper.insert(systemDictData); @@ -91,7 +100,7 @@ Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData); return systemDictDataMapper.selectList(wrapper); } @Override public PageData<SystemDictDataListVO> findPage(PageWrap<QuerySystemDictDataDTO> pageWrap) { PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); @@ -112,4 +121,132 @@ .in(SystemDictData::getLabel,codes); return systemDictDataMapper.selectList(wrapper); } @Override public VisitConfigDTO getVisitConfigDTO() { try { String jasonStr = Constants.toUnderlineJSONString(new VisitConfigDTO()); JSONObject parse = (JSONObject) JSONObject.parse(jasonStr); List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList()); QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); systemDictQuery.lambda() .eq(SystemDict::getDeleted,Boolean.FALSE) .eq(SystemDict::getCode,Constants.VISIT_CONFIG); SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); if (Objects.isNull(systemDict)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸ä¸åå¨"); } QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(SystemDictData::getDictId,systemDict.getId()) .in(SystemDictData::getLabel,collect); List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper); if (CollectionUtils.isEmpty(systemDictData)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸å¼ä¸åå¨"); } systemDictData.forEach(s->{ parse.put(s.getLabel().toLowerCase(),s.getCode()); }); String s = parse.toJSONString(); VisitConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, VisitConfigDTO.class); return miniProgrammeDTO; } catch (Exception e) { throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"åå ¸å¼è§£ææè¯¯"); } } @Override public void updateVisitConfig(VisitConfigDTO miniProgrammeDTO) { try { QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); systemDictQuery.lambda() .eq(SystemDict::getDeleted,Boolean.FALSE) .eq(SystemDict::getCode,Constants.VISIT_CONFIG); SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); if (Objects.isNull(systemDict)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸ä¸åå¨"); } String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO); JSONObject parse = (JSONObject) JSONObject.parse(jasonStr); parse.entrySet().forEach(s->{ UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>(); wrapper.lambda() .eq(SystemDictData::getDictId,systemDict.getId()) .eq(SystemDictData::getLabel,s.getKey().toUpperCase()) .set(SystemDictData::getCode,s.getValue()); systemDictDataMapper.update(null,wrapper); }); } catch (JsonProcessingException e) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"åå ¸å¼è§£ææè¯¯"); } } @Override public LaborConfigDTO getLaborConfigDTO() { try { String jasonStr = Constants.toUnderlineJSONString(new LaborConfigDTO()); JSONObject parse = (JSONObject) JSONObject.parse(jasonStr); List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList()); QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); systemDictQuery.lambda() .eq(SystemDict::getDeleted,Boolean.FALSE) .eq(SystemDict::getCode,Constants.LABOR_CONFIG); SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); if (Objects.isNull(systemDict)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸ä¸åå¨"); } QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(SystemDictData::getDictId,systemDict.getId()) .in(SystemDictData::getLabel,collect); List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper); if (CollectionUtils.isEmpty(systemDictData)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸å¼ä¸åå¨"); } systemDictData.forEach(s->{ parse.put(s.getLabel().toLowerCase(),s.getCode()); }); String s = parse.toJSONString(); LaborConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, LaborConfigDTO.class); return miniProgrammeDTO; } catch (Exception e) { throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"åå ¸å¼è§£ææè¯¯"); } } @Override public void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO) { try { QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>(); systemDictQuery.lambda() .eq(SystemDict::getDeleted,Boolean.FALSE) .eq(SystemDict::getCode,Constants.VISIT_CONFIG); SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery); if (Objects.isNull(systemDict)){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"åå ¸ä¸åå¨"); } String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO); JSONObject parse = (JSONObject) JSONObject.parse(jasonStr); parse.entrySet().forEach(s->{ UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>(); wrapper.lambda() .eq(SystemDictData::getDictId,systemDict.getId()) .eq(SystemDictData::getLabel,s.getKey().toUpperCase()) .set(SystemDictData::getCode,s.getValue()); systemDictDataMapper.update(null,wrapper); }); } catch (JsonProcessingException e) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"åå ¸å¼è§£ææè¯¯"); } } }