|
@@ -16,6 +16,7 @@ import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -23,6 +24,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -63,6 +65,10 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|
|
private CompanyMapper companyMapper;
|
|
|
@Resource
|
|
|
private CompanyReportMapper companyReportMapper;
|
|
|
+ @Resource
|
|
|
+ private HttpServletRequest request;
|
|
|
+ @Resource
|
|
|
+ private OperationRecordMapper operationRecordMapper;
|
|
|
|
|
|
|
|
|
//根据角色id获取角色列表
|
|
@@ -313,6 +319,9 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg savePermission(Integer role, String moduleList) {
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ HttpRespMsg authority = getAuthority(role,user.getCompanyId(), request);
|
|
|
+ List<SysModule> sysModuleList= (List<SysModule>) authority.data;
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
JSONArray array = JSONArray.parseArray(moduleList);
|
|
|
List<Integer> selectedModuleIds = new ArrayList<>();
|
|
@@ -356,9 +365,58 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|
|
sysRoleFunctions.add(fun);
|
|
|
}
|
|
|
sysRoleFunctionService.saveBatch(sysRoleFunctions);
|
|
|
+ permissionModificationRecord(sysModuleList,moduleList,user);
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Async("taskExecutor")
|
|
|
+ public void permissionModificationRecord(List<SysModule> oldSysModuleList,String newModuleList,User user){
|
|
|
+ JSONArray array = JSONArray.parseArray(newModuleList);
|
|
|
+ StringBuilder message=new StringBuilder();
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
+ Optional<SysModule> first = oldSysModuleList.stream().filter(sl -> sl.getId().equals(jsonObject.getIntValue("id"))).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ String compareOld= jsonObject.getBoolean("checked")?"0":"1";
|
|
|
+ String compareNew= first.get().isChecked()?"0":"1";
|
|
|
+ if(!compareOld.equals(compareNew)){
|
|
|
+ if(jsonObject.getBoolean("checked")){
|
|
|
+ message.append("开启了["+first.get().getName()+"]功能模块\n");
|
|
|
+ }else {
|
|
|
+ message.append("关闭了["+first.get().getName()+"]功能模块\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONArray functionList = jsonObject.getJSONArray("functionList");
|
|
|
+ for (int j = 0; j < functionList.size(); j++) {
|
|
|
+ JSONObject function = functionList.getJSONObject(j);
|
|
|
+ if(first.isPresent()){
|
|
|
+ List<SysFunction> sysFunctionList = first.get().getFunctionList();
|
|
|
+ Optional<SysFunction> optional = sysFunctionList.stream().filter(sl -> sl.getId().equals(function.getIntValue("id"))).findFirst();
|
|
|
+ if(optional.isPresent()){
|
|
|
+ String compareOld= function.getBoolean("checked")?"0":"1";
|
|
|
+ String compareNew= optional.get().isChecked()?"0":"1";
|
|
|
+ if(!compareOld.equals(compareNew)){
|
|
|
+ if(function.getBoolean("checked")){
|
|
|
+ message.append("开启了["+optional.get().getName()+"]权限\n");
|
|
|
+ }else {
|
|
|
+ message.append("关闭了["+optional.get().getName()+"]权限\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(message.toString());
|
|
|
+ OperationRecord operationRecord=new OperationRecord();
|
|
|
+ operationRecord.setOperationTime(LocalDateTime.now());
|
|
|
+ operationRecord.setContent(message.toString());
|
|
|
+ operationRecord.setCompanyId(user.getCompanyId());
|
|
|
+ operationRecord.setModuleName("角色权限管理");
|
|
|
+ operationRecord.setOperatorName(user.getName());
|
|
|
+ operationRecordMapper.insert(operationRecord);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg setDefaultRole(Integer id, Integer companyId) {
|
|
|
//查找当前默认的角色
|