Browse Source

用户范围权限保存

changhaoning 2 năm trước cách đây
mục cha
commit
effe13314e

+ 11 - 0
src/main/java/com/dk/mdm/controller/mst/StaffPurviewController.java

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mst.StaffPurviewService;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -69,4 +70,14 @@ public class StaffPurviewController{
         return staffService.saveStaffPurview(staffVO);
     }
 
+    /**
+     * @desc   : 保存范围权限
+     * @author : 常皓宁
+     * @date   : 2024/4/3 14:45
+     */
+    @PostMapping("save_purview/{staffId}")
+    public ResponseResultVO savePurview(@RequestBody List<StaffPurview> staffPurviewList, @PathVariable String staffId) {
+        return staffPurviewService.savePurview(staffPurviewList, staffId);
+    }
+
 }

+ 7 - 0
src/main/java/com/dk/mdm/mapper/mst/StaffPurviewMapper.java

@@ -33,5 +33,12 @@ public interface StaffPurviewMapper extends BaseMapper<StaffPurview>{
      * @date : 2024/2/26 10:36
      */
     int insertOrUpdateCondition(@Param("list") List<StaffPurview> list);
+
+    /**
+     * @desc   : 通过用户删除
+     * @author : 常皓宁
+     * @date   : 2024/4/3 14:45
+     */
+    int deleteByStaff(@Param("staffId") String staffId);
 }
 

+ 6 - 1
src/main/java/com/dk/mdm/mapper/mst/StaffPurviewMapper.xml

@@ -163,7 +163,7 @@
 
     <!-- 批量插入   -->
     <insert id="insertOrUpdateCondition">
-        insert into t_mst_staff_purview
+        insert into dkic_b.t_mst_staff_purview
         (
         <trim suffixOverrides=",">
             staff_id,
@@ -190,4 +190,9 @@
         data_ids = excluded."data_ids";
     </insert>
 
+    <!--    通过用户删除-->
+    <delete id="deleteByStaff">
+        delete from  dkic_b.t_mst_staff_purview
+        where Staff_id = #{staffId}::uuid
+    </delete>
 </mapper>

+ 16 - 0
src/main/java/com/dk/mdm/service/mst/StaffPurviewService.java

@@ -64,4 +64,20 @@ public class StaffPurviewService extends BaseService<StaffPurview> {
 		return  ResponseResultUtil.success(staffPurviewMapper.deleteById(new StaffRight().setStaffId(id)) > 0) ;
 	}
 
+	/**
+	 * @desc   : 保存范围权限
+	 * @author : 常皓宁
+	 * @date   : 2024/4/3 14:45
+	 */
+	@Transactional(rollbackFor = {Exception.class})
+	public ResponseResultVO savePurview(List<StaffPurview> staffPurviewList, String staffId) {
+//		通过用户删除
+		staffPurviewMapper.deleteByStaff(staffId);
+		if (staffPurviewList.size() > 0) {
+			//		保存
+			staffPurviewMapper.insertOrUpdateCondition(staffPurviewList);
+		}
+		return ResponseResultUtil.success();
+	}
+
 }