Selaa lähdekoodia

新增健康教育类型字典

hsh 1 vuosi sitten
vanhempi
commit
a2a87941b7

+ 16 - 0
src/main/java/thyyxxk/webserver/controller/dictionary/ServiceNumberController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.dictionary.ZdHealthEducation;
+import thyyxxk.webserver.entity.dictionary.ZdHealthEducationType;
 import thyyxxk.webserver.service.dictionary.ServiceNumberService;
 
 import java.util.List;
@@ -54,4 +55,19 @@ public class ServiceNumberController {
         return service.delHealthEducationByCode(code);
     }
 
+    @GetMapping("/selectHeType")
+    public ResultVo<List<ZdHealthEducationType>> selectHeType(){
+        return service.selectHeType();
+    }
+
+    @PostMapping("/saveHeType")
+    public ResultVo<Map<String, Object>> saveHeType(@RequestBody @Validated ZdHealthEducationType zdHealthEducationType){
+        return service.saveHeType(zdHealthEducationType);
+    }
+
+    @GetMapping("/delHeTypeByCode")
+    public ResultVo<Map<String, Object>> delHeTypeByCode(@RequestParam("code") String code){
+        return service.delHeTypeByCode(code);
+    }
+
 }

+ 46 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/ZdHealthEducationTypeDao.java

@@ -0,0 +1,46 @@
+package thyyxxk.webserver.dao.his.dictionary;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.dictionary.ZdHealthEducation;
+import thyyxxk.webserver.entity.dictionary.ZdHealthEducationType;
+
+import java.util.List;
+
+@Mapper
+public interface ZdHealthEducationTypeDao extends BaseMapper<ZdHealthEducationType> {
+
+    @Select(" select * from zd_health_education_type order by sort ")
+    List<ZdHealthEducationType> selectHeType();
+
+    @Select(" select * from zd_health_education_type where code = #{code}  ")
+    ZdHealthEducationType selectHeTypeByCode(@Param("code") String code);
+
+    @Update("<script>" +
+            "update zd_health_education_type " +
+            "<trim prefix=\"set\" suffixOverrides=\",\">" +
+            "<if test=\"code != null and code != '' \">" +
+            "code = #{code}, " +
+            "</if>" +
+            "<if test=\"name != null and name != '' \">" +
+            "name = #{name}, " +
+            "</if>" +
+            "<if test=\"sort != null and sort != '' \">" +
+            "sort = #{sort}, " +
+            "</if>" +
+            "<if test=\"delFlag != null and delFlag != '' \">" +
+            "del_flag = #{delFlag}, " +
+            "</if>" +
+            "</trim>" +
+            "where code = #{code} " +
+            "</script>")
+    int updateHeTypeByCode(ZdHealthEducationType zdHealthEducationType);
+
+    @Delete(" delete from zd_health_education_type where code = #{code} ")
+    int deleteHeTypeByCode(@Param("code") String code);
+
+}

+ 28 - 0
src/main/java/thyyxxk/webserver/entity/dictionary/ZdHealthEducationType.java

@@ -0,0 +1,28 @@
+package thyyxxk.webserver.entity.dictionary;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @ClassName ZdHealthEducationType
+ * @Author hsh
+ * @Date 2024/3/25 8:56
+ * @Version 1.0
+ * @Description 健康教育类型
+ **/
+@Data
+@TableName(value = "zd_health_education_type")
+public class ZdHealthEducationType implements Serializable {
+
+    private static final long serialVersionUID = -1L;
+    @TableId(value = "code", type = IdType.NONE)
+    private String code;
+    private String name;
+    private String sort;
+    private String delFlag;
+
+}

+ 55 - 1
src/main/java/thyyxxk/webserver/service/dictionary/ServiceNumberService.java

@@ -5,9 +5,11 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.dictionary.ServiceNumberDao;
 import thyyxxk.webserver.dao.his.dictionary.ZdHealthEducationDao;
+import thyyxxk.webserver.dao.his.dictionary.ZdHealthEducationTypeDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.dictionary.ZdHealthEducation;
+import thyyxxk.webserver.entity.dictionary.ZdHealthEducationType;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 
@@ -31,9 +33,13 @@ public class ServiceNumberService {
 
     private final ZdHealthEducationDao healthEducationDao;
 
-    public ServiceNumberService(ServiceNumberDao dao, ZdHealthEducationDao healthEducationDao) {
+    private final ZdHealthEducationTypeDao zdHealthEducationTypeDao;
+
+    public ServiceNumberService(ServiceNumberDao dao, ZdHealthEducationDao healthEducationDao,
+                                ZdHealthEducationTypeDao zdHealthEducationTypeDao) {
         this.dao = dao;
         this.healthEducationDao = healthEducationDao;
+        this.zdHealthEducationTypeDao = zdHealthEducationTypeDao;
     }
 
     public ResultVo<Map<String, List<CodeName>>> selectServiceNumberDict(){
@@ -109,4 +115,52 @@ public class ServiceNumberService {
         }
     }
 
+    public ResultVo<List<ZdHealthEducationType>> selectHeType(){
+        return ResultVoUtil.success(zdHealthEducationTypeDao.selectHeType());
+    }
+
+    public ResultVo<Map<String, Object>> saveHeType(ZdHealthEducationType zdHealthEducationType){
+
+        if(null == zdHealthEducationType || zdHealthEducationType.getCode() == null){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "健康教育类型信息不存在,请检查!");
+        }
+
+        Map<String, Object> resultMap = new HashMap<>();
+        String code = zdHealthEducationType.getCode();
+        ZdHealthEducationType type = zdHealthEducationTypeDao.selectHeTypeByCode(code);
+        int num;
+        try{
+            if(null != type){
+                num = zdHealthEducationTypeDao.updateHeTypeByCode(zdHealthEducationType);
+            } else {
+                num = zdHealthEducationTypeDao.insert(zdHealthEducationType);
+            }
+            if(num == 0){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存健康教育类型信息失败!");
+            }
+            resultMap.put("cg", "保存健康教育类型信息成功!");
+            return ResultVoUtil.success(resultMap);
+        } catch(Exception e){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存健康教育类型信息失败!");
+        }
+    }
+
+    public ResultVo<Map<String, Object>> delHeTypeByCode(String code) {
+        if (StringUtil.isBlank(code)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有健康教育类型编码,请检查!");
+        }
+
+        Map<String, Object> resultMap = new HashMap<>();
+        try{
+            int num = zdHealthEducationTypeDao.deleteHeTypeByCode(code);
+            if(num == 0){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除健康教育类型失败!");
+            }
+            resultMap.put("cg", "删除健康教育类型成功!");
+            return ResultVoUtil.success(resultMap);
+        } catch(Exception e){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除健康教育类型失败!");
+        }
+    }
+
 }