From ea9a04fe8ae638765e174a382c5df419aa63d42e Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 23 四月 2024 14:22:27 +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/BaUser.java | 15 +
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java | 13 +
pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml | 5
pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml | 6
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/QueryVo.java | 14 +
pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml | 18 ++
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java | 119 +++++++++++++
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebFilterConfiguration.java | 45 +++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java | 1
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java | 31 ++-
pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml | 50 +++++
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java | 2
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java | 1
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleSv.java | 103 +++++++++++
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java | 2
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebListenerConfiguration.java | 62 ++++++
16 files changed, 465 insertions(+), 22 deletions(-)
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 3015a93..0af28a4 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
@@ -16,6 +16,7 @@
* @return List<BaPrivilege>
*/
List<BaPrivilege> selectAll() ;
+ List<BaPrivilege> selectByIds(List<String> ids) ;
/**
* 鏌ヨ鏌愪釜鐢ㄦ埛鎵�闅跺睘鎵�鏈夎鑹茬殑鎵�鏈夋潈闄�
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
index a5187f0..37e8842 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
@@ -1,10 +1,12 @@
package com.dy.pmsGlobal.daoBa;
import com.dy.pmsGlobal.pojoBa.BaRole;
+import com.dy.pmsGlobal.pojoBa.BaUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Map;
@Mapper
public interface BaRoleMapper {
@@ -29,4 +31,15 @@
int deleteByPrimaryKey(Long id);
+
+ /**
+ * 閫昏緫鍒犻櫎
+ * @param id primaryKey
+ * @return update count
+ */
+ int deleteLogicById(Long id);
+
+ Long selectSomeCount(Map<String, Object> params);
+
+ List<BaRole> selectSome(Map<String, Object> params);
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
index 05d1623..b77dd74 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
@@ -7,6 +7,7 @@
@Mapper
public interface BaRolePrivilegeMapper {
int deleteByPrimaryKey(@Param("roleId") Long roleId, @Param("privilegeId") Long privilegeId);
+ int deleteByRoleId(@Param("roleId") Long roleId);
int insert(BaRolePrivilege record);
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
index dc282fd..eb0a905 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
@@ -6,20 +6,16 @@
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import com.dy.common.po.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import lombok.*;
import org.hibernate.validator.constraints.Length;
-/**
- * 鐢ㄦ埛
- */
-//2024-04-12涓嬮潰TableName涓嶇敤閰嶇疆琛ㄥ悕绉帮紙value="BaUser"鎴栤�渂a_user鈥濓級
-//鍙閫氳繃椹煎嘲鍛藉悕娉曞垯绫诲悕涓庤〃鍚嶅搴旇捣鏉ュ氨鍙互浜嗭紝濡傛灉涓嶈兘瀵瑰簲璧锋潵锛岄渶瑕佹寚瀹氳〃鍚嶇О
-//渚嬪@TableName(value="TestUser" autoResultMap = true)
+import java.util.Date;
+import java.util.List;
+
@TableName(value="ba_role", autoResultMap = true)
@Data
@Builder
@@ -47,8 +43,8 @@
/**
* 瑙掕壊鍚嶇О
*/
- @NotEmpty(message = "濮撳悕涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
- @Length(message = "濮撳悕涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 2, max = 50)
+ @NotEmpty(message = "瑙掕壊鍚嶇О涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
+ @Length(message = "瑙掕壊鍚嶇О涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 2, max = 50)
public String name;
/**
@@ -61,4 +57,17 @@
*/
public Boolean deleted;
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ @TableField(value = "create_dt", fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ public Date createDt;
+
+ /**
+ * 鍓嶇web鐣岄潰鎻愪氦鐨勮鑹叉墍灞炴潈闄愮殑id锛屽叾鏄竴涓瓧绗︿覆鏁扮粍
+ */
+ @TableField(exist = false)
+ public List<Integer> priIds ;
+
}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaUser.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaUser.java
index 4fefbde..e843aa4 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaUser.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaUser.java
@@ -2,15 +2,14 @@
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import com.dy.common.po.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import lombok.*;
import org.hibernate.validator.constraints.Length;
+import java.util.Date;
import java.util.List;
/**
@@ -62,6 +61,7 @@
*/
@NotEmpty(message = "瀵嗙爜涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
@Length(message = "瀵嗙爜蹇呴』{max}浣嶆暟鎹�", min = 6, max = 6)
+ @JSONField(serialize = false)
public String password;
/**
@@ -80,6 +80,13 @@
*/
public Boolean deleted;
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ @TableField(value = "create_dt", fill = FieldFill.INSERT)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ public Date createDt;
+
//////////////////////////////////////
// 浠ヤ笅涓嶆槸鏁版嵁搴撳疄浣撳睘鎬�
//////////////////////////////////////
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 a452108..37fa18a 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
@@ -54,6 +54,15 @@
</if>
</select>
+<!-- <select id="selectByRole" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege">-->
+<!-- select p.id,p.num,p.name,p.type-->
+<!-- from ba_privilege p-->
+<!-- inner join ba_role_privilege rp on p.id = rp.privilege_id-->
+<!-- <if test="roleId != null">-->
+<!-- where rp.role_id = #{roleId, jdbcType=BIGINT}-->
+<!-- </if>-->
+<!-- </select>-->
+
<insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege">
@@ -123,4 +132,13 @@
delete from ba_privilege
where id = #{id}
</delete>
+
+ <select id="selectByIds" parameterType="arraylist" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from ba_privilege where id in
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
index eacb14e..b722404 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
@@ -8,23 +8,28 @@
<result column="name" property="name" />
<result column="disabled" property="disabled" />
<result column="deleted" property="deleted" />
+ <result column="create_dt" property="createDt" />
</resultMap>
<resultMap id="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaRole">
<result column="id" property="id" />
<result column="name" property="name" />
</resultMap>
+ <resultMap id="someResultMap" extends="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaRole">
+ <collection property="priIds" ofType="java.lang.Integer" fetchType="eager" column="{roleId=id}" select="com.dy.pmsGlobal.daoBa.BaPrivilegeMapper.selectPrivilegeByRoleId" />
+ </resultMap>
+
<sql id="Base_Column_List">
<!--@mbg.generated-->
- id, `name`, disabled, deleted
+ id, `name`, disabled, deleted,create_dt
</sql>
<sql id="Part_Column_List">
<!--@mbg.generated-->
- id, `name`, disabled
+ id, `name`, disabled,create_dt
</sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+ <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="someResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
@@ -111,4 +116,43 @@
deleted = #{deleted}
where id = #{id}
</update>
+
+ <delete id="deleteLogicById" parameterType="java.lang.Long">
+ update ba_role set deleted = 1
+ where id = #{id}
+ </delete>
+
+ <select id="selectSomeCount" resultType="java.lang.Long">
+ select
+ count(*)
+ from ba_role r
+ inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id
+ where r.disabled!=1 and r.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null and name != ''">
+ r.name like concat('%', #{name}, '%') and
+ </if>
+ </trim>
+ </select>
+
+ <select id="selectSome" resultMap="someResultMap">
+ select
+ <include refid="Part_Column_List" >
+ <property name="alias" value="r"/>
+ </include>
+ from ba_role r
+ inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id
+ where r.disabled!=1 and r.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null and name != ''">
+ r.name like concat('%', #{name}, '%') and
+ </if>
+ </trim>
+ order by id DESC
+ <trim prefix="limit " >
+ <if test="start != null and count != null">
+ #{start}, #{count}
+ </if>
+ </trim>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
index 938e840..daad892 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
@@ -17,6 +17,12 @@
where role_id = #{roleId}
and privilege_id = #{privilegeId}
</delete>
+
+ <delete id="deleteByRoleId" parameterType="map">
+ <!--@mbg.generated-->
+ delete from ba_role_privilege
+ where role_id = #{roleId}
+ </delete>
<insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaRolePrivilege">
<!--@mbg.generated-->
insert into ba_role_privilege (role_id, privilege_id)
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
index b4adcd1..59beadf 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
@@ -11,6 +11,7 @@
<result column="supper_admin" property="supperAdmin" />
<result column="disabled" property="disabled" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
<result column="deleted" property="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
+ <result column="create_dt" property="createDt" />
</resultMap>
<resultMap id="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaUser">
<!--@mbg.generated-->
@@ -36,10 +37,10 @@
<sql id="Base_Column_List">
<!--@mbg.generated-->
- id, `name`, phone, `password`, supper_admin, disabled, deleted
+ id, `name`, phone, `password`, supper_admin, disabled, deleted,create_dt
</sql>
<sql id="part_Column_List">
- ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled
+ ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.password, ${alias}.disabled,${alias}.create_dt
</sql>
<sql id="Login_Column_List">
id, name, phone, supper_admin
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebFilterConfiguration.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebFilterConfiguration.java
new file mode 100644
index 0000000..43ab770
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebFilterConfiguration.java
@@ -0,0 +1,45 @@
+package com.dy.pmsBase.config;
+
+//import com.dy.common.webFilter.DevOfDataSourceNameSetFilter;
+import com.dy.common.webFilter.UserTokenFilter;
+import jakarta.servlet.Filter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class WebFilterConfiguration {
+
+ @Value("${pms.global.dev}")
+ public String isDevStage ;//鏄惁涓哄紑鍙戦樁娈�
+// @Value("${pipIrr.global.dsName}")
+// public String dsName ;//寮�鍙戦樁娈电殑鏁版嵁婧愬悕绉�
+
+ /**
+ * DevOfDataSourceNameSetFilter涓嶶serTokenFilter鍙兘涓�涓閰嶇疆涓婏紝
+ * 鎵�浠ヤ粬浠殑order閮芥槸1
+ */
+ private static final int order_UserTokenFilter = 1 ;//涓庝笅闈�
+ private static final int order_DevOfDataSourceNameSetFilter = 1 ;
+
+
+ @Bean
+ public FilterRegistrationBean<? extends Filter> RegFilter() {
+ FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
+ if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){
+// filterRegistrationBean.setFilter(new DevOfDataSourceNameSetFilter());
+// filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯
+// filterRegistrationBean.addInitParameter("dataSourceName",dsName);//璁剧疆init鍙傛暟
+// filterRegistrationBean.setName("DevOfDataSourceNameSetFilter");//璁剧疆杩囨护鍣ㄥ悕绉�
+// filterRegistrationBean.setOrder(order_DevOfDataSourceNameSetFilter);//鎵ц娆″簭
+ }else{
+ filterRegistrationBean.setFilter(new UserTokenFilter());
+ filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯
+ filterRegistrationBean.setName("UserTokenFilter");//璁剧疆杩囨护鍣ㄥ悕绉�
+ filterRegistrationBean.setOrder(order_UserTokenFilter);//鎵ц娆″簭
+ }
+ return filterRegistrationBean;
+ }
+
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebListenerConfiguration.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebListenerConfiguration.java
new file mode 100644
index 0000000..eb55338
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/config/WebListenerConfiguration.java
@@ -0,0 +1,62 @@
+package com.dy.pmsBase.config;
+
+import com.dy.common.webListener.GenerateIdSetSuffixListener;
+import jakarta.servlet.ServletContextListener;
+import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class WebListenerConfiguration {
+
+ /**
+ * 鍚姩椤哄簭
+ */
+ //private static final int order_config = 0 ;
+ private static final int order_idSetSuffix = 1 ;
+ //private static final int order_init = 2 ;
+
+ /*
+ * 瑙f瀽鍚勭***.config閰嶇疆鐨凜onfigListener锛屾殏鏃朵笉閲囩敤姝ょ閰嶇疆鏂瑰紡
+ *
+ @Bean
+ public ConfigListener getGlConfigListener(){
+ return new ConfigListener() ;
+ }
+ /**
+ * 澶栭儴鎻愪緵Listener
+ * @param listener 澶栭儴鎻愪緵Listener
+ * @return 娉ㄥ唽Bean
+ @Bean
+ public ServletListenerRegistrationBean<? extends ServletContextListener> regConfigListener(ConfigListener listener) {
+ ServletListenerRegistrationBean<ConfigListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
+ listenerRegistrationBean.setListener(listener);
+ listenerRegistrationBean.setOrder(order_config);
+ return listenerRegistrationBean;
+ }
+ */
+
+ /**
+ * 鍐呴儴鎻愪緵listener锛岃listener鍦ㄧ郴缁熷惎鍔ㄦ椂锛屾牴鎹厤缃� 璁剧疆ID浜х敓鍣ㄧ殑鍚庣紑
+ * @return 娉ㄥ唽Bean
+ */
+ @Bean
+ public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() {
+ ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
+ listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener());
+ listenerRegistrationBean.setOrder(order_idSetSuffix);
+ return listenerRegistrationBean;
+ }
+
+// /**
+// * 鍐呴儴鎻愪緵listener锛岃listener鍦ㄧ郴缁熷惎鍔ㄦ椂锛屽垵濮嬪寲鏁版嵁搴撴暟鎹�
+// * @return 娉ㄥ唽Bean
+// */
+// @Bean
+// public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() {
+// ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>();
+// listenerRegistrationBean.setListener(new InitListener());
+// listenerRegistrationBean.setOrder(order_init);
+// return listenerRegistrationBean;
+// }
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/QueryVo.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/QueryVo.java
new file mode 100644
index 0000000..53d38a0
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/QueryVo.java
@@ -0,0 +1,14 @@
+package com.dy.pmsBase.role;
+
+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;
+}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
new file mode 100644
index 0000000..01091c5
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
@@ -0,0 +1,119 @@
+package com.dy.pmsBase.role;
+
+import com.alibaba.fastjson2.JSON;
+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.pojoBa.BaRole;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 瑙掕壊绠$悊
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="role")
+@SuppressWarnings("unchecked")
+public class RoleCtrl {
+ private RoleSv roleSv;
+ @Autowired
+ public RoleCtrl(RoleSv roleSv){
+ this.roleSv = roleSv;
+ }
+
+ /**
+ * 淇濆瓨瑙掕壊淇℃伅
+ * @param role
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="save")
+ @SsoPowerAop(power = "10100011")
+ public BaseResponse<BaRole> save(@RequestBody @Valid BaRole role,BindingResult bindingResult){
+ try {
+ role.setDeleted(false);
+ role.setDisabled(false);
+ return BaseResponseUtils.buildSuccess(roleSv.save(role));
+ }catch (Exception e){
+ log.error("淇濆瓨瑙掕壊寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 鏇存柊瑙掕壊淇℃伅
+ * @param role
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="update")
+ @SsoPowerAop(power = "10100011")
+ public BaseResponse<BaRole> update(@RequestBody @Valid BaRole role,BindingResult bindingResult){
+ try {
+ return BaseResponseUtils.buildSuccess(roleSv.update(role));
+ }catch (Exception e){
+ log.error("鏇存柊瑙掕壊寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒犻櫎瑙掕壊淇℃伅
+ * @param id
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path="delete")
+ @SsoPowerAop(power = "10100011")
+ public BaseResponse<BaRole> delete(String id,BindingResult bindingResult){
+ try {
+ return BaseResponseUtils.buildSuccess(roleSv.delete(Long.parseLong(id)));
+ }catch (Exception e){
+ log.error("鍒犻櫎瑙掕壊寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 鏍规嵁ID鏌ヨ瑙掕壊淇℃伅
+ * @return
+ */
+ @GetMapping(path="one")
+ @SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
+ public BaseResponse<BaRole> one(String id){
+ try{
+ BaRole role=roleSv.selectById(id);
+ return BaseResponseUtils.buildSuccess(JSON.toJSON(role));
+ }catch (Exception e){
+ log.error("鏌ヨ瑙掕壊寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ瑙掕壊淇℃伅
+ * @param vo
+ * @return
+ */
+ @PostMapping(path="some")
+ @SsoPowerAop(power = "10100010")
+ public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody QueryVo vo){
+ try {
+ return BaseResponseUtils.buildSuccess(roleSv.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/role/RoleSv.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleSv.java
new file mode 100644
index 0000000..e3a95c6
--- /dev/null
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleSv.java
@@ -0,0 +1,103 @@
+package com.dy.pmsBase.role;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsBase.role.QueryVo;
+import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper;
+import com.dy.pmsGlobal.daoBa.BaRoleMapper;
+import com.dy.pmsGlobal.daoBa.BaRolePrivilegeMapper;
+import com.dy.pmsGlobal.pojoBa.BaRole;
+import com.dy.pmsGlobal.pojoBa.BaRolePrivilege;
+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 org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class RoleSv {
+
+ private BaRoleMapper dao;
+ private BaRolePrivilegeMapper rpDao;
+ private BaPrivilegeMapper priDao;
+
+ @Autowired
+ public RoleSv(BaRoleMapper dao, BaRolePrivilegeMapper rpDao,BaPrivilegeMapper priDao) {
+ this.dao = dao;
+ this.rpDao = rpDao;
+ this.priDao = priDao;
+ }
+
+ @Transactional
+ public int save(BaRole role) {
+ int count = dao.insert(role);
+ // 娣诲姞瑙掕壊鏉冮檺
+ updateRolePrivileges(role.id,role.priIds);
+ return count;
+ }
+
+ /**
+ * 閫昏緫鍒犻櫎瀹炰綋
+ * @param id 瀹炰綋ID
+ * @return 褰卞搷璁板綍鏁伴噺
+ */
+ @Transactional
+ public int delete(Long id) {
+ return this.dao.deleteLogicById(id);
+ }
+
+ @Transactional
+ public int update(BaRole role) {
+ int count = dao.updateByPrimaryKeySelective(role);
+ // 鏇存柊瑙掕壊鏉冮檺
+ updateRolePrivileges(role.id,role.priIds);
+ return count;
+ }
+
+ /**
+ * 娣诲姞鎴栨洿鏂拌鑹叉潈闄�
+ * @param roleId 瑙掕壊ID
+ * @param priIds 鏉冮檺id
+ * @return
+ */
+ private void updateRolePrivileges(Long roleId,List<Integer> priIds) {
+ if(CollectionUtils.isEmpty(priIds)){
+ throw new RuntimeException("鏉冮檺id涓嶈兘涓虹┖");
+ }
+ // 鍒犻櫎瑙掕壊鏉冮檺
+ rpDao.deleteByRoleId(roleId);
+ priIds.stream().forEach(rp -> {
+ if(priDao.selectByPrimaryKey(rp.longValue()) != null){
+ rpDao.insert(new BaRolePrivilege(roleId, rp.longValue()));
+ }
+ });
+ }
+
+ public BaRole selectById(String roleId) {
+ return dao.selectByPrimaryKey(Long.valueOf(roleId));
+ }
+
+ /**
+ * 鑾峰彇瑙掕壊鍒楄〃
+ */
+ public QueryResultVo<List<BaRole>> selectSome(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+ Long itemTotal = this.dao.selectSomeCount(params);
+
+ QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+ //璁$畻鍒嗛〉绛変俊鎭�
+ rsVo.calculateAndSet(itemTotal, params);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+ rsVo.obj = this.dao.selectSome(params) ;
+ return rsVo ;
+ }
+
+}
+
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 29e4c59..01bd5b6 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
@@ -241,7 +241,7 @@
if (count <= 0) {
return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
} else {
- return BaseResponseUtils.buildSuccess("淇敼瀵嗙爜鎴愬姛");
+ return BaseResponseUtils.buildSuccess("閲嶇疆瀵嗙爜鎴愬姛");
}
}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
index ac488f7..753a880 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserSv.java
@@ -117,7 +117,7 @@
* @return 鎻掑叆鐢ㄦ埛涓庤鑹插叧鑱旇褰曟暟閲�
*/
@Transactional
- private int saveUserRoles(Long userId, String[] roleIds) {
+ public int saveUserRoles(Long userId, String[] roleIds) {
this.urDao.deleteByUserId(userId);
int count = 0;
if (roleIds != null && roleIds.length > 0) {
--
Gitblit v1.8.0