调解系统修改
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.system.domain.entity.log;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Table(name = "ms_request_log")
|
||||
public class MsRequestLog {
|
||||
@Id
|
||||
@GeneratedValue(generator = "JDBC")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 状态,0-成功,1-失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
@Column(name = "request_url")
|
||||
private String requestUrl;
|
||||
|
||||
/**
|
||||
* 请求内容
|
||||
*/
|
||||
@Column(name = "content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
@Column(name = "reason")
|
||||
private String reason;
|
||||
/**
|
||||
* 返回内容
|
||||
*/
|
||||
@Column(name = "return_content")
|
||||
private String returnContent;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
@@ -144,11 +144,11 @@ public interface SysUserMapper
|
||||
*/
|
||||
SysUser selectUserByIdCard(@Param("idCard")String identityNo);
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
* @param phone
|
||||
* 根据邮箱查询用户信息
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
SysUser selectUserByPhone(@Param("phone")String phone);
|
||||
SysUser selectUserByEmail(@Param("email")String email);
|
||||
|
||||
/**
|
||||
* 根据部门和角色查询用户
|
||||
|
||||
@@ -67,4 +67,11 @@ public interface SysUserRoleMapper
|
||||
* @param roleId
|
||||
*/
|
||||
void insertUserRole(@Param("userId")Long userId, @Param("roleId")Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户id查询关联的角色id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public List<Long> selectRoleIdsByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ruoyi.system.mapper.log;
|
||||
|
||||
import com.ruoyi.system.domain.entity.log.MsRequestLog;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
|
||||
public interface MsRequestLogMapper extends Mapper<MsRequestLog> {
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.wisdomarbitrate.domain.entity.casestatus.MsCaseStatus;
|
||||
import com.ruoyi.common.enums.AttachmentOperateTypeEnum;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo;
|
||||
import org.apache.ibatis.annotations.Case;
|
||||
import org.apache.poi.hmef.Attachment;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface BeiMingInterface {
|
||||
/**
|
||||
* 1.获取北明接口令牌token
|
||||
* 1.获取北明接口令牌token对象
|
||||
*
|
||||
* @param userName
|
||||
* @param password
|
||||
@@ -73,5 +70,13 @@ public interface BeiMingInterface {
|
||||
* @param caseNo 案件编号
|
||||
* @return
|
||||
*/
|
||||
JSONObject pushAttachmentInfo(String username, String password, File file, String abutmentId, String syncSource, String caseNo);
|
||||
MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo, AttachmentOperateTypeEnum operateTypeEnum);
|
||||
|
||||
/**
|
||||
* 删除附件
|
||||
* @param file
|
||||
* @param caseNo
|
||||
* @return
|
||||
*/
|
||||
public JSONObject deleteAttachmentInfo( String caseNo,String fileId,String fileName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.entity.log.MsRequestLog;
|
||||
|
||||
/**
|
||||
* @Classname MsRequestLogService
|
||||
* @Description TODO
|
||||
* @Version 1.0.0
|
||||
* @Date 2024/4/2 14:18
|
||||
* @Created wangqiong
|
||||
*/
|
||||
public interface MsRequestLogService {
|
||||
void insert(MsRequestLog requestLog);
|
||||
}
|
||||
+88
-14
@@ -5,7 +5,10 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.ruoyi.common.enums.AttachmentOperateTypeEnum;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.system.domain.entity.log.MsRequestLog;
|
||||
import com.ruoyi.system.service.BeiMingInterface;
|
||||
import com.ruoyi.system.service.MsRequestLogService;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseFileInfo;
|
||||
import com.ruoyi.wisdomarbitrate.domain.vo.mscase.MsCaseStatusInfo;
|
||||
import com.ruoyi.wisdomarbitrate.utils.CommonInputStreamResource;
|
||||
@@ -15,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
@@ -22,6 +26,8 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ruoyi.common.utils.EncryptUtils.sm4Decrypt;
|
||||
import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt;
|
||||
@@ -34,6 +40,10 @@ import static com.ruoyi.common.utils.EncryptUtils.sm4Encrypt;
|
||||
public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
@Autowired
|
||||
MsRequestLogService requestLogService;
|
||||
@Autowired
|
||||
BeiMingInterfaceService beiMingInterfaceService;
|
||||
/**
|
||||
* 接口地址
|
||||
*/
|
||||
@@ -46,6 +56,13 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
public String apiprefix;
|
||||
@Value("${beimingprivatekey}")
|
||||
public String privateKey;
|
||||
// 北明配置
|
||||
@Value("${BMConfig.userName}")
|
||||
private String BMUserName;
|
||||
@Value("${BMConfig.password}")
|
||||
private String BMPassword;
|
||||
@Value("${BMConfig.syncSource}")
|
||||
private String BMSyncSource;
|
||||
|
||||
/**
|
||||
* 1.获取北明接口令牌token
|
||||
@@ -54,9 +71,11 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
* @param password
|
||||
* @param times
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public String getApiToken(String userName, String password, Long times) {
|
||||
JSONObject result = new JSONObject();
|
||||
MsRequestLog requestLog = new MsRequestLog();
|
||||
try {
|
||||
//设置请求头
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
@@ -79,13 +98,25 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
System.out.println("encryptString:" + encryptString);
|
||||
fromEntity = new HttpEntity(body, httpHeaders);
|
||||
String url = apihost + apiprefix + "/getToken";
|
||||
|
||||
requestLog.setRequestUrl(url);
|
||||
requestLog.setContent(param.toString());
|
||||
requestLog.setCreateTime((new Date()));
|
||||
requestLog.setStatus(0);
|
||||
result = restTemplate.postForObject(url, fromEntity, JSONObject.class);
|
||||
requestLog.setReturnContent(result!=null?result.toString():null);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
requestLog.setReason(e.getMessage());
|
||||
requestLog.setStatus(1);
|
||||
requestLogService.insert(requestLog);
|
||||
throw new ServiceException("推送失败");
|
||||
}
|
||||
return result.toString();
|
||||
requestLogService.insert(requestLog);
|
||||
return analysisResultToken(Objects.requireNonNull(result).toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析加密后端token
|
||||
*
|
||||
@@ -97,9 +128,7 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
if (token != null && !token.isEmpty()) {
|
||||
JSONObject jsonObject = JSON.parseObject(token);
|
||||
String tokenString = jsonObject.getString("data");
|
||||
System.out.println("data信息:" + tokenString);
|
||||
String tokenstr = sm4Decrypt(tokenString, privateKey);
|
||||
System.out.println("解密后的字符串:" + tokenstr);
|
||||
if (tokenstr != null && !tokenstr.isEmpty()) {
|
||||
JSONObject tokenObject = JSON.parseObject(tokenstr);
|
||||
resultToken = tokenObject.getString("token");
|
||||
@@ -117,9 +146,11 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
* @param syncSource 同步来源(账户名)
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public JSONObject submitCaseStatusInfo(String token, String abutmentId, String syncSource, MsCaseStatusInfo msCaseStatusInfo) {
|
||||
JSONObject result = new JSONObject();
|
||||
MsRequestLog requestLog = new MsRequestLog();
|
||||
try {
|
||||
//设置请求头
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
@@ -146,10 +177,20 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
fromEntity = new HttpEntity(body, httpHeaders);
|
||||
|
||||
String url = apihost + apiprefix + "/caseMediation/status";
|
||||
requestLog.setRequestUrl(url);
|
||||
requestLog.setContent(param.toString());
|
||||
requestLog.setCreateTime((new Date()));
|
||||
requestLog.setStatus(0);
|
||||
result = restTemplate.postForObject(url, fromEntity, JSONObject.class);
|
||||
requestLog.setReturnContent(result!=null?result.toString():null);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
requestLog.setReason(e.getMessage());
|
||||
requestLog.setStatus(1);
|
||||
requestLogService.insert(requestLog);
|
||||
throw new ServiceException("推送失败");
|
||||
}
|
||||
requestLogService.insert(requestLog);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -160,11 +201,13 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public JSONObject uploadFile(File file, String token, String syncSource) {
|
||||
System.out.println("文件:" + file.getName());
|
||||
System.out.println("文件:" + file.toString());
|
||||
JSONObject result = new JSONObject();
|
||||
MsRequestLog requestLog = new MsRequestLog();
|
||||
try {
|
||||
//设置请求头
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
@@ -184,10 +227,20 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
requestBody.add("file", commonInputStreamResource);
|
||||
HttpEntity<MultiValueMap> fromEntity = new HttpEntity<MultiValueMap>(requestBody, httpHeaders);
|
||||
String url = apihost + apiprefix + "/uploadFile";
|
||||
requestLog.setRequestUrl(url);
|
||||
requestLog.setContent(fromEntity.toString());
|
||||
requestLog.setCreateTime((new Date()));
|
||||
requestLog.setStatus(0);
|
||||
result = restTemplate.postForObject(url, fromEntity, JSONObject.class);
|
||||
requestLog.setReturnContent(result!=null?result.toString():null);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
requestLog.setReason(e.getMessage());
|
||||
requestLog.setStatus(1);
|
||||
requestLogService.insert(requestLog);
|
||||
throw new ServiceException("推送失败");
|
||||
}
|
||||
requestLogService.insert(requestLog);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -201,9 +254,11 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
* @param msCaseFileInfo 案件附件信息
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public JSONObject syncAttachmentInfo(String token, String syncSource, String action, String caseNo, MsCaseFileInfo msCaseFileInfo) {
|
||||
JSONObject result = new JSONObject();
|
||||
MsRequestLog requestLog = new MsRequestLog();
|
||||
try {
|
||||
//设置请求头
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
@@ -238,21 +293,31 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
body.put("encryptString", encryptString);
|
||||
fromEntity = new HttpEntity(body, httpHeaders);
|
||||
String url = apihost + apiprefix + "/caseMediation/attachment/accept";
|
||||
requestLog.setRequestUrl(url);
|
||||
requestLog.setContent(param.toString());
|
||||
requestLog.setCreateTime((new Date()));
|
||||
requestLog.setStatus(0);
|
||||
result = restTemplate.postForObject(url, fromEntity, JSONObject.class);
|
||||
requestLog.setReturnContent(result!=null?result.toString():null);
|
||||
} catch (RestClientException e) {
|
||||
e.printStackTrace();
|
||||
requestLog.setReason(e.getMessage());
|
||||
requestLog.setStatus(1);
|
||||
requestLogService.insert(requestLog);
|
||||
throw new ServiceException("推送失败");
|
||||
}
|
||||
requestLogService.insert(requestLog);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送案件状态信息
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public JSONObject pushCaseStatusInfo(String username, String password, String caseNo, String statusCode, String caseClosureExplanation) {
|
||||
JSONObject result = new JSONObject();
|
||||
String token = getApiToken(username, password, System.currentTimeMillis());
|
||||
token = analysisResultToken(token);
|
||||
String token = beiMingInterfaceService.getApiToken(username, password, System.currentTimeMillis());
|
||||
if (token != null && !token.isEmpty()) {
|
||||
MsCaseStatusInfo info = MsCaseStatusInfo.builder().caseNo(caseNo).statusCode(statusCode).caseClosureExplanation(caseClosureExplanation).build();
|
||||
result = submitCaseStatusInfo(token, caseNo, username, info);
|
||||
@@ -265,16 +330,16 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送案件附件信息
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public JSONObject pushAttachmentInfo(String username, String password, File file, String abutmentId, String syncSource, String caseNo) {
|
||||
public MsCaseFileInfo pushAttachmentInfo(String username, String password, File file, String syncSource, String caseNo,AttachmentOperateTypeEnum operateTypeEnum) {
|
||||
JSONObject result = new JSONObject();
|
||||
MsCaseFileInfo fileInfo=null;
|
||||
//1.获取token
|
||||
String token = getApiToken(username, password, System.currentTimeMillis());
|
||||
token = analysisResultToken(token);
|
||||
String token = beiMingInterfaceService.getApiToken(username, password, System.currentTimeMillis());
|
||||
if (token != null && !token.isEmpty()) {
|
||||
//2.上传文件
|
||||
JSONObject fileResult = uploadFile(file, token, syncSource);
|
||||
@@ -289,16 +354,25 @@ public class BeiMingInterfaceService implements BeiMingInterface {
|
||||
System.out.println("fileId====:" + fileId);
|
||||
if (fileId != null) {
|
||||
//3.同步附件更新信息
|
||||
MsCaseFileInfo fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(file.getName()).abutmentId(abutmentId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build();
|
||||
result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.ADD.getCode(), caseNo, fileInfo);
|
||||
result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.UPD.getCode(), caseNo, fileInfo);
|
||||
result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo);
|
||||
fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(file.getName()).abutmentId(fileId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build();
|
||||
result = syncAttachmentInfo(token, username, operateTypeEnum.getCode(), caseNo, fileInfo);
|
||||
// 更新到附件表将fileId
|
||||
// result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.UPD.getCode(), caseNo, fileInfo);
|
||||
// result = syncAttachmentInfo(token, username, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject deleteAttachmentInfo( String caseNo,String fileId,String fileName) {
|
||||
String token = beiMingInterfaceService.getApiToken(BMUserName, BMPassword, System.currentTimeMillis());
|
||||
MsCaseFileInfo fileInfo = MsCaseFileInfo.builder().fileId(fileId).fileName(fileName).abutmentId(fileId).abutmentCaseId(caseNo).documentSubject("EVEDENT").documentType("EVEDENT_METERIAL").build();
|
||||
|
||||
return syncAttachmentInfo(token, BMUserName, AttachmentOperateTypeEnum.DEL.getCode(), caseNo, fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.system.domain.entity.log.MsRequestLog;
|
||||
import com.ruoyi.system.mapper.log.MsRequestLogMapper;
|
||||
import com.ruoyi.system.service.MsRequestLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Classname MsRequestLogServiceImpl
|
||||
* @Description TODO
|
||||
* @Version 1.0.0
|
||||
* @Date 2024/4/2 14:19
|
||||
* @Created wangqiong
|
||||
*/
|
||||
@Service
|
||||
public class MsRequestLogServiceImpl implements MsRequestLogService {
|
||||
@Autowired
|
||||
private MsRequestLogMapper logMapper;
|
||||
@Override
|
||||
public void insert(MsRequestLog requestLog) {
|
||||
logMapper.insert(requestLog);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.TreeSelect;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
@@ -20,6 +16,13 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
@@ -34,6 +37,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
@@ -221,7 +226,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
}
|
||||
return deptMapper.insertDept(dept);
|
||||
int i = deptMapper.insertDept(dept);
|
||||
redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId());
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,6 +256,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatusNormal(dept);
|
||||
}
|
||||
// 修改缓存
|
||||
redisCache.setCacheObject(CacheConstants.DEPT_KEY+dept.getDeptName(),dept.getDeptId());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -293,6 +302,11 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId)
|
||||
{
|
||||
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||
if(sysDept!=null) {
|
||||
// 删除缓存
|
||||
redisCache.deleteObject(CacheConstants.DEPT_KEY + sysDept.getDeptName());
|
||||
}
|
||||
return deptMapper.deleteDeptById(deptId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -24,6 +19,12 @@ import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色 业务层处理
|
||||
@@ -44,6 +45,8 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
@@ -233,6 +236,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
{
|
||||
// 新增角色信息
|
||||
roleMapper.insertRole(role);
|
||||
redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId());
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@@ -250,6 +254,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
roleMapper.updateRole(role);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
redisCache.setCacheObject(CacheConstants.ROLE_KEY+role.getRoleName(),role.getRoleId());
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
@@ -341,10 +346,15 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@Transactional
|
||||
public int deleteRoleById(Long roleId)
|
||||
{
|
||||
// 根据角色id查询角色名
|
||||
SysRole role = roleMapper.selectRoleById(roleId);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDeptByRoleId(roleId);
|
||||
if(role!=null) {
|
||||
redisCache.deleteObject(CacheConstants.ROLE_KEY + role.getRoleName());
|
||||
}
|
||||
return roleMapper.deleteRoleById(roleId);
|
||||
}
|
||||
|
||||
@@ -358,6 +368,11 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
@Transactional
|
||||
public int deleteRoleByIds(Long[] roleIds)
|
||||
{
|
||||
List<SysRole> roles = roleMapper.selectRoleList(new SysRole());
|
||||
if(CollectionUtil.isEmpty(roles)){
|
||||
return 0;
|
||||
}
|
||||
Map<Long, String> roleMap = roles.stream().collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName, (n1, n2) -> n2));
|
||||
for (Long roleId : roleIds)
|
||||
{
|
||||
checkRoleAllowed(new SysRole(roleId));
|
||||
@@ -367,6 +382,9 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
{
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
if(roleMap.containsKey(roleId)) {
|
||||
redisCache.deleteObject(CacheConstants.ROLE_KEY + roleMap.get(roleId));
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||
|
||||
Reference in New Issue
Block a user