Przeglądaj źródła

1、core模块类自动加载配置;
2、数据字典新增字典类型

17358629955 2 lat temu
rodzic
commit
b43bac6f00

+ 1 - 0
sckw-common/sckw-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+com.sckw.core.aspect.DaoAspect

+ 3 - 3
sckw-modules/sckw-message/src/main/resources/bootstrap-dev.yml

@@ -53,9 +53,9 @@ spring:
           binder: defaultRabbit
           group: sckw
   rabbitmq:
-    username: admin
-    password: admin
-    host: 10.10.10.138
+    username: wph
+    password: Yy123...
+    host: 39.104.134.114
     port: 5672
     virtual-host: /
 

+ 31 - 6
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/SysDictController.java

@@ -6,6 +6,7 @@ import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.model.SysDict;
+import com.sckw.system.model.SysDictType;
 import com.sckw.system.service.SysDictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -26,16 +27,27 @@ public class SysDictController {
     private SysDictService sysDictService;
 
     /**
-     * @param id 主键ID
+     * @param params {type:字典类型、name:类型名称}
      * @return
-     * @description 根据主键查询
+     * @description 新增
      * @author zk
      * @date 2023/5/30
      **/
-    @GetMapping("/detail")
-    public HttpResult selectByKey(Long id) throws Exception {
-        SysDict sysDict = sysDictService.selectByKey(id);
-        return HttpResult.ok(sysDict);
+    @PostMapping("/addType")
+    public HttpResult addType(@RequestBody SysDictType params) throws Exception {
+        return sysDictService.addType(params);
+    }
+
+    /**
+     * @param params {id:主键ID、type:字典类型、name:类型名称}
+     * @return
+     * @description 更新
+     * @author zk
+     * @date 2023/5/30
+     **/
+    @PostMapping("/updateType")
+    public HttpResult updateType(@RequestBody SysDictType params) throws Exception {
+        return sysDictService.updateType(params);
     }
 
     /**
@@ -54,6 +66,19 @@ public class SysDictController {
         return HttpResult.ok(pageResult);
     }
 
+    /**
+     * @param id 主键ID
+     * @return
+     * @description 根据主键查询
+     * @author zk
+     * @date 2023/5/30
+     **/
+    @GetMapping("/detail")
+    public HttpResult selectByKey(Long id) throws Exception {
+        SysDict sysDict = sysDictService.selectByKey(id);
+        return HttpResult.ok(sysDict);
+    }
+
     /**
      * @param params {type:字典类型}
      * @return

+ 36 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/SysDictTypeDao.java

@@ -0,0 +1,36 @@
+package com.sckw.system.dao;
+
+import com.sckw.system.model.SysDictType;
+import org.apache.ibatis.annotations.Mapper;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 字典类型
+ * @author zk
+ * @date 2023-05-30
+ */
+@Mapper
+public interface SysDictTypeDao {
+
+    /**
+     * 新增
+     * @param record
+     * @return
+     */
+    int insert(SysDictType record);
+
+    /**
+     * 更新
+     * @param record
+     * @return
+     */
+    int update(SysDictType record);
+
+    /**
+     * 查询
+     * @param params
+     * @return
+     */
+    List<SysDictType> findPage(Map<String, Object> params);
+}

+ 5 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/SysDict.java

@@ -11,6 +11,11 @@ import lombok.Data;
 @Data
 public class SysDict extends BaseModel {
 
+    /**
+     * 字典类型id
+     */
+    private Long dictId;
+
     /**
      * 选项值
      */

+ 24 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/SysDictType.java

@@ -0,0 +1,24 @@
+package com.sckw.system.model;
+
+import com.sckw.core.model.base.BaseModel;
+import lombok.Data;
+
+/**
+ * 字典类型
+ * @author zk
+ * @date 2023-05-30
+ */
+@Data
+public class SysDictType extends BaseModel {
+
+    /**
+     * 字典类型名称
+     */
+    private String name;
+
+    /**
+     * 类型
+     */
+    private String type;
+
+}

+ 46 - 10
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/SysDictService.java

@@ -5,7 +5,9 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.system.dao.SysDictDao;
+import com.sckw.system.dao.SysDictTypeDao;
 import com.sckw.system.model.SysDict;
+import com.sckw.system.model.SysDictType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import java.util.Date;
@@ -20,9 +22,53 @@ import java.util.Map;
 @Service
 public class SysDictService {
 
+    @Autowired
+    SysDictTypeDao sysDictTypeDao;
+
     @Autowired
     SysDictDao sysDictDao;
 
+    /**
+     * 添加新纪录
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    public HttpResult addType(SysDictType params) throws Exception {
+        /*params.setId(new IdWorker(1).nextId());
+        params.setStatus(0);
+        params.setCreateBy(0L);
+        params.setCreateTime(new Date());
+        params.setUpdateBy(0L);
+        params.setUpdateTime(new Date());
+        params.setDelFlag(0);*/
+        params.setCreateBy(0L);
+        params.setUpdateBy(0L);
+        int count = sysDictTypeDao.insert(params);
+        return count > 0 ? HttpResult.ok("添加成功!") : HttpResult.error();
+    }
+
+    /**
+     * 更新记录
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    public HttpResult updateType(SysDictType params) throws Exception {
+        int count = sysDictTypeDao.update(params);
+        return count > 0 ? HttpResult.ok("更新成功!") : HttpResult.error();
+    }
+
+    /**
+     * 分页查询
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    public List<SysDictType> findPage(Map<String, Object> params) throws Exception{
+        return sysDictTypeDao.findPage(params);
+    }
+
     /**
      * 添加新纪录
      * @param params
@@ -89,16 +135,6 @@ public class SysDictService {
         return sysDictDao.selectByKey(key);
     }
 
-    /**
-     * 分页查询
-     * @param params
-     * @return
-     * @throws Exception
-     */
-    public List<SysDict> findPage(Map<String, Object> params) throws Exception{
-        return sysDictDao.findPage(params);
-    }
-
     /**
      * 查询
      * @param params

+ 11 - 1
sckw-modules/sckw-system/src/main/resources/mapper/SysDictDao.xml

@@ -3,6 +3,7 @@
 <mapper namespace="com.sckw.system.dao.SysDictDao">
   <resultMap id="BaseResultMap" type="com.sckw.system.model.SysDict">
     <id column="id" jdbcType="BIGINT" property="id" />
+    <id column="dict_id" jdbcType="BIGINT" property="dictId" />
     <result column="value" jdbcType="VARCHAR" property="value" />
     <result column="label" jdbcType="VARCHAR" property="label" />
     <result column="type" jdbcType="VARCHAR" property="type" />
@@ -19,7 +20,7 @@
   </resultMap>
 
   <sql id="Base_Column_List">
-    id, value, label, type, description, sort, parent_id, remark, status, create_by, 
+    id, dict_id, value, label, type, description, sort, parent_id, remark, status, create_by,
     create_time, update_by, update_time, del_flag
   </sql>
 
@@ -29,6 +30,9 @@
       <if test="id != null">
         id,
       </if>
+      <if test="dictId != null">
+        dict_id,
+      </if>
       <if test="value != null">
         value,
       </if>
@@ -73,6 +77,9 @@
       <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
+      <if test="dictId != null">
+        #{dictId,jdbcType=BIGINT},
+      </if>
       <if test="value != null">
         #{value,jdbcType=VARCHAR},
       </if>
@@ -118,6 +125,9 @@
   <update id="update" parameterType="com.sckw.system.model.SysDict">
     update sys_dict
     <set>
+      <if test="dictId != null">
+        dict_id = #{dictId,jdbcType=BIGINT},
+      </if>
       <if test="value != null">
         value = #{value,jdbcType=VARCHAR},
       </if>

+ 137 - 0
sckw-modules/sckw-system/src/main/resources/mapper/SysDictTypeDao.xml

@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.system.dao.SysDictTypeDao">
+  <resultMap id="BaseResultMap" type="com.sckw.system.model.SysDictType">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="type" jdbcType="VARCHAR" property="type" />
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="create_by" jdbcType="BIGINT" property="createBy" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
+  </resultMap>
+
+  <sql id="Base_Column_List">
+    id, name, type, remark, status, create_by,
+    create_time, update_by, update_time, del_flag
+  </sql>
+
+  <insert id="insert" parameterType="com.sckw.system.model.SysDictType">
+    insert into sys_dict_type
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null">
+        name,
+      </if>
+      <if test="type != null">
+        type,
+      </if>
+      <if test="remark != null">
+        remark,
+      </if>
+      <if test="status != null">
+        status,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+      <if test="delFlag != null">
+        del_flag,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="type != null">
+        #{type,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createBy != null">
+        #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        #{delFlag,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="update" parameterType="com.sckw.system.model.SysDictType">
+    update sys_dict_type
+    <set>
+      <if test="name != null">
+        name = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="type != null">
+        type = #{type,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        status = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        del_flag = #{delFlag,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+
+  <select id="findPage" resultMap="BaseResultMap" parameterType="java.util.Map" >
+    select
+    <include refid="Base_Column_List" />
+    from sys_dict_type
+    where del_flag = 0
+    <if test="type != null and type != ''">
+      and type = #{type, jdbcType=VARCHAR}
+    </if>
+    <if test="name != null and name != ''">
+      and name = #{name, jdbcType=VARCHAR}
+    </if>
+    ORDER BY type, create_time desc
+  </select>
+</mapper>