From f717a59e727726535235642937f62e8851cc4a67 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 26 四月 2024 16:30:43 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pms-SV

---
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java            |    4 
 pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java         |   46 +++++++++
 pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java |   66 +++++++++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java |    8 +
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java      |    7 +
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java           |    3 
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java          |    3 
 pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java       |   17 +++
 pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java           |   26 +++++
 pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml             |   65 ++++++++++++
 pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml                   |   19 +++
 11 files changed, 254 insertions(+), 10 deletions(-)

diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
index 1086ddc..71605a8 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
@@ -50,7 +50,6 @@
             // 鑾峰彇鐢ㄦ埛淇℃伅
             BaUser user = (BaUser)getCurUser(result);
             if(user!=null && user.id !=null && !StringUtils.isNullOrEmpty(user.name)){
-                Long operator = user.id;
                 // 鑾峰彇鏂规硶鐨勪腑鏂囨弿杩�
                 MethodSignature sign = (MethodSignature) joinPoint.getSignature();
                 Log logDesc = sign.getMethod().getAnnotation(Log.class);
@@ -58,7 +57,7 @@
                 // 鑾峰彇IP鍦板潃
                 String ip = getRemoteHost();
                 // 璁板綍鏃ュ織
-                logSv.save(operator, operationName,ip,result.getCode(),result.getMsg());
+                logSv.save(user.id,user.name, operationName,ip,result.getCode(),result.getMsg());
             }
         }catch (Exception e){
             log.error("璁板綍鏃ュ織寮傚父:"+e.getMessage());
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java
index 5ca8a39..3465a1d 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogService.java
@@ -13,9 +13,10 @@
     @Autowired
     private BaLogMapper dao;
 
-    public void save(long operator, String operation,String ip,String code,String msg) {
+    public void save(long operator,String operatorName, String operation,String ip,String code,String msg) {
         BaLog log = new BaLog();
         log.userId=operator;
+        log.userName=operatorName;
         log.content = operation;
         log.dt = new Date();
         log.ip = ip;
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
index 0af28a4..de69388 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
@@ -1,10 +1,13 @@
 package com.dy.pmsGlobal.daoBa;
 
+import com.dy.pmsGlobal.pojoBa.BaLog;
 import com.dy.pmsGlobal.pojoBa.BaPrivilege;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface BaPrivilegeMapper {
@@ -16,6 +19,11 @@
      * @return List<BaPrivilege>
      */
     List<BaPrivilege> selectAll() ;
+
+    List<BaPrivilege> selectSome(Map<String, Object> params);
+
+    Long selectSomeCount(Map<String, Object> params);
+
     List<BaPrivilege> selectByIds(List<String> ids) ;
 
     /**
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java
index 4ab5877..ada9610 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaLog.java
@@ -25,6 +25,10 @@
     * 鐢ㄦ埛ID
     */
     public Long userId;
+    /**
+     * 鐢ㄦ埛濮撳悕
+     */
+    public String userName;
 
     /**
     * 鏃ュ織鍐呭
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java
index 2df3dde..0fda674 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaPrivilege.java
@@ -58,4 +58,11 @@
     @Length(message = "鏉冮檺绫诲瀷涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 4, max = 4)
     public Integer type;
 
+    /**
+     * 绫诲埆鍚嶇О
+     */
+    @NotEmpty(message = "绫诲埆鍚嶇О涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
+    @Length(message = "鏉冮檺绫诲瀷涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 3, max = 6)
+    public String typeName;
+
 }
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml
index 7a2bcf7..5c0e8fb 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaLogMapper.xml
@@ -6,6 +6,7 @@
     <!--@Table ba_log-->
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="user_name" jdbcType="VARCHAR" property="userName" />
     <result column="content" jdbcType="VARCHAR" property="content" />
     <result column="ip" jdbcType="VARCHAR" property="ip" />
     <result column="code" jdbcType="VARCHAR" property="code" />
@@ -14,7 +15,7 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, user_id, content, dt,ip,code,msg
+    id, user_id,user_name, content, dt,ip,code,msg
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
@@ -25,9 +26,9 @@
   </select>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoBa.BaLog" useGeneratedKeys="true">
     <!--@mbg.generated-->
-    insert into ba_log (user_id, content, ip,code,msg
+    insert into ba_log (user_id,user_name, content, ip,code,msg
       )
-    values (#{userId,jdbcType=BIGINT}, #{content,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
+    values (#{userId,jdbcType=BIGINT},#{userName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
     #{code,jdbcType=VARCHAR},#{msg,jdbcType=VARCHAR}
       )
   </insert>
@@ -37,6 +38,9 @@
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="userId != null">
         user_id,
+      </if>
+      <if test="userName != null">
+        user_name,
       </if>
       <if test="content != null">
         content,
@@ -54,6 +58,9 @@
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="userId != null">
         #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="userName != null">
+        #{userName,jdbcType=VARCHAR},
       </if>
       <if test="content != null">
         #{content,jdbcType=VARCHAR},
@@ -80,6 +87,9 @@
       <if test="userId != null and userId != ''">
         user_id = #{userId,jdbcType=BIGINT} and
       </if>
+      <if test="userName != null and userName != ''">
+        user_name = #{userName,jdbcType=VARCHAR} and
+      </if>
       <if test="content != null  and content != '' ">
         content like concat('%', #{content}, '%') and
       </if>
@@ -105,6 +115,9 @@
       <if test="userId != null and userId != ''">
         user_id = #{userId,jdbcType=BIGINT} and
       </if>
+      <if test="userName != null and userName != ''">
+        user_name = #{userName,jdbcType=VARCHAR} and
+      </if>
       <if test="content != null  and content != '' ">
         content like concat('%', #{content}, '%') and
       </if>
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
index 37fa18a..7fd878d 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
@@ -8,10 +8,11 @@
     <result column="num" property="num" />
     <result column="name" property="name" />
     <result column="type" property="type" />
+    <result column="type_name" property="typeName" />
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, num, `name`, `type`
+    id, num, `name`, `type`,type_name
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
@@ -67,8 +68,8 @@
 
   <insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege">
     <!--@mbg.generated-->
-    insert into ba_privilege (id, num, `name`, `type`)
-    values (#{id}, #{num}, #{name}, #{type})
+    insert into ba_privilege (id, num, `name`, `type`,type_name)
+    values (#{id}, #{num}, #{name}, #{type}, #{typeName})
   </insert>
   <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege">
     <!--@mbg.generated-->
@@ -86,6 +87,9 @@
       <if test="type != null">
         `type`,
       </if>
+      <if test="typeName != null">
+        type_name,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -99,6 +103,9 @@
       </if>
       <if test="type != null">
         #{type},
+      </if>
+      <if test="typeName != null">
+        #{typeName},
       </if>
     </trim>
   </insert>
@@ -115,6 +122,9 @@
       <if test="type != null">
         `type` = #{type},
       </if>
+      <if test="typeName != null">
+        type_name = #{typeName},
+      </if>
     </set>
     where id = #{id}
   </update>
@@ -123,7 +133,8 @@
     update ba_privilege
     set num = #{num},
       `name` = #{name},
-      `type` = #{type}
+      `type` = #{type},
+       type_name = #{typeName}
     where id = #{id}
   </update>
 
@@ -141,4 +152,50 @@
       #{id}
     </foreach>
   </select>
+
+  <select id="selectSome" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege">
+    select
+      <include refid="Base_Column_List" />
+    from ba_privilege
+    <trim prefix="where " suffixOverrides="and">
+      <if test="num != null and num != ''">
+        num = #{num,jdbcType=INTEGER} and
+      </if>
+      <if test="name != null and name != ''">
+        name like concat('%', #{name}, '%') and
+      </if>
+      <if test="typeName != null  and typeName != '' ">
+        type_name like concat('%', #{typeName}, '%') and
+      </if>
+      <if test="type != null and type != ''">
+        type = #{type,jdbcType=INTEGER} and
+      </if>
+    </trim>
+    order by id desc
+    <trim prefix="limit " >
+      <if test="start != null and count != null">
+        #{start}, #{count}
+      </if>
+    </trim>
+  </select>
+
+  <select id="selectSomeCount" resultType="java.lang.Long">
+    select
+    count(1)
+    from ba_privilege
+    <trim prefix="where " suffixOverrides="and">
+      <if test="num != null and num != ''">
+        num = #{num,jdbcType=INTEGER} and
+      </if>
+      <if test="name != null and name != ''">
+        name like concat('%', #{name}, '%') and
+      </if>
+      <if test="typeName != null  and typeName != '' ">
+        type_name like concat('%', #{typeName}, '%') and
+      </if>
+      <if test="type != null and type != ''">
+        type = #{type,jdbcType=INTEGER} and
+      </if>
+    </trim>
+  </select>
 </mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java
new file mode 100644
index 0000000..8339844
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PriSv.java
@@ -0,0 +1,46 @@
+package com.dy.pmsBase.privilege;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper;
+import com.dy.pmsGlobal.pojoBa.BaPrivilege;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class PriSv {
+
+    private BaPrivilegeMapper dao;
+    @Autowired
+    public void setDao(BaPrivilegeMapper dao) {
+        this.dao = dao;
+    }
+
+    /**
+     * 鑾峰彇瑙掕壊鍒楄〃
+     */
+    public QueryResultVo<List<BaPrivilege>> selectSome(QueryVo queryVo) {
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+        Long itemTotal = dao.selectSomeCount(params);
+        QueryResultVo<List<BaPrivilege>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+        //璁$畻鍒嗛〉绛変俊鎭�
+        rsVo.calculateAndSet(itemTotal, params);
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+        rsVo.obj = dao.selectSome(params) ;
+        return rsVo ;
+    }
+
+    public Map<String, List<BaPrivilege>> selectByType(){
+        List<BaPrivilege> priList = dao.selectAll();
+        Map<String, List<BaPrivilege>> map = priList.stream()
+                .collect(Collectors.groupingBy(BaPrivilege::getTypeName));
+        return map;
+    }
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java
new file mode 100644
index 0000000..307dec3
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/PrivilegeCtrl.java
@@ -0,0 +1,66 @@
+package com.dy.pmsBase.privilege;
+
+import com.dy.common.aop.SsoPowerAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.aop.Log;
+import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper;
+import com.dy.pmsGlobal.pojoBa.BaPrivilege;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 鏉冮檺绠$悊
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="pri")
+@SuppressWarnings("unchecked")
+public class PrivilegeCtrl {
+    private PriSv sv;
+    @Autowired
+    public PrivilegeCtrl(PriSv sv){
+        this.sv = sv;
+    }
+
+    /**
+     * 鍒嗙被鍨嬫煡璇㈡潈闄�
+     * @return
+     */
+    @GetMapping(path="getByType")
+    @SsoPowerAop(power = "10100010")
+    public BaseResponse<Map<String, List<BaPrivilege>>> getByType(){
+       try {
+           return BaseResponseUtils.buildSuccess(sv.selectByType());
+       }catch (Exception e){
+            log.error("鍒嗙被鍨嬭幏鍙栨潈闄�",e);
+            return BaseResponseUtils.buildException(e.getMessage());
+       }
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ鏉冮檺
+     * @param vo
+     * @return
+     */
+    @RequestMapping(path="some")
+    @SsoPowerAop(power = "10100010")
+    @Log("鏌ヨ鏉冮檺淇℃伅")
+    public BaseResponse<QueryResultVo<List<BaPrivilege>>> some(@RequestBody QueryVo vo){
+        try {
+            return BaseResponseUtils.buildSuccess(sv.selectSome(vo));
+        }catch (Exception e){
+            log.error("鍒嗛〉鑾峰彇鏉冮檺",e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java
new file mode 100644
index 0000000..e3a44d0
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/privilege/QueryVo.java
@@ -0,0 +1,17 @@
+package com.dy.pmsBase.privilege;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.*;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class QueryVo extends QueryConditionVo {
+    public String name;
+    public Integer num;
+    public Integer type;
+    public String typeName;
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
index 88000f3..ce93d75 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
@@ -166,6 +166,32 @@
     }
 
     /**
+     * 鍒犻櫎鐢ㄦ埛淇℃伅
+     * @param id
+     * @return
+     */
+    @GetMapping(path = "delete")
+    @SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+    @Log("鍒犻櫎鐢ㄦ埛")
+    public BaseResponse<Boolean> delete(Long id) {
+        int count;
+        try {
+            BaUser po = new BaUser();
+            po.id = id;
+            po.deleted = true;
+            count = this.sv.update(po);
+        } catch (Exception e) {
+            log.error("鍒犻櫎鐢ㄦ埛寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+        if (count <= 0) {
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+        } else {
+            return BaseResponseUtils.buildSuccess(true);
+        }
+    }
+
+    /**
      * 淇敼瀵嗙爜
      * @param id 鐢ㄦ埛ID
      * @return 鏄惁鎴愬姛

--
Gitblit v1.8.0