save code
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>digital-system</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<!--shiro-->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring-boot-starter</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<!--集成springmvc框架 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- feign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>hibernate-re</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>digital-bean</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>digital-util</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>digital-base</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>digital-config</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+697
@@ -0,0 +1,697 @@
|
||||
package digital.system.jeecg.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.SysPermissionDataRuleModel;
|
||||
import digital.bean.jeecg.dto.OnlineAuthDTO;
|
||||
import digital.bean.jeecg.dto.message.*;
|
||||
import digital.bean.jeecg.vo.*;
|
||||
import digital.system.jeecg.system.service.ISysUserService;
|
||||
import digital.system.jeecg.system.service.impl.SysBaseApiImpl;
|
||||
import digital.util.util.SysUserCacheInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* 服务化 system模块 对外接口请求类
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/api")
|
||||
public class SystemAPIController {
|
||||
|
||||
@Autowired
|
||||
private SysBaseApiImpl sysBaseApi;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
|
||||
*/
|
||||
@PostMapping("/sendSysAnnouncement")
|
||||
public void sendSysAnnouncement(@RequestBody MessageDTO message) {
|
||||
sysBaseApi.sendSysAnnouncement(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sendBusAnnouncement")
|
||||
public void sendBusAnnouncement(@RequestBody BusMessageDTO message) {
|
||||
sysBaseApi.sendBusAnnouncement(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过模板发送消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sendTemplateAnnouncement")
|
||||
public void sendTemplateAnnouncement(@RequestBody TemplateMessageDTO message) {
|
||||
sysBaseApi.sendTemplateAnnouncement(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过模板发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sendBusTemplateAnnouncement")
|
||||
public void sendBusTemplateAnnouncement(@RequestBody BusTemplateMessageDTO message) {
|
||||
sysBaseApi.sendBusTemplateAnnouncement(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过消息中心模板,生成推送内容
|
||||
*
|
||||
* @param templateDTO 使用构造器赋值参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/parseTemplateByCode")
|
||||
public String parseTemplateByCode(@RequestBody TemplateDTO templateDTO) {
|
||||
return sysBaseApi.parseTemplateByCode(templateDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务类型busType及业务busId修改消息已读
|
||||
*/
|
||||
@GetMapping("/updateSysAnnounReadFlag")
|
||||
public void updateSysAnnounReadFlag(@RequestParam("busType") String busType, @RequestParam("busId") String busId) {
|
||||
sysBaseApi.updateSysAnnounReadFlag(busType, busId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户账号查询用户信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserByName")
|
||||
public LoginUser getUserByName(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getUserByName(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id查询用户信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserById")
|
||||
LoginUser getUserById(@RequestParam("id") String id) {
|
||||
return sysBaseApi.getUserById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户账号查询角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRolesByUsername")
|
||||
List<String> getRolesByUsername(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getRolesByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户账号查询部门集合
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 id
|
||||
*/
|
||||
@GetMapping("/getDepartIdsByUsername")
|
||||
List<String> getDepartIdsByUsername(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getDepartIdsByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户账号查询部门 name
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 name
|
||||
*/
|
||||
@GetMapping("/getDepartNamesByUsername")
|
||||
List<String> getDepartNamesByUsername(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getDepartNamesByUsername(username);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据字典
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDictItemsByCode")
|
||||
List<DictModel> queryDictItemsByCode(@RequestParam("code") String code) {
|
||||
return sysBaseApi.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有效的数据字典
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryEnableDictItemsByCode")
|
||||
List<DictModel> queryEnableDictItemsByCode(@RequestParam("code") String code) {
|
||||
return sysBaseApi.queryEnableDictItemsByCode(code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有的父级字典,按照create_time排序
|
||||
*/
|
||||
@GetMapping("/queryAllDict")
|
||||
List<DictModel> queryAllDict() {
|
||||
// try{
|
||||
// //睡10秒,gateway网关5秒超时,会触发熔断降级操作
|
||||
// Thread.sleep(10000);
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
log.info("--我是jeecg-system服务节点,微服务接口queryAllDict被调用--");
|
||||
return sysBaseApi.queryAllDict();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有分类字典
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllSysCategory")
|
||||
List<SysCategoryModel> queryAllSysCategory() {
|
||||
return sysBaseApi.queryAllSysCategory();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有部门 作为字典信息 id -->value,departName -->text
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllDepartBackDictModel")
|
||||
List<DictModel> queryAllDepartBackDictModel() {
|
||||
return sysBaseApi.queryAllDepartBackDictModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有角色 带参
|
||||
* roleIds 默认选中角色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllRole")
|
||||
public List<ComboModel> queryAllRole(@RequestParam(name = "roleIds", required = false) String[] roleIds) {
|
||||
if (roleIds == null || roleIds.length == 0) {
|
||||
return sysBaseApi.queryAllRole();
|
||||
} else {
|
||||
return sysBaseApi.queryAllRole(roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户账号查询角色Id集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRoleIdsByUsername")
|
||||
public List<String> getRoleIdsByUsername(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getRoleIdsByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过部门编号查询部门id
|
||||
*
|
||||
* @param orgCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDepartIdsByOrgCode")
|
||||
public String getDepartIdsByOrgCode(@RequestParam("orgCode") String orgCode) {
|
||||
return sysBaseApi.getDepartIdsByOrgCode(orgCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getAllSysDepart")
|
||||
public List<SysDepartModel> getAllSysDepart() {
|
||||
return sysBaseApi.getAllSysDepart();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 id 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDynamicDbSourceById")
|
||||
DynamicDataSourceModel getDynamicDbSourceById(@RequestParam("dbSourceId") String dbSourceId) {
|
||||
return sysBaseApi.getDynamicDbSourceById(dbSourceId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门Id获取部门负责人
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDeptHeadByDepId")
|
||||
public List<String> getDeptHeadByDepId(@RequestParam("deptId") String deptId) {
|
||||
return sysBaseApi.getDeptHeadByDepId(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找父级部门
|
||||
*
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getParentDepartId")
|
||||
public DictModel getParentDepartId(@RequestParam("departId") String departId) {
|
||||
return sysBaseApi.getParentDepartId(departId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 code 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDynamicDbSourceByCode")
|
||||
public DynamicDataSourceModel getDynamicDbSourceByCode(@RequestParam("dbSourceCode") String dbSourceCode) {
|
||||
return sysBaseApi.getDynamicDbSourceByCode(dbSourceCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定用户发消息
|
||||
*
|
||||
* @param userIds
|
||||
* @param cmd
|
||||
*/
|
||||
@GetMapping("/sendWebSocketMsg")
|
||||
public void sendWebSocketMsg(String[] userIds, String cmd) {
|
||||
sysBaseApi.sendWebSocketMsg(userIds, cmd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取所有参与用户
|
||||
* userIds
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllUserByIds")
|
||||
public List<LoginUser> queryAllUserByIds(@RequestParam("userIds") String[] userIds) {
|
||||
return sysBaseApi.queryAllUserByIds(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有用户 返回ComboModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllUserBackCombo")
|
||||
public List<ComboModel> queryAllUserBackCombo() {
|
||||
return sysBaseApi.queryAllUserBackCombo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户 返回JSONObject
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryAllUser")
|
||||
public JSONObject queryAllUser(@RequestParam(name = "userIds", required = false) String userIds, @RequestParam(name = "pageNo", required = false) Integer pageNo, @RequestParam(name = "pageSize", required = false) int pageSize) {
|
||||
return sysBaseApi.queryAllUser(userIds, pageNo, pageSize);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将会议签到信息推动到预览
|
||||
* userIds
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/meetingSignWebsocket")
|
||||
public void meetingSignWebsocket(@RequestParam("userId") String userId) {
|
||||
sysBaseApi.meetingSignWebsocket(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据name获取所有参与用户
|
||||
* userNames
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryUserByNames")
|
||||
public List<LoginUser> queryUserByNames(@RequestParam("userNames") String[] userNames) {
|
||||
return sysBaseApi.queryUserByNames(userNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserRoleSet")
|
||||
public Set<String> getUserRoleSet(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getUserRoleSet(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的权限集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserPermissionSet")
|
||||
public Set<String> getUserPermissionSet(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getUserPermissionSet(username);
|
||||
}
|
||||
|
||||
//-----
|
||||
|
||||
/**
|
||||
* 判断是否有online访问的权限
|
||||
*
|
||||
* @param onlineAuthDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/hasOnlineAuth")
|
||||
public boolean hasOnlineAuth(@RequestBody OnlineAuthDTO onlineAuthDTO) {
|
||||
return sysBaseApi.hasOnlineAuth(onlineAuthDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户角色信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryUserRoles")
|
||||
public Set<String> queryUserRoles(@RequestParam("username") String username) {
|
||||
return sysUserService.getUserRolesSet(username);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询用户权限信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryUserAuths")
|
||||
public Set<String> queryUserAuths(@RequestParam("username") String username) {
|
||||
return sysUserService.getUserPermissionsSet(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过部门id获取部门全部信息
|
||||
*/
|
||||
@GetMapping("/selectAllById")
|
||||
public SysDepartModel selectAllById(@RequestParam("id") String id) {
|
||||
return sysBaseApi.selectAllById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id查询用户所属公司下所有用户ids
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDeptUsersByUserId")
|
||||
public List<String> queryDeptUsersByUserId(@RequestParam("userId") String userId) {
|
||||
return sysBaseApi.queryDeptUsersByUserId(userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询数据权限
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryPermissionDataRule")
|
||||
public List<SysPermissionDataRuleModel> queryPermissionDataRule(@RequestParam("component") String component, @RequestParam("requestPath") String requestPath, @RequestParam("username") String username) {
|
||||
return sysBaseApi.queryPermissionDataRule(component, requestPath, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getCacheUser")
|
||||
public SysUserCacheInfo getCacheUser(@RequestParam("username") String username) {
|
||||
return sysBaseApi.getCacheUser(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通字典的翻译
|
||||
*
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDict")
|
||||
public String translateDict(@RequestParam("code") String code, @RequestParam("key") String key) {
|
||||
return sysBaseApi.translateDict(code, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/queryUsersByUsernames")
|
||||
List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames) {
|
||||
return this.sysBaseApi.queryUsersByUsernames(usernames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 37根据多个用户id(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/queryUsersByIds")
|
||||
List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids) {
|
||||
return this.sysBaseApi.queryUsersByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 38根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDepartsByOrgcodes")
|
||||
List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes) {
|
||||
return this.sysBaseApi.queryDepartsByOrgcodes(orgCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 39根据多个部门ID(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDepartsByIds")
|
||||
List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids) {
|
||||
return this.sysBaseApi.queryDepartsByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 40发送邮件消息
|
||||
*
|
||||
* @param email
|
||||
* @param title
|
||||
* @param content
|
||||
*/
|
||||
// @GetMapping("/sendEmailMsg")
|
||||
// public void sendEmailMsg(@RequestParam("email") String email, @RequestParam("title") String title, @RequestParam("content") String content) {
|
||||
// this.sysBaseApi.sendEmailMsg(email, title, content);
|
||||
// }
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 41 获取公司下级部门和公司下所有用户信息
|
||||
*
|
||||
* @param orgCode
|
||||
*/
|
||||
@GetMapping("/getDeptUserByOrgCode")
|
||||
List<Map> getDeptUserByOrgCode(@RequestParam("orgCode") String orgCode) {
|
||||
return this.sysBaseApi.getDeptUserByOrgCode(orgCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类字典翻译
|
||||
*
|
||||
* @param ids 分类字典表id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadCategoryDictItem")
|
||||
public List<String> loadCategoryDictItem(@RequestParam("ids") String ids) {
|
||||
return sysBaseApi.loadCategoryDictItem(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadDictItem")
|
||||
public List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys) {
|
||||
return sysBaseApi.loadDictItem(dictCode, keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code查询字典项
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param dictCode 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDictItems")
|
||||
public List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode) {
|
||||
return sysBaseApi.getDictItems(dictCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
@RequestMapping("/getManyDictItems")
|
||||
public Map<String, List<DictModel>> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList) {
|
||||
return sysBaseApi.getManyDictItems(dictCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【下拉搜索】
|
||||
* 大数据量的字典表 走异步加载,即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @param keyword 过滤关键字
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadDictItemByKeyword")
|
||||
public List<DictModel> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
return sysBaseApi.loadDictItemByKeyword(dictCode, keyword, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 48 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
|
||||
*
|
||||
* @param dictCodes
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateManyDict")
|
||||
public Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys) {
|
||||
return this.sysBaseApi.translateManyDict(dictCodes, keys);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取表数据字典 【接口签名验证】
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryTableDictItemsByCode")
|
||||
List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code) {
|
||||
return sysBaseApi.queryTableDictItemsByCode(table, text, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表字典 支持过滤数据 【接口签名验证】
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryFilterTableDictInfo")
|
||||
List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql) {
|
||||
return sysBaseApi.queryFilterTableDictInfo(table, text, code, filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 查询指定table的 text code 获取字典,包含text和value
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@GetMapping("/queryTableDictByKeys")
|
||||
public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray) {
|
||||
return sysBaseApi.queryTableDictByKeys(table, text, code, keyArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字典表的 翻译【接口签名验证】
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDictFromTable")
|
||||
public String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key) {
|
||||
return sysBaseApi.translateDictFromTable(table, text, code, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 49 字典表的 翻译,可批量
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys 多个用逗号分割
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDictFromTableByKeys")
|
||||
public List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys) {
|
||||
return this.sysBaseApi.translateDictFromTableByKeys(table, text, code, keys);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package digital.system.jeecg.group;
|
||||
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.SysPermissionDataRuleModel;
|
||||
import digital.bean.jeecg.vo.DictModel;
|
||||
import digital.bean.jeecg.vo.DynamicDataSourceModel;
|
||||
import digital.util.util.SysUserCacheInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 通用api
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface CommonAPI {
|
||||
|
||||
/**
|
||||
* 1查询用户角色信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> queryUserRoles(String username);
|
||||
|
||||
|
||||
/**
|
||||
* 2查询用户权限信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> queryUserAuths(String username);
|
||||
|
||||
/**
|
||||
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceId
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);
|
||||
|
||||
/**
|
||||
* 4根据 code 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceCode
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);
|
||||
|
||||
/**
|
||||
* 5根据用户账号查询用户信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public LoginUser getUserByName(String username);
|
||||
|
||||
|
||||
/**
|
||||
* 6字典表的 翻译
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String translateDictFromTable(String table, String text, String code, String key);
|
||||
|
||||
/**
|
||||
* 7普通字典的翻译
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String translateDict(String code, String key);
|
||||
|
||||
/**
|
||||
* 8查询数据权限
|
||||
* @param component 组件
|
||||
* @param username 用户名
|
||||
* @param requestPath 前段请求地址
|
||||
* @return
|
||||
*/
|
||||
List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username);
|
||||
|
||||
|
||||
/**
|
||||
* 9查询用户信息
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
SysUserCacheInfo getCacheUser(String username);
|
||||
|
||||
/**
|
||||
* 10获取数据字典
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryDictItemsByCode(String code);
|
||||
|
||||
/**
|
||||
* 获取有效的数据字典项
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryEnableDictItemsByCode(String code);
|
||||
|
||||
/**
|
||||
* 13获取表数据字典
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
|
||||
|
||||
/**
|
||||
* 14 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
|
||||
* @param dictCodes 例如:user_status,sex
|
||||
* @param keys 例如:1,2,0
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys);
|
||||
|
||||
/**
|
||||
* 15 字典表的 翻译,可批量
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys 多个用逗号分割
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,592 @@
|
||||
package digital.system.jeecg.group.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import digital.system.jeecg.group.CommonAPI;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.SysPermissionDataRuleModel;
|
||||
import digital.bean.jeecg.dto.OnlineAuthDTO;
|
||||
import digital.bean.jeecg.dto.message.*;
|
||||
import digital.bean.jeecg.vo.*;
|
||||
import digital.util.util.SysUserCacheInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 1、cloud接口数量43 local:35 common:9 额外一个特殊queryAllRole一个当两个用
|
||||
* - 相比较local版jeecg.
|
||||
* - 去掉了一些方法:addLog、getDatabaseType、queryAllDepart、queryAllUser(Wrapper wrapper)、queryAllUser(String[] userIds, int pageNo, int pageSize)
|
||||
* - 修改了一些方法:createLog、sendSysAnnouncement(只保留了一个,其余全部干掉)
|
||||
* 2、@ConditionalOnMissingClass("org.jeecg.modules.system.service.impl.SysBaseApiImpl")=> 有实现类的时候,不实例化Feign接口
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
@Component
|
||||
//@FeignClient(contextId = "sysBaseRemoteApi", value = ServiceNameConstants.SERVICE_SYSTEM, fallbackFactory = SysBaseAPIFallbackFactory.class)
|
||||
//@ConditionalOnMissingClass("digital.system.modules.system.service.impl.SysBaseApiImpl")
|
||||
public interface ISysBaseAPI extends CommonAPI {
|
||||
|
||||
/**
|
||||
* 1发送系统消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
|
||||
*/
|
||||
@PostMapping("/sys/api/sendSysAnnouncement")
|
||||
void sendSysAnnouncement(@RequestBody MessageDTO message);
|
||||
|
||||
/**
|
||||
* 2发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sys/api/sendBusAnnouncement")
|
||||
void sendBusAnnouncement(@RequestBody BusMessageDTO message);
|
||||
|
||||
/**
|
||||
* 3通过模板发送消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sys/api/sendTemplateAnnouncement")
|
||||
void sendTemplateAnnouncement(@RequestBody TemplateMessageDTO message);
|
||||
|
||||
/**
|
||||
* 4通过模板发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
@PostMapping("/sys/api/sendBusTemplateAnnouncement")
|
||||
void sendBusTemplateAnnouncement(@RequestBody BusTemplateMessageDTO message);
|
||||
|
||||
/**
|
||||
* 5通过消息中心模板,生成推送内容
|
||||
*
|
||||
* @param templateDTO 使用构造器赋值参数
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sys/api/parseTemplateByCode")
|
||||
String parseTemplateByCode(@RequestBody TemplateDTO templateDTO);
|
||||
|
||||
/**
|
||||
* 6根据用户id查询用户信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getUserById")
|
||||
LoginUser getUserById(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 7通过用户账号查询角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getRolesByUsername")
|
||||
List<String> getRolesByUsername(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 8通过用户账号查询部门集合
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 id
|
||||
*/
|
||||
@GetMapping("/sys/api/getDepartIdsByUsername")
|
||||
List<String> getDepartIdsByUsername(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 9通过用户账号查询部门 name
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 name
|
||||
*/
|
||||
@GetMapping("/sys/api/getDepartNamesByUsername")
|
||||
List<String> getDepartNamesByUsername(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 10获取数据字典
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryDictItemsByCode")
|
||||
List<DictModel> queryDictItemsByCode(@RequestParam("code") String code);
|
||||
|
||||
/**
|
||||
* 获取有效的数据字典项
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryEnableDictItemsByCode")
|
||||
public List<DictModel> queryEnableDictItemsByCode(@RequestParam("code") String code);
|
||||
|
||||
/**
|
||||
* 11查询所有的父级字典,按照create_time排序
|
||||
*
|
||||
* @return List<DictModel> 字典值集合
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllDict")
|
||||
List<DictModel> queryAllDict();
|
||||
|
||||
/**
|
||||
* 12查询所有分类字典
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllSysCategory")
|
||||
List<SysCategoryModel> queryAllSysCategory();
|
||||
|
||||
/**
|
||||
* 13获取表数据字典
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryTableDictItemsByCode")
|
||||
List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code);
|
||||
|
||||
/**
|
||||
* 14查询所有部门 作为字典信息 id -->value,departName -->text
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllDepartBackDictModel")
|
||||
List<DictModel> queryAllDepartBackDictModel();
|
||||
|
||||
/**
|
||||
* 15根据业务类型 busType 及业务 busId 修改消息已读
|
||||
*
|
||||
* @param busType 业务类型
|
||||
* @param busId 业务id
|
||||
*/
|
||||
@GetMapping("/sys/api/updateSysAnnounReadFlag")
|
||||
public void updateSysAnnounReadFlag(@RequestParam("busType") String busType, @RequestParam("busId") String busId);
|
||||
|
||||
/**
|
||||
* 16查询表字典 支持过滤数据
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryFilterTableDictInfo")
|
||||
List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql);
|
||||
|
||||
/**
|
||||
* 17查询指定table的 text code 获取字典,包含text和value
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@GetMapping("/sys/api/queryTableDictByKeys")
|
||||
public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray);
|
||||
|
||||
/**
|
||||
* 18查询所有用户 返回ComboModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllUserBackCombo")
|
||||
public List<ComboModel> queryAllUserBackCombo();
|
||||
|
||||
/**
|
||||
* 19分页查询用户 返回JSONObject
|
||||
*
|
||||
* @param userIds 多个用户id
|
||||
* @param pageNo 当前页数
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllUser")
|
||||
public JSONObject queryAllUser(@RequestParam(name = "userIds", required = false) String userIds, @RequestParam(name = "pageNo", required = false) Integer pageNo, @RequestParam(name = "pageSize", required = false) int pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 20获取所有角色 带参
|
||||
*
|
||||
* @param roleIds 默认选中角色
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllRole")
|
||||
public List<ComboModel> queryAllRole(@RequestParam(name = "roleIds", required = false) String[] roleIds);
|
||||
|
||||
/**
|
||||
* 21通过用户账号查询角色Id集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getRoleIdsByUsername")
|
||||
public List<String> getRoleIdsByUsername(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 22通过部门编号查询部门id
|
||||
*
|
||||
* @param orgCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getDepartIdsByOrgCode")
|
||||
public String getDepartIdsByOrgCode(@RequestParam("orgCode") String orgCode);
|
||||
|
||||
/**
|
||||
* 23查询所有部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getAllSysDepart")
|
||||
public List<SysDepartModel> getAllSysDepart();
|
||||
|
||||
/**
|
||||
* 24查找父级部门
|
||||
*
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getParentDepartId")
|
||||
DictModel getParentDepartId(@RequestParam("departId") String departId);
|
||||
|
||||
/**
|
||||
* 25根据部门Id获取部门负责人
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getDeptHeadByDepId")
|
||||
public List<String> getDeptHeadByDepId(@RequestParam("deptId") String deptId);
|
||||
|
||||
/**
|
||||
* 26给指定用户发消息
|
||||
*
|
||||
* @param userIds
|
||||
* @param cmd
|
||||
*/
|
||||
@GetMapping("/sys/api/sendWebSocketMsg")
|
||||
public void sendWebSocketMsg(@RequestParam("userIds") String[] userIds, @RequestParam("cmd") String cmd);
|
||||
|
||||
/**
|
||||
* 27根据id获取所有参与用户
|
||||
*
|
||||
* @param userIds 多个用户id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryAllUserByIds")
|
||||
public List<LoginUser> queryAllUserByIds(@RequestParam("userIds") String[] userIds);
|
||||
|
||||
/**
|
||||
* 28将会议签到信息推动到预览
|
||||
* userIds
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/meetingSignWebsocket")
|
||||
void meetingSignWebsocket(@RequestParam("userId") String userId);
|
||||
|
||||
/**
|
||||
* 29根据name获取所有参与用户
|
||||
*
|
||||
* @param userNames 多个用户账号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryUserByNames")
|
||||
List<LoginUser> queryUserByNames(@RequestParam("userNames") String[] userNames);
|
||||
|
||||
|
||||
/**
|
||||
* 30获取用户的角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getUserRoleSet")
|
||||
Set<String> getUserRoleSet(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 31获取用户的权限集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getUserPermissionSet")
|
||||
Set<String> getUserPermissionSet(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 32判断是否有online访问的权限
|
||||
*
|
||||
* @param onlineAuthDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sys/api/hasOnlineAuth")
|
||||
boolean hasOnlineAuth(@RequestBody OnlineAuthDTO onlineAuthDTO);
|
||||
|
||||
/**
|
||||
* 33通过部门id获取部门全部信息
|
||||
*
|
||||
* @param id 部门id
|
||||
* @return SysDepartModel 部门信息
|
||||
*/
|
||||
@GetMapping("/sys/api/selectAllById")
|
||||
SysDepartModel selectAllById(@RequestParam("id") String id);
|
||||
|
||||
/**
|
||||
* 34根据用户id查询用户所属公司下所有用户ids
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryDeptUsersByUserId")
|
||||
List<String> queryDeptUsersByUserId(@RequestParam("userId") String userId);
|
||||
|
||||
|
||||
//---
|
||||
|
||||
/**
|
||||
* 35查询用户角色信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryUserRoles")
|
||||
Set<String> queryUserRoles(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 36查询用户权限信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryUserAuths")
|
||||
Set<String> queryUserAuths(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 37根据 id 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/getDynamicDbSourceById")
|
||||
DynamicDataSourceModel getDynamicDbSourceById(@RequestParam("dbSourceId") String dbSourceId);
|
||||
|
||||
/**
|
||||
* 38根据 code 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/getDynamicDbSourceByCode")
|
||||
DynamicDataSourceModel getDynamicDbSourceByCode(@RequestParam("dbSourceCode") String dbSourceCode);
|
||||
|
||||
/**
|
||||
* 39根据用户账号查询用户信息 CommonAPI中定义
|
||||
*
|
||||
* @param username
|
||||
* @return LoginUser 用户信息
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/getUserByName")
|
||||
LoginUser getUserByName(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 40字典表的 翻译
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/translateDictFromTable")
|
||||
String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key);
|
||||
|
||||
/**
|
||||
* 41普通字典的翻译
|
||||
*
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/translateDict")
|
||||
String translateDict(@RequestParam("code") String code, @RequestParam("key") String key);
|
||||
|
||||
/**
|
||||
* 42查询数据权限
|
||||
*
|
||||
* @param component
|
||||
* @param requestPath
|
||||
* @param username 用户姓名
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/queryPermissionDataRule")
|
||||
List<SysPermissionDataRuleModel> queryPermissionDataRule(@RequestParam("component") String component, @RequestParam("requestPath") String requestPath, @RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 43查询用户信息
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/getCacheUser")
|
||||
SysUserCacheInfo getCacheUser(@RequestParam("username") String username);
|
||||
|
||||
/**
|
||||
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryUsersByUsernames")
|
||||
List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames);
|
||||
|
||||
/**
|
||||
* 37根据多个用户ID(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/sys/api/queryUsersByIds")
|
||||
List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids);
|
||||
|
||||
/**
|
||||
* 38根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/sys/api/queryDepartsByOrgcodes")
|
||||
List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes);
|
||||
|
||||
/**
|
||||
* 39根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryDepartsByOrgIds")
|
||||
List<JSONObject> queryDepartsByOrgIds(@RequestParam("ids") String ids);
|
||||
|
||||
/**
|
||||
* 40发送邮件消息
|
||||
*
|
||||
* @param email
|
||||
* @param title
|
||||
* @param content
|
||||
*/
|
||||
@GetMapping("/sys/api/sendEmailMsg")
|
||||
void sendEmailMsg(@RequestParam("email") String email, @RequestParam("title") String title, @RequestParam("content") String content);
|
||||
|
||||
/**
|
||||
* 41 获取公司下级部门和公司下所有用户id
|
||||
*
|
||||
* @param orgCode 部门编号
|
||||
* @return List<Map>
|
||||
*/
|
||||
@GetMapping("/sys/api/getDeptUserByOrgCode")
|
||||
List<Map> getDeptUserByOrgCode(@RequestParam("orgCode") String orgCode);
|
||||
|
||||
/**
|
||||
* 42 查询分类字典翻译
|
||||
*
|
||||
* @param ids 多个分类字典id
|
||||
* @return List<String>
|
||||
*/
|
||||
@GetMapping("/sys/api/loadCategoryDictItem")
|
||||
List<String> loadCategoryDictItem(@RequestParam("ids") String ids);
|
||||
|
||||
/**
|
||||
* 43 根据字典code加载字典text
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/loadDictItem")
|
||||
List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys);
|
||||
|
||||
/**
|
||||
* 44 根据字典code查询字典项
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param dictCode 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/getDictItems")
|
||||
List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode);
|
||||
|
||||
/**
|
||||
* 45 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
@RequestMapping("/sys/api/getManyDictItems")
|
||||
Map<String, List<DictModel>> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList);
|
||||
|
||||
/**
|
||||
* 46 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @param keyword 过滤关键字
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/loadDictItemByKeyword")
|
||||
List<DictModel> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize);
|
||||
|
||||
/**
|
||||
* 47 根据多个部门id(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryDepartsByIds")
|
||||
List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids);
|
||||
|
||||
/**
|
||||
* 48 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
|
||||
*
|
||||
* @param dictCodes
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/translateManyDict")
|
||||
Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys);
|
||||
|
||||
/**
|
||||
* 49 字典表的 翻译,可批量
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys 多个用逗号分割
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/sys/api/translateDictFromTableByKeys")
|
||||
List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys);
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package digital.system.jeecg.group.api.factory;
|
||||
|
||||
import digital.system.jeecg.group.api.ISysBaseAPI;
|
||||
import digital.system.jeecg.group.api.fallback.SysBaseAPIFallback;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description: SysBaseAPIFallbackFactory
|
||||
* @author: smcp
|
||||
*/
|
||||
@Component
|
||||
public class SysBaseAPIFallbackFactory implements FallbackFactory<ISysBaseAPI> {
|
||||
|
||||
@Override
|
||||
public ISysBaseAPI create(Throwable throwable) {
|
||||
SysBaseAPIFallback fallback = new SysBaseAPIFallback();
|
||||
fallback.setCause(throwable);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
+324
@@ -0,0 +1,324 @@
|
||||
package digital.system.jeecg.group.api.fallback;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import digital.system.jeecg.group.api.ISysBaseAPI;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.SysPermissionDataRuleModel;
|
||||
import digital.bean.jeecg.dto.OnlineAuthDTO;
|
||||
import digital.bean.jeecg.dto.message.*;
|
||||
import digital.bean.jeecg.vo.*;
|
||||
import digital.util.util.SysUserCacheInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 进入fallback的方法 检查是否token未设置
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
@Slf4j
|
||||
public class SysBaseAPIFallback implements ISysBaseAPI {
|
||||
|
||||
@Setter
|
||||
private Throwable cause;
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(MessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBusAnnouncement(BusMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTemplateAnnouncement(TemplateMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBusTemplateAnnouncement(BusTemplateMessageDTO message) {
|
||||
log.error("发送消息失败 {}", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseTemplateByCode(TemplateDTO templateDTO) {
|
||||
log.error("通过模板获取消息内容失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getUserById(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRolesByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDepartIdsByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDepartNamesByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryEnableDictItemsByCode(String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryAllDict() {
|
||||
log.error("fegin接口queryAllDict失败:" + cause.getMessage(), cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysCategoryModel> queryAllSysCategory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryAllDepartBackDictModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysAnnounReadFlag(String busType, String busId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) {
|
||||
log.error("queryTableDictByKeys查询失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUserBackCombo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllUser(String userIds, Integer pageNo, int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllRole(String[] roleIds) {
|
||||
log.error("获取角色信息失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleIdsByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDepartIdsByOrgCode(String orgCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDepartModel> getAllSysDepart() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictModel getParentDepartId(String departId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDeptHeadByDepId(String deptId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendWebSocketMsg(String[] userIds, String cmd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> queryAllUserByIds(String[] userIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void meetingSignWebsocket(String userId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> queryUserByNames(String[] userNames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUserRoleSet(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getUserPermissionSet(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOnlineAuth(OnlineAuthDTO onlineAuthDTO) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDepartModel selectAllById(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryDeptUsersByUserId(String userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> queryUserRoles(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> queryUserAuths(String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser getUserByName(String username) {
|
||||
log.error("jeecg-system服务节点不通,导致获取登录用户信息失败: " + cause.getMessage(), cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateDictFromTable(String table, String text, String code, String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translateDict(String code, String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserCacheInfo getCacheUser(String username) {
|
||||
log.error("获取用户信息失败 {}", cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryUsersByUsernames(String usernames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryUsersByIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByOrgcodes(String orgCodes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEmailMsg(String email, String title, String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getDeptUserByOrgCode(String orgCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByOrgIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadCategoryDictItem(String ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String dictCode, String keys) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> getDictItems(String dictCode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> getManyDictItems(List<String> dictCodeList) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> loadDictItemByKeyword(String dictCode, String keyword, Integer pageSize) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
package digital.system.jeecg.group.base;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import digital.system.jeecg.group.CommonAPI;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.bean.jeecg.dto.OnlineAuthDTO;
|
||||
import digital.bean.jeecg.dto.message.*;
|
||||
import digital.bean.jeecg.vo.ComboModel;
|
||||
import digital.bean.jeecg.vo.DictModel;
|
||||
import digital.bean.jeecg.vo.SysCategoryModel;
|
||||
import digital.bean.jeecg.vo.SysDepartModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description 底层共通业务API,提供其他独立模块调用
|
||||
* @Author scott
|
||||
* @Date 2019-4-20
|
||||
* @Version V1.0
|
||||
*/
|
||||
public interface ISysBaseAPI extends CommonAPI {
|
||||
|
||||
|
||||
/**
|
||||
* 1发送系统消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
|
||||
*/
|
||||
void sendSysAnnouncement(MessageDTO message);
|
||||
|
||||
/**
|
||||
* 2发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
void sendBusAnnouncement(BusMessageDTO message);
|
||||
|
||||
/**
|
||||
* 3通过模板发送消息
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
void sendTemplateAnnouncement(TemplateMessageDTO message);
|
||||
|
||||
/**
|
||||
* 4通过模板发送消息 附带业务参数
|
||||
*
|
||||
* @param message 使用构造器赋值参数
|
||||
*/
|
||||
void sendBusTemplateAnnouncement(BusTemplateMessageDTO message);
|
||||
|
||||
/**
|
||||
* 5通过消息中心模板,生成推送内容
|
||||
*
|
||||
* @param templateDTO 使用构造器赋值参数
|
||||
* @return
|
||||
*/
|
||||
String parseTemplateByCode(TemplateDTO templateDTO);
|
||||
|
||||
/**
|
||||
* 6根据用户id查询用户信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LoginUser getUserById(String id);
|
||||
|
||||
/**
|
||||
* 7通过用户账号查询角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
List<String> getRolesByUsername(String username);
|
||||
|
||||
/**
|
||||
* 8通过用户账号查询部门集合
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 id
|
||||
*/
|
||||
List<String> getDepartIdsByUsername(String username);
|
||||
|
||||
/**
|
||||
* 9通过用户账号查询部门 name
|
||||
*
|
||||
* @param username
|
||||
* @return 部门 name
|
||||
*/
|
||||
List<String> getDepartNamesByUsername(String username);
|
||||
|
||||
|
||||
/**
|
||||
* 11查询所有的父级字典,按照create_time排序
|
||||
*
|
||||
* @return List<DictModel> 字典集合
|
||||
*/
|
||||
public List<DictModel> queryAllDict();
|
||||
|
||||
/**
|
||||
* 12查询所有分类字典
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SysCategoryModel> queryAllSysCategory();
|
||||
|
||||
|
||||
/**
|
||||
* 14查询所有部门 作为字典信息 id -->value,departName -->text
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryAllDepartBackDictModel();
|
||||
|
||||
/**
|
||||
* 15根据业务类型及业务id修改消息已读
|
||||
*
|
||||
* @param busType
|
||||
* @param busId
|
||||
*/
|
||||
public void updateSysAnnounReadFlag(String busType, String busId);
|
||||
|
||||
/**
|
||||
* 16查询表字典 支持过滤数据
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql);
|
||||
|
||||
/**
|
||||
* 17查询指定table的 text code 获取字典,包含text和value
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray);
|
||||
|
||||
/**
|
||||
* 18查询所有用户 返回ComboModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ComboModel> queryAllUserBackCombo();
|
||||
|
||||
/**
|
||||
* 19分页查询用户 返回JSONObject
|
||||
*
|
||||
* @param userIds 多个用户id
|
||||
* @param pageNo 当前页数
|
||||
* @param pageSize 每页显示条数
|
||||
* @return
|
||||
*/
|
||||
public JSONObject queryAllUser(String userIds, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 20获取所有角色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ComboModel> queryAllRole();
|
||||
|
||||
/**
|
||||
* 21获取所有角色 带参
|
||||
*
|
||||
* @param roleIds 默认选中角色
|
||||
* @return
|
||||
*/
|
||||
public List<ComboModel> queryAllRole(String[] roleIds);
|
||||
|
||||
/**
|
||||
* 22通过用户账号查询角色Id集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public List<String> getRoleIdsByUsername(String username);
|
||||
|
||||
/**
|
||||
* 23通过部门编号查询部门id
|
||||
*
|
||||
* @param orgCode
|
||||
* @return
|
||||
*/
|
||||
public String getDepartIdsByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 24查询所有部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SysDepartModel> getAllSysDepart();
|
||||
|
||||
/**
|
||||
* 25查找父级部门
|
||||
*
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
DictModel getParentDepartId(String departId);
|
||||
|
||||
/**
|
||||
* 26根据部门Id获取部门负责人
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getDeptHeadByDepId(String deptId);
|
||||
|
||||
/**
|
||||
* 27给指定用户发消息
|
||||
*
|
||||
* @param userIds
|
||||
* @param cmd
|
||||
*/
|
||||
public void sendWebSocketMsg(String[] userIds, String cmd);
|
||||
|
||||
/**
|
||||
* 28根据id获取所有参与用户
|
||||
*
|
||||
* @param userIds 多个用户id
|
||||
* @return
|
||||
*/
|
||||
public List<LoginUser> queryAllUserByIds(String[] userIds);
|
||||
|
||||
/**
|
||||
* 29将会议签到信息推动到预览
|
||||
* userIds
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
void meetingSignWebsocket(String userId);
|
||||
|
||||
/**
|
||||
* 30根据name获取所有参与用户
|
||||
*
|
||||
* @param userNames 多个用户账户
|
||||
* @return
|
||||
*/
|
||||
List<LoginUser> queryUserByNames(String[] userNames);
|
||||
|
||||
|
||||
/**
|
||||
* 31获取用户的角色集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> getUserRoleSet(String username);
|
||||
|
||||
/**
|
||||
* 32获取用户的权限集合
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
Set<String> getUserPermissionSet(String username);
|
||||
|
||||
/**
|
||||
* 33判断是否有online访问的权限
|
||||
*
|
||||
* @param onlineAuthDTO
|
||||
* @return
|
||||
*/
|
||||
boolean hasOnlineAuth(OnlineAuthDTO onlineAuthDTO);
|
||||
|
||||
/**
|
||||
* 34通过部门id获取部门全部信息
|
||||
*
|
||||
* @param id 部门id
|
||||
* @return SysDepartModel对象
|
||||
*/
|
||||
SysDepartModel selectAllById(String id);
|
||||
|
||||
/**
|
||||
* 35根据用户id查询用户所属公司下所有用户ids
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<String> queryDeptUsersByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryUsersByUsernames(String usernames);
|
||||
|
||||
/**
|
||||
* 37根据多个用户ID(逗号分隔),查询返回多个用户信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryUsersByIds(String ids);
|
||||
|
||||
/**
|
||||
* 38根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryDepartsByOrgcodes(String orgCodes);
|
||||
|
||||
/**
|
||||
* 39根据多个部门id(逗号分隔),查询返回多个部门信息
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryDepartsByIds(String ids);
|
||||
|
||||
/**
|
||||
* 40发送邮件消息
|
||||
*
|
||||
* @param email
|
||||
* @param title
|
||||
* @param content
|
||||
*/
|
||||
// void sendEmailMsg(String email, String title, String content);
|
||||
|
||||
/**
|
||||
* 41 获取公司下级部门和公司下所有用户信息
|
||||
*
|
||||
* @param orgCode
|
||||
* @return List<Map>
|
||||
*/
|
||||
List<Map> getDeptUserByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 查询分类字典翻译
|
||||
*
|
||||
* @param ids 多个分类字典id
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> loadCategoryDictItem(String ids);
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @return
|
||||
*/
|
||||
List<String> loadDictItem(String dictCode, String keys);
|
||||
|
||||
/**
|
||||
* 根据字典code查询字典项
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param dictCode 要查询的key
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> getDictItems(String dictCode);
|
||||
|
||||
/**
|
||||
* 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
Map<String, List<DictModel>> getManyDictItems(List<String> dictCodeList);
|
||||
|
||||
/**
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @param keyword 过滤关键字
|
||||
* @param pageSize 分页条数
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> loadDictItemByKeyword(String dictCode, String keyword, Integer pageSize);
|
||||
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
package digital.system.jeecg.group.base.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.Result;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: Controller基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-21 8:13
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class JeecgController<T, S extends IService<T>> {
|
||||
/**issues/2933 JeecgController注入service时改用protected修饰,能避免重复引用service*/
|
||||
@Autowired
|
||||
protected S service;
|
||||
|
||||
@Value("${jeecg.path.upload}")
|
||||
private String upLoadPath;
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
// Step.2 获取导出数据
|
||||
List<T> pageList = service.list(queryWrapper);
|
||||
List<T> exportList = null;
|
||||
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if (oConvertUtils.isNotEmpty(selections)) {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
|
||||
} else {
|
||||
exportList = pageList;
|
||||
}
|
||||
|
||||
// Step.3 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
//此处设置的filename无效 ,前端会重更新设置一下
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, title);
|
||||
mv.addObject(NormalExcelConstants.CLASS, clazz);
|
||||
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
|
||||
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
|
||||
exportParams.setImageBasePath(upLoadPath);
|
||||
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
|
||||
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
return mv;
|
||||
}
|
||||
/**
|
||||
* 根据每页sheet数量导出多sheet
|
||||
*
|
||||
* @param request
|
||||
* @param object 实体类
|
||||
* @param clazz 实体类class
|
||||
* @param title 标题
|
||||
* @param exportFields 导出字段自定义
|
||||
* @param pageNum 每个sheet的数据条数
|
||||
* @param request
|
||||
*/
|
||||
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields,Integer pageNum) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// Step.2 计算分页sheet数据
|
||||
double total = service.count();
|
||||
int count = (int)Math.ceil(total/pageNum);
|
||||
// Step.3 多sheet处理
|
||||
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
|
||||
for (int i = 1; i <=count ; i++) {
|
||||
Page<T> page = new Page<T>(i, pageNum);
|
||||
IPage<T> pageList = service.page(page, queryWrapper);
|
||||
List<T> records = pageList.getRecords();
|
||||
List<T> exportList = null;
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if (oConvertUtils.isNotEmpty(selections)) {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
exportList = records.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
|
||||
} else {
|
||||
exportList = records;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(5);
|
||||
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,upLoadPath);
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
//map.put("title",exportParams);
|
||||
//表格Title
|
||||
map.put(NormalExcelConstants.PARAMS,exportParams);
|
||||
//表格对应实体
|
||||
map.put(NormalExcelConstants.CLASS,clazz);
|
||||
//数据集合
|
||||
map.put(NormalExcelConstants.DATA_LIST, exportList);
|
||||
listMap.add(map);
|
||||
}
|
||||
// Step.4 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
//此处设置的filename无效 ,前端会重更新设置一下
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, title);
|
||||
mv.addObject(NormalExcelConstants.MAP_LIST, listMap);
|
||||
return mv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据权限导出excel,传入导出字段参数
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields) {
|
||||
ModelAndView mv = this.exportXls(request,object,clazz,title);
|
||||
mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getId(T item) {
|
||||
try {
|
||||
return PropertyUtils.getProperty(item, "id").toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
protected Result<?> importExcel(HttpServletRequest request, HttpServletResponse response, Class<T> clazz) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
|
||||
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
||||
long start = System.currentTimeMillis();
|
||||
service.saveBatch(list);
|
||||
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
||||
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
||||
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
//update-end-author:taoyan date:20190528 for:批量插入数据
|
||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||
String msg = e.getMessage();
|
||||
log.error(msg, e);
|
||||
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
|
||||
return Result.error("文件导入失败:有重复数据!");
|
||||
}else{
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
}
|
||||
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package digital.system.jeecg.group.base.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import digital.bean.jeecg.dto.LogDTO;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: BaseCommonMapper
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface BaseCommonMapper {
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@InterceptorIgnore(illegalSql = "true", tenantLine = "true")
|
||||
void saveLog(@Param("dto") LogDTO dto);
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="digital.system.jeecg.group.base.mapper.BaseCommonMapper">
|
||||
|
||||
<!-- 保存日志11 -->
|
||||
<insert id="saveLog">
|
||||
insert into sys_log (id, log_type, app_key, log_content, result, method, operate_type, request_param, ip,
|
||||
user_id,
|
||||
username,
|
||||
cost_time, create_time)
|
||||
values (#{dto.id,jdbcType=VARCHAR},
|
||||
#{dto.logType,jdbcType=INTEGER},
|
||||
#{dto.appKey,jdbcType=VARCHAR},
|
||||
#{dto.logContent,jdbcType=VARCHAR},
|
||||
#{dto.result,jdbcType=VARCHAR},
|
||||
#{dto.method,jdbcType=VARCHAR},
|
||||
#{dto.operateType,jdbcType=INTEGER},
|
||||
#{dto.requestParam,jdbcType=VARCHAR},
|
||||
#{dto.ip,jdbcType=VARCHAR},
|
||||
#{dto.userId,jdbcType=VARCHAR},
|
||||
#{dto.username,jdbcType=VARCHAR},
|
||||
#{dto.costTime,jdbcType=BIGINT},
|
||||
#{dto.createTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package digital.system.jeecg.group.base.service;
|
||||
|
||||
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.bean.jeecg.dto.LogDTO;
|
||||
|
||||
|
||||
/**
|
||||
* common接口
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface BaseCommonService {
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
* @param logDTO
|
||||
*/
|
||||
void addLog(LogDTO logDTO);
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
* @param logContent
|
||||
* @param logType
|
||||
* @param operateType
|
||||
* @param user
|
||||
*/
|
||||
void addLog(String logContent, Integer logType, Integer operateType, LoginUser user);
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
* @param logContent
|
||||
* @param logType
|
||||
* @param operateType
|
||||
*/
|
||||
void addLog(String logContent, Integer logType, Integer operateType);
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package digital.system.jeecg.group.base.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: Service基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-21 8:13
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface JeecgService<T> extends IService<T> {
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package digital.system.jeecg.group.base.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.bean.jeecg.dto.LogDTO;
|
||||
import digital.system.jeecg.group.base.mapper.BaseCommonMapper;
|
||||
import digital.system.jeecg.group.base.service.BaseCommonService;
|
||||
import digital.util.util.IpUtils;
|
||||
import digital.util.util.SpringContextUtils;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: common实现类
|
||||
* @author: smcp
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BaseCommonServiceImpl implements BaseCommonService {
|
||||
|
||||
@Autowired
|
||||
private BaseCommonMapper baseCommonMapper;
|
||||
|
||||
@Override
|
||||
public void addLog(LogDTO logDTO) {
|
||||
if(oConvertUtils.isEmpty(logDTO.getId())){
|
||||
logDTO.setId(String.valueOf(IdWorker.getId()));
|
||||
}
|
||||
//保存日志(异常捕获处理,防止数据太大存储失败,导致业务失败)JT-238
|
||||
try {
|
||||
baseCommonMapper.saveLog(logDTO);
|
||||
} catch (Exception e) {
|
||||
log.warn(" LogContent length : "+logDTO.getLogContent().length());
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLog(String logContent, Integer logType, Integer operatetype, LoginUser user) {
|
||||
LogDTO sysLog = new LogDTO();
|
||||
sysLog.setId(String.valueOf(IdWorker.getId()));
|
||||
//注解上的描述,操作日志内容
|
||||
sysLog.setLogContent(logContent);
|
||||
sysLog.setLogType(logType);
|
||||
sysLog.setOperateType(operatetype);
|
||||
try {
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IpUtils.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
sysLog.setIp("127.0.0.1");
|
||||
}
|
||||
//获取登录用户信息
|
||||
if(user==null){
|
||||
try {
|
||||
user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(user!=null){
|
||||
sysLog.setUserId(user.getUsername());
|
||||
sysLog.setUsername(user.getRealname());
|
||||
}
|
||||
sysLog.setCreateTime(new Date());
|
||||
//保存日志(异常捕获处理,防止数据太大存储失败,导致业务失败)JT-238
|
||||
try {
|
||||
baseCommonMapper.saveLog(sysLog);
|
||||
} catch (Exception e) {
|
||||
log.warn(" LogContent length : "+sysLog.getLogContent().length());
|
||||
log.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLog(String logContent, Integer logType, Integer operateType) {
|
||||
addLog(logContent, logType, operateType, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package digital.system.jeecg.group.base.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import digital.bean.jeecg.entity.JeecgEntity;
|
||||
import digital.system.jeecg.group.base.service.JeecgService;
|
||||
|
||||
/**
|
||||
* @Description: ServiceImpl基类
|
||||
* @Author: dangzhenghui@163.com
|
||||
* @Date: 2019-4-21 8:13
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class JeecgServiceImpl<M extends BaseMapper<T>, T extends JeecgEntity> extends ServiceImpl<M, T> implements JeecgService<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package digital.system.jeecg.group.config;
|
||||
|
||||
import digital.system.jeecg.group.CommonAPI;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecgframework.dict.service.AutoPoiDictServiceI;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.bean.jeecg.vo.DictModel;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:AutoPoi Excel注解支持字典参数设置
|
||||
* 举例: @Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
* 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
|
||||
* 2、导入的时候,会把男、女翻译成1,2存进数据库;
|
||||
*
|
||||
* @Author:scott
|
||||
* @since:2019-04-09
|
||||
* @Version:1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
||||
final static String EXCEL_SPLIT_TAG = "_";
|
||||
final static String TEMP_EXCEL_SPLIT_TAG = "---";
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private CommonAPI commonApi;
|
||||
|
||||
/**
|
||||
* 通过字典查询easypoi,所需字典文本
|
||||
*
|
||||
* @Author:scott
|
||||
* @since:2019-04-09
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String[] queryDict(String dicTable, String dicCode, String dicText) {
|
||||
List<String> dictReplaces = new ArrayList<String>();
|
||||
List<DictModel> dictList = null;
|
||||
// step.1 如果没有字典表则使用系统字典表
|
||||
if (oConvertUtils.isEmpty(dicTable)) {
|
||||
dictList = commonApi.queryDictItemsByCode(dicCode);
|
||||
} else {
|
||||
try {
|
||||
dicText = oConvertUtils.getString(dicText, dicCode);
|
||||
dictList = commonApi.queryTableDictItemsByCode(dicTable, dicText, dicCode);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (DictModel t : dictList) {
|
||||
if(t!=null){
|
||||
//update-begin---author:scott Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
|
||||
if(t.getValue().contains(EXCEL_SPLIT_TAG)){
|
||||
String val = t.getValue().replace(EXCEL_SPLIT_TAG,TEMP_EXCEL_SPLIT_TAG);
|
||||
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + val);
|
||||
}else{
|
||||
dictReplaces.add(t.getText() + EXCEL_SPLIT_TAG + t.getValue());
|
||||
}
|
||||
//update-end---author:20211220 Date:20211220 for:[issues/I4MBB3]@Excel dicText字段的值有下划线时,导入功能不能正确解析---
|
||||
}
|
||||
}
|
||||
if (dictReplaces != null && dictReplaces.size() != 0) {
|
||||
log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
|
||||
return dictReplaces.toArray(new String[dictReplaces.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package digital.system.jeecg.group.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import digital.base.constant.CacheConstant;
|
||||
import digital.system.jeecg.group.redis.receiver.RedisReceiver;
|
||||
import digital.system.jeecg.group.redis.writer.JeecgRedisCacheWriter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.constant.GlobalConstants;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.listener.ChannelTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
/**
|
||||
* 开启缓存支持
|
||||
* @author zyf
|
||||
* @Return:
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Resource
|
||||
private LettuceConnectionFactory lettuceConnectionFactory;
|
||||
|
||||
/**
|
||||
* RedisTemplate配置
|
||||
* @param lettuceConnectionFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
|
||||
log.info(" --- redis config init --- ");
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = jacksonSerializer();
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
|
||||
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
|
||||
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
|
||||
|
||||
// key序列化
|
||||
redisTemplate.setKeySerializer(stringSerializer);
|
||||
// value序列化
|
||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
// Hash key序列化
|
||||
redisTemplate.setHashKeySerializer(stringSerializer);
|
||||
// Hash value序列化
|
||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存配置管理器
|
||||
*
|
||||
* @param factory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public CacheManager cacheManager(LettuceConnectionFactory factory) {
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = jacksonSerializer();
|
||||
// 配置序列化(解决乱码的问题),并且配置缓存默认有效期 6小时
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(6));
|
||||
RedisCacheConfiguration redisCacheConfiguration = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer));
|
||||
//.disableCachingNullValues();
|
||||
|
||||
// 以锁写入的方式创建RedisCacheWriter对象
|
||||
//update-begin-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符*
|
||||
RedisCacheWriter writer = new JeecgRedisCacheWriter(factory, Duration.ofMillis(50L));
|
||||
//RedisCacheWriter.lockingRedisCacheWriter(factory);
|
||||
// 创建默认缓存配置对象
|
||||
/* 默认配置,设置缓存有效期 1小时*/
|
||||
//RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(1));
|
||||
// 自定义配置test:demo 的超时时间为 5分钟
|
||||
RedisCacheManager cacheManager = RedisCacheManager.builder(writer).cacheDefaults(redisCacheConfiguration)
|
||||
.withInitialCacheConfigurations(singletonMap(CacheConstant.SYS_DICT_TABLE_CACHE,
|
||||
RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(10)).disableCachingNullValues()
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer))))
|
||||
.withInitialCacheConfigurations(singletonMap(CacheConstant.TEST_DEMO_CACHE, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(5)).disableCachingNullValues()))
|
||||
.withInitialCacheConfigurations(singletonMap(CacheConstant.PLUGIN_MALL_RANKING, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(24)).disableCachingNullValues()))
|
||||
.withInitialCacheConfigurations(singletonMap(CacheConstant.PLUGIN_MALL_PAGE_LIST, RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(24)).disableCachingNullValues()))
|
||||
.transactionAware().build();
|
||||
//update-end-author:taoyan date:20210316 for:注解CacheEvict根据key删除redis支持通配符*
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* redis 监听配置
|
||||
*
|
||||
* @param redisConnectionFactory redis 配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisMessageListenerContainer redisContainer(RedisConnectionFactory redisConnectionFactory, RedisReceiver redisReceiver, MessageListenerAdapter commonListenerAdapter) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(redisConnectionFactory);
|
||||
container.addMessageListener(commonListenerAdapter, new ChannelTopic(GlobalConstants.REDIS_TOPIC_NAME));
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
MessageListenerAdapter commonListenerAdapter(RedisReceiver redisReceiver) {
|
||||
MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(redisReceiver, "onMessage");
|
||||
messageListenerAdapter.setSerializer(jacksonSerializer());
|
||||
return messageListenerAdapter;
|
||||
}
|
||||
|
||||
private Jackson2JsonRedisSerializer jacksonSerializer() {
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
||||
return jackson2JsonRedisSerializer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
package digital.system.jeecg.group.config;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
|
||||
import org.apache.shiro.mgt.DefaultSubjectDAO;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
//import org.crazycake.shiro.IRedisManager;
|
||||
//import org.crazycake.shiro.RedisCacheManager;
|
||||
//import org.crazycake.shiro.RedisClusterManager;
|
||||
//import org.crazycake.shiro.RedisManager;
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.env.Environment;
|
||||
//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
//import redis.clients.jedis.HostAndPort;
|
||||
//import redis.clients.jedis.JedisCluster;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.config.JeecgBaseConfig;
|
||||
import digital.config.shiro.filters.CustomShiroFilterFactoryBean;
|
||||
import digital.config.shiro.filters.JwtFilter;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import java.util.*;
|
||||
/**
|
||||
* @author: Scott
|
||||
* @date: 2018/2/7
|
||||
* @description: shiro 配置类
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
// @Resource
|
||||
// LettuceConnectionFactory lettuceConnectionFactory;
|
||||
@Autowired
|
||||
JeecgBaseConfig jeecgBaseConfig;
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Bean
|
||||
public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Chain定义说明
|
||||
* <p>
|
||||
* 1、一个URL可以配置多个Filter,使用逗号分隔
|
||||
* 2、当设置多个过滤器时,全部验证通过,才视为通过
|
||||
* 3、部分过滤器可指定参数,如perms,roles
|
||||
*/
|
||||
@Bean("shiroFilterFactoryBean")
|
||||
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
|
||||
CustomShiroFilterFactoryBean shiroFilterFactoryBean = new CustomShiroFilterFactoryBean();
|
||||
shiroFilterFactoryBean.setSecurityManager(securityManager);
|
||||
// 拦截器
|
||||
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
||||
String shiroExcludeUrls = jeecgBaseConfig.getShiro().getExcludeUrls();
|
||||
if (oConvertUtils.isNotEmpty(shiroExcludeUrls)) {
|
||||
String[] permissionUrl = shiroExcludeUrls.split(",");
|
||||
for (String url : permissionUrl) {
|
||||
filterChainDefinitionMap.put(url, "anon");
|
||||
}
|
||||
}
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
// filterChainDefinitionMap.put("/**/**", "anon"); //发验证码
|
||||
filterChainDefinitionMap.put("/api/cloth/submitContactInfo", "anon"); //提交公司信息
|
||||
filterChainDefinitionMap.put("/api/digital/sms", "anon"); //发验证码
|
||||
filterChainDefinitionMap.put("/api/digital/phoneLogin", "anon"); //登录
|
||||
filterChainDefinitionMap.put("/api/cloth/sms", "anon"); //发验证码
|
||||
filterChainDefinitionMap.put("/api/cloth/phoneLogin", "anon"); //登录
|
||||
filterChainDefinitionMap.put("/api/cloth/callBack", "anon"); //回调
|
||||
// filterChainDefinitionMap.put("/api/v1/clientSystem/queryByLanguageType/**", "anon"); //隐私协议
|
||||
filterChainDefinitionMap.put("/success.html", "anon"); //去掉token验证
|
||||
filterChainDefinitionMap.put("/sys/loginWithDiscord", "anon"); //c登录
|
||||
|
||||
//天津第三方接口
|
||||
filterChainDefinitionMap.put("/api/v1/getHairData", "anon"); //查询可以调用的发型数据
|
||||
filterChainDefinitionMap.put("/api/v1/swapHair", "anon"); //换发型
|
||||
filterChainDefinitionMap.put("/api/v1/getSwapHairHistoryByTaskId", "anon");
|
||||
filterChainDefinitionMap.put("/api/v1/getSwapHairHistory", "anon"); //查看换发结果数据
|
||||
|
||||
// 第二家公司第三方接口
|
||||
filterChainDefinitionMap.put("/api/v1/querySwapHairHistory", "anon"); //查看所有历史换发型结果
|
||||
filterChainDefinitionMap.put("/api/v1/queryHairData", "anon"); //查询可以调用的发型数据
|
||||
filterChainDefinitionMap.put("/api/v1/getTargetTryOnHistory", "anon"); //查看历史数据
|
||||
filterChainDefinitionMap.put("/api/v1/swapHairAsync", "anon"); //换发型
|
||||
|
||||
filterChainDefinitionMap.put("/zitaTask/savePictureTaskInfo", "anon"); //task 场景1:保存生成图片和模型结果
|
||||
filterChainDefinitionMap.put("/zitaTask/addPictureTaskInfo", "anon"); //task 场景1:生成图片和模型结果
|
||||
|
||||
filterChainDefinitionMap.put("/zitaTask/addVideoTaskInfo", "anon"); //task 场景2:生成视频任务
|
||||
filterChainDefinitionMap.put("/zitaTask/saveVideoTaskInfo", "anon"); //task 场景2:保存生成图片和模型结果
|
||||
filterChainDefinitionMap.put("/zitaTask/queryModelId", "anon"); //任务管理-根据 taskId 查 modelId
|
||||
|
||||
filterChainDefinitionMap.put("/zitaPayment/webhook", "anon"); // 回调
|
||||
|
||||
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/api/v1/clientLogin/randomImage/**", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/api/v1/clientLogin/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
|
||||
filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
|
||||
filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
|
||||
filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
|
||||
filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
|
||||
filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
|
||||
filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
|
||||
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
|
||||
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
|
||||
filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
|
||||
filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
|
||||
|
||||
filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
|
||||
filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
|
||||
filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
|
||||
|
||||
|
||||
filterChainDefinitionMap.put("/", "anon");
|
||||
filterChainDefinitionMap.put("/doc.html", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.js", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.css", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.html", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.svg", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.pdf", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.jpg", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.png", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.ico", "anon");
|
||||
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
filterChainDefinitionMap.put("/**/*.ttf", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
|
||||
filterChainDefinitionMap.put("/druid/**", "anon");
|
||||
filterChainDefinitionMap.put("/swagger-ui.html", "anon");
|
||||
filterChainDefinitionMap.put("/swagger**/**", "anon");
|
||||
filterChainDefinitionMap.put("/webjars/**", "anon");
|
||||
filterChainDefinitionMap.put("/v2/**", "anon");
|
||||
|
||||
filterChainDefinitionMap.put("/sys/annountCement/show/**", "anon");
|
||||
|
||||
//积木报表排除
|
||||
filterChainDefinitionMap.put("/jmreport/**", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.js.map", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.css.map", "anon");
|
||||
|
||||
//测试示例
|
||||
filterChainDefinitionMap.put("/test/bigScreen/**", "anon"); //大屏模板例子
|
||||
//filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
|
||||
//filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
|
||||
//filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
|
||||
|
||||
//websocket排除
|
||||
filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告
|
||||
filterChainDefinitionMap.put("/newsWebsocket/**", "anon");//CMS模块
|
||||
filterChainDefinitionMap.put("/vxeSocket/**", "anon");//JVxeTable无痕刷新示例
|
||||
|
||||
//wps
|
||||
filterChainDefinitionMap.put("/v1/**", "anon");
|
||||
|
||||
//性能监控 TODO 存在安全漏洞泄露TOEKN(durid连接池也有)
|
||||
filterChainDefinitionMap.put("/actuator/**", "anon");
|
||||
|
||||
//测试模块排除
|
||||
filterChainDefinitionMap.put("/test/seata/**", "anon");
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
||||
//如果cloudServer为空 则说明是单体 需要加载跨域配置【微服务跨域切换】
|
||||
Object cloudServer = env.getProperty(CommonConstant.CLOUD_SERVER_KEY);
|
||||
filterMap.put("jwt", new JwtFilter(cloudServer == null));
|
||||
shiroFilterFactoryBean.setFilters(filterMap);
|
||||
// <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
|
||||
filterChainDefinitionMap.put("/**", "jwt");
|
||||
|
||||
// 未授权界面返回JSON
|
||||
shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
|
||||
shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
|
||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
|
||||
return shiroFilterFactoryBean;
|
||||
}
|
||||
|
||||
@Bean("securityManager")
|
||||
public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
|
||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||
securityManager.setRealm(myRealm);
|
||||
|
||||
/*
|
||||
* 关闭shiro自带的session,详情见文档
|
||||
* http://shiro.apache.org/session-management.html#SessionManagement-
|
||||
* StatelessApplications%28Sessionless%29
|
||||
*/
|
||||
DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
|
||||
DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
|
||||
defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
|
||||
subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
|
||||
securityManager.setSubjectDAO(subjectDAO);
|
||||
//自定义缓存实现,使用redis
|
||||
// securityManager.setCacheManager(redisCacheManager());
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下面的代码是添加注解支持
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@DependsOn("lifecycleBeanPostProcessor")
|
||||
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
|
||||
DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
|
||||
defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
|
||||
/**
|
||||
* 解决重复代理问题 github#994
|
||||
* 添加前缀判断 不匹配 任何Advisor
|
||||
*/
|
||||
defaultAdvisorAutoProxyCreator.setUsePrefix(true);
|
||||
defaultAdvisorAutoProxyCreator.setAdvisorBeanNamePrefix("_no_advisor");
|
||||
return defaultAdvisorAutoProxyCreator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(DefaultWebSecurityManager securityManager) {
|
||||
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
|
||||
advisor.setSecurityManager(securityManager);
|
||||
return advisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* cacheManager 缓存 redis实现
|
||||
* 使用的是shiro-redis开源插件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// public RedisCacheManager redisCacheManager() {
|
||||
// log.info("===============(1)创建缓存管理器RedisCacheManager");
|
||||
// RedisCacheManager redisCacheManager = new RedisCacheManager();
|
||||
// redisCacheManager.setRedisManager(redisManager());
|
||||
// //redis中针对不同用户缓存(此处的id需要对应user实体中的id字段,用于唯一标识)
|
||||
// redisCacheManager.setPrincipalIdFieldName("id");
|
||||
// //用户权限信息缓存时间
|
||||
// redisCacheManager.setExpire(200000);
|
||||
// return redisCacheManager;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 配置shiro redisManager
|
||||
* 使用的是shiro-redis开源插件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// @Bean
|
||||
// public IRedisManager redisManager() {
|
||||
// log.info("===============(2)创建RedisManager,连接Redis..");
|
||||
// IRedisManager manager;
|
||||
// // redis 单机支持,在集群为空,或者集群无机器时候使用 add by jzyadmin@163.com
|
||||
// if (lettuceConnectionFactory.getClusterConfiguration() == null || lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().isEmpty()) {
|
||||
// RedisManager redisManager = new RedisManager();
|
||||
// redisManager.setHost(lettuceConnectionFactory.getHostName());
|
||||
// redisManager.setPort(lettuceConnectionFactory.getPort());
|
||||
// redisManager.setDatabase(lettuceConnectionFactory.getDatabase());
|
||||
// redisManager.setTimeout(0);
|
||||
// if (!StringUtils.isEmpty(lettuceConnectionFactory.getPassword())) {
|
||||
// redisManager.setPassword(lettuceConnectionFactory.getPassword());
|
||||
// }
|
||||
// manager = redisManager;
|
||||
// } else {
|
||||
// // redis集群支持,优先使用集群配置
|
||||
// RedisClusterManager redisManager = new RedisClusterManager();
|
||||
// Set<HostAndPort> portSet = new HashSet<>();
|
||||
// lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().forEach(node -> portSet.add(new HostAndPort(node.getHost(), node.getPort())));
|
||||
// //update-begin--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
|
||||
// if (oConvertUtils.isNotEmpty(lettuceConnectionFactory.getPassword())) {
|
||||
// JedisCluster jedisCluster = new JedisCluster(portSet, 2000, 2000, 5,
|
||||
// lettuceConnectionFactory.getPassword(), new GenericObjectPoolConfig());
|
||||
// redisManager.setPassword(lettuceConnectionFactory.getPassword());
|
||||
// redisManager.setJedisCluster(jedisCluster);
|
||||
// } else {
|
||||
// JedisCluster jedisCluster = new JedisCluster(portSet);
|
||||
// redisManager.setJedisCluster(jedisCluster);
|
||||
// }
|
||||
// //update-end--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
|
||||
// manager = redisManager;
|
||||
// }
|
||||
// return manager;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package digital.system.jeecg.group.config;
|
||||
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.config.shiro.JwtToken;
|
||||
import digital.system.jeecg.group.CommonAPI;
|
||||
import digital.util.util.JeecgRedisUtil;
|
||||
import digital.util.util.JwtUtil;
|
||||
import digital.util.util.SpringContextUtils;
|
||||
import digital.util.util.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description: 用户登录鉴权和获取用户授权
|
||||
* @Author: Scott
|
||||
* @Date: 2019-4-23 8:13
|
||||
* @Version: 1.1
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ShiroRealm extends AuthorizingRealm {
|
||||
@Lazy
|
||||
@Resource
|
||||
private CommonAPI commonApi;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
private JeecgRedisUtil jeecgRedisUtil;
|
||||
|
||||
/**
|
||||
* 必须重写此方法,不然Shiro会报错
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(AuthenticationToken token) {
|
||||
return token instanceof JwtToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限信息认证(包括角色以及权限)是用户访问controller的时候才进行验证(redis存储的此处权限信息)
|
||||
* 触发检测用户权限时才会调用此方法,例如checkRole,checkPermission
|
||||
*
|
||||
* @param principals 身份信息
|
||||
* @return AuthorizationInfo 权限信息
|
||||
*/
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
log.debug("===============Shiro权限认证开始============ [ roles、permissions]==========");
|
||||
String username = null;
|
||||
if (principals != null) {
|
||||
LoginUser sysUser = (LoginUser) principals.getPrimaryPrincipal();
|
||||
username = sysUser.getUsername();
|
||||
}
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
|
||||
// 设置用户拥有的角色集合,比如“admin,test”
|
||||
Set<String> roleSet = commonApi.queryUserRoles(username);
|
||||
System.out.println(roleSet.toString());
|
||||
info.setRoles(roleSet);
|
||||
|
||||
// 设置用户拥有的权限集合,比如“sys:role:add,sys:user:add”
|
||||
Set<String> permissionSet = commonApi.queryUserAuths(username);
|
||||
info.addStringPermissions(permissionSet);
|
||||
System.out.println(permissionSet);
|
||||
log.debug("===============Shiro权限认证成功==============");
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息认证是在用户进行登录的时候进行验证(不存redis)
|
||||
* 也就是说验证用户输入的账号和密码是否正确,错误抛出异常
|
||||
*
|
||||
* @param auth 用户登录的账号密码信息
|
||||
* @return 返回封装了用户信息的 AuthenticationInfo 实例
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
@Override
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
|
||||
log.debug("===============Shiro身份认证开始============doGetAuthenticationInfo==========");
|
||||
String token = (String) auth.getCredentials();
|
||||
if (token == null) {
|
||||
HttpServletRequest req = SpringContextUtils.getHttpServletRequest();
|
||||
log.debug("————————身份认证失败——————————IP地址: " + oConvertUtils.getIpAddrByRequest(req) + ",URL:" + req.getRequestURI());
|
||||
throw new AuthenticationException("token为空!");
|
||||
}
|
||||
// 校验token有效性
|
||||
LoginUser loginUser = null;
|
||||
try {
|
||||
loginUser = this.checkUserTokenIsEffect(token);
|
||||
} catch (AuthenticationException e) {
|
||||
JwtUtil.responseError(SpringContextUtils.getHttpServletResponse(),401,e.getMessage());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return new SimpleAuthenticationInfo(loginUser, token, getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验token的有效性
|
||||
*
|
||||
* @param token
|
||||
*/
|
||||
public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
|
||||
// 解密获得username,用于和数据库进行对比
|
||||
String username = JwtUtil.getUsername(token);
|
||||
if (username == null) {
|
||||
throw new AuthenticationException("token非法无效!");
|
||||
}
|
||||
|
||||
// 查询用户信息
|
||||
log.debug("———校验token是否有效————checkUserTokenIsEffect——————— " + token);
|
||||
// LoginUser loginUser = TokenUtils.getLoginUser(username,commonApi, jeecgRedisUtil);
|
||||
LoginUser loginUser = commonApi.getUserByName(username);
|
||||
if (loginUser == null) {
|
||||
throw new AuthenticationException("用户不存在!");
|
||||
}
|
||||
// 判断用户状态
|
||||
// if (loginUser.getStatus() != 1) {
|
||||
// throw new AuthenticationException("账号已被锁定,请联系管理员!");
|
||||
// }
|
||||
// 校验token是否超时失效 & 或者账号密码是否错误
|
||||
if (!jwtTokenRefresh(token, username, loginUser.getPassword())) {
|
||||
throw new AuthenticationException(CommonConstant.TOKEN_IS_INVALID_MSG);
|
||||
}
|
||||
//update-begin-author:taoyan date:20210609 for:校验用户的tenant_id和前端传过来的是否一致
|
||||
// String userTenantIds = loginUser.getRelTenantIds();
|
||||
// if(oConvertUtils.isNotEmpty(userTenantIds)){
|
||||
// String contextTenantId = TenantContext.getTenant();
|
||||
// String str ="0";
|
||||
// if(oConvertUtils.isNotEmpty(contextTenantId) && !str.equals(contextTenantId)){
|
||||
// //update-begin-author:taoyan date:20211227 for: /issues/I4O14W 用户租户信息变更判断漏洞
|
||||
// String[] arr = userTenantIds.split(",");
|
||||
// if(!oConvertUtils.isIn(contextTenantId, arr)){
|
||||
// throw new AuthenticationException("用户租户信息变更,请重新登陆!");
|
||||
// }
|
||||
// //update-end-author:taoyan date:20211227 for: /issues/I4O14W 用户租户信息变更判断漏洞
|
||||
// }
|
||||
// }
|
||||
//update-end-author:taoyan date:20210609 for:校验用户的tenant_id和前端传过来的是否一致
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* JWTToken刷新生命周期 (实现: 用户在线操作不掉线功能)
|
||||
* 1、登录成功后将用户的JWT生成的Token作为k、v存储到cache缓存里面(这时候k、v值一样),缓存有效期设置为Jwt有效时间的2倍
|
||||
* 2、当该用户再次请求时,通过JWTFilter层层校验之后会进入到doGetAuthenticationInfo进行身份验证
|
||||
* 3、当该用户这次请求jwt生成的token值已经超时,但该token对应cache中的k还是存在,则表示该用户一直在操作只是JWT的token失效了,程序会给token对应的k映射的v值重新生成JWTToken并覆盖v值,该缓存生命周期重新计算
|
||||
* 4、当该用户这次请求jwt在生成的token值已经超时,并在cache中不存在对应的k,则表示该用户账户空闲超时,返回用户信息已失效,请重新登录。
|
||||
* 注意: 前端请求Header中设置Authorization保持不变,校验有效性以缓存中的token为准。
|
||||
* 用户过期时间 = Jwt有效时间 * 2。
|
||||
*
|
||||
* @param userName
|
||||
* @param passWord
|
||||
* @return
|
||||
*/
|
||||
public boolean jwtTokenRefresh(String token, String userName, String passWord) {
|
||||
String cacheToken = String.valueOf(jeecgRedisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token));
|
||||
if (oConvertUtils.isNotEmpty(cacheToken)) {
|
||||
// 校验token有效性
|
||||
if (!JwtUtil.verify(cacheToken, userName, passWord)) {
|
||||
String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||
// 设置超时时间
|
||||
jeecgRedisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
||||
jeecgRedisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME *2 / 1000);
|
||||
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
|
||||
}
|
||||
//update-begin--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题
|
||||
// else {
|
||||
// // 设置超时时间
|
||||
// redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken);
|
||||
// redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
|
||||
// }
|
||||
//update-end--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题
|
||||
return true;
|
||||
}
|
||||
|
||||
//redis中不存在此TOEKN,说明token非法返回false
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除当前用户的权限认证缓存
|
||||
*
|
||||
* @param principals 权限信息
|
||||
*/
|
||||
@Override
|
||||
public void clearCache(PrincipalCollection principals) {
|
||||
super.clearCache(principals);
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//package org.jeecg.modules.ngalain.aop;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
//import org.aspectj.lang.ProceedingJoinPoint;
|
||||
//import org.aspectj.lang.annotation.Around;
|
||||
//import org.aspectj.lang.annotation.Aspect;
|
||||
//import org.aspectj.lang.annotation.Pointcut;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.web.context.request.RequestAttributes;
|
||||
//import org.springframework.web.context.request.RequestContextHolder;
|
||||
//import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;;
|
||||
//
|
||||
//
|
||||
//// 暂时注释掉,提高系统性能
|
||||
////@Aspect //定义一个切面
|
||||
////@Configuration
|
||||
//public class LogRecordAspect {
|
||||
//private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.class);
|
||||
//
|
||||
// // 定义切点Pointcut
|
||||
// @Pointcut("execution(public * org.jeecg.modules.*.*.*Controller.*(..))")
|
||||
// public void excudeService() {
|
||||
// }
|
||||
//
|
||||
// @Around("excudeService()")
|
||||
// public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
|
||||
// RequestAttributes ra = RequestContextHolder.getRequestAttributes();
|
||||
// ServletRequestAttributes sra = (ServletRequestAttributes) ra;
|
||||
// HttpServletRequest request = sra.getRequest();
|
||||
//
|
||||
// String url = request.getRequestURL().toString();
|
||||
// String method = request.getMethod();
|
||||
// String uri = request.getRequestURI();
|
||||
// String queryString = request.getQueryString();
|
||||
// logger.info("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}", url, method, uri, queryString);
|
||||
//
|
||||
// // result的值就是被拦截方法的返回值
|
||||
// Object result = pjp.proceed();
|
||||
//
|
||||
// logger.info("请求结束,controller的返回值是 " + result);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
//package org.jeecg.modules.ngalain.controller;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//
|
||||
//
|
||||
//
|
||||
//import org.jeecg.modules.ngalain.service.NgAlainService;
|
||||
//import org.jeecg.modules.system.service.ISysDictService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.PathVariable;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/ng-alain")
|
||||
//public class NgAlainController {
|
||||
// @Autowired
|
||||
// private NgAlainService ngAlainService;
|
||||
// @Autowired
|
||||
// private ISysDictService sysDictService;
|
||||
//
|
||||
// @RequestMapping(value = "/getAppData")
|
||||
// @ResponseBody
|
||||
// public JSONObject getAppData(HttpServletRequest request) throws Exception {
|
||||
// String token=request.getHeader("X-Access-Token");
|
||||
// JSONObject j = new JSONObject();
|
||||
// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// JSONObject userObjcet = new JSONObject();
|
||||
// userObjcet.put("name", user.getUsername());
|
||||
// userObjcet.put("avatar", user.getAvatar());
|
||||
// userObjcet.put("email", user.getEmail());
|
||||
// userObjcet.put("token", token);
|
||||
// j.put("user", userObjcet);
|
||||
// j.put("menu",ngAlainService.getMenu(user.getUsername()));
|
||||
// JSONObject app = new JSONObject();
|
||||
// app.put("name", "smcp-angular");
|
||||
// app.put("description", "jeecg+ng-alain整合版本");
|
||||
// j.put("app", app);
|
||||
// return j;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
// public Object getDictItems(@PathVariable String dictCode) {
|
||||
// log.info(" dictCode : "+ dictCode);
|
||||
// Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
// List<DictModel> ls = null;
|
||||
// try {
|
||||
// ls = sysDictService.queryDictItemsByCode(dictCode);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(ls);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(),e);
|
||||
// result.error500("操作失败");
|
||||
// return result;
|
||||
// }
|
||||
// List<JSONObject> dictlist=new ArrayList<>();
|
||||
// for (DictModel l : ls) {
|
||||
// JSONObject dict=new JSONObject();
|
||||
// try {
|
||||
// dict.put("value",Integer.parseInt(l.getValue()));
|
||||
// } catch (NumberFormatException e) {
|
||||
// dict.put("value",l.getValue());
|
||||
// }
|
||||
// dict.put("label",l.getText());
|
||||
// dictlist.add(dict);
|
||||
// }
|
||||
// return dictlist;
|
||||
// }
|
||||
// @RequestMapping(value = "/getDictItemsByTable/{table}/{key}/{value}", method = RequestMethod.GET)
|
||||
// public Object getDictItemsByTable(@PathVariable String table,@PathVariable String key,@PathVariable String value) {
|
||||
// return this.ngAlainService.getDictByTable(table,key,value);
|
||||
// }
|
||||
//}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package digital.system.jeecg.group.ngalain.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: NgAlainService接口
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface NgAlainService {
|
||||
/**
|
||||
* 菜单
|
||||
*
|
||||
* @param id
|
||||
* @return JSONArray
|
||||
* @throws Exception
|
||||
*/
|
||||
public JSONArray getMenu(String id) throws Exception;
|
||||
|
||||
/**
|
||||
* jeecg菜单
|
||||
*
|
||||
* @param id
|
||||
* @return JSONArray
|
||||
* @throws Exception
|
||||
*/
|
||||
public JSONArray getJeecgMenu(String id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param table
|
||||
* @param key
|
||||
* @param value
|
||||
* @return List<Map < String, String>>
|
||||
*/
|
||||
public List<Map<String, String>> getDictByTable(String table, String key, String value);
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package digital.system.jeecg.group.ngalain.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.system.jeecg.group.ngalain.service.NgAlainService;
|
||||
import digital.system.jeecg.system.entity.SysPermission;
|
||||
import digital.system.jeecg.system.mapper.SysDictMapper;
|
||||
import digital.system.jeecg.system.service.ISysPermissionService;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: NgAlainServiceImpl 实现类
|
||||
* @author: smcp
|
||||
*/
|
||||
@Service("ngAlainService")
|
||||
public class NgAlainServiceImpl implements NgAlainService {
|
||||
@Autowired
|
||||
private ISysPermissionService sysPermissionService;
|
||||
@Autowired
|
||||
private SysDictMapper mapper;
|
||||
|
||||
@Override
|
||||
public JSONArray getMenu(String id) throws Exception {
|
||||
return getJeecgMenu(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getJeecgMenu(String id) throws Exception {
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(id);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
getPermissionJsonArray(jsonArray, metaList, null);
|
||||
JSONArray menulist = parseNgAlain(jsonArray);
|
||||
JSONObject jeecgMenu = new JSONObject();
|
||||
jeecgMenu.put("text", "jeecg菜单");
|
||||
jeecgMenu.put("group", true);
|
||||
jeecgMenu.put("children", menulist);
|
||||
JSONArray jeecgMenuList = new JSONArray();
|
||||
jeecgMenuList.add(jeecgMenu);
|
||||
return jeecgMenuList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getDictByTable(String table, String key, String value) {
|
||||
return this.mapper.getDictByTableNgAlain(table, key, value);
|
||||
}
|
||||
|
||||
private JSONArray parseNgAlain(JSONArray jsonArray) {
|
||||
JSONArray menulist = new JSONArray();
|
||||
for (Object object : jsonArray) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
String path = (String) jsonObject.get("path");
|
||||
JSONObject meta = (JSONObject) jsonObject.get("meta");
|
||||
JSONObject menu = new JSONObject();
|
||||
menu.put("text", meta.get("title"));
|
||||
menu.put("reuse", true);
|
||||
if (jsonObject.get("children") != null) {
|
||||
JSONArray child = parseNgAlain((JSONArray) jsonObject.get("children"));
|
||||
menu.put("children", child);
|
||||
JSONObject icon = new JSONObject();
|
||||
icon.put("type", "icon");
|
||||
icon.put("value", meta.get("icon"));
|
||||
menu.put("icon", icon);
|
||||
} else {
|
||||
menu.put("link", path);
|
||||
}
|
||||
menulist.add(menu);
|
||||
}
|
||||
return menulist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单JSON数组
|
||||
*
|
||||
* @param jsonArray
|
||||
* @param metaList
|
||||
* @param parentJson
|
||||
*/
|
||||
private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson) {
|
||||
for (SysPermission permission : metaList) {
|
||||
if (permission.getMenuType() == null) {
|
||||
continue;
|
||||
}
|
||||
String tempPid = permission.getParentId();
|
||||
JSONObject json = getPermissionJsonObject(permission);
|
||||
if (parentJson == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
jsonArray.add(json);
|
||||
if (!permission.isLeaf()) {
|
||||
getPermissionJsonArray(jsonArray, metaList, json);
|
||||
}
|
||||
} else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
|
||||
if (permission.getMenuType() == 0) {
|
||||
JSONObject metaJson = parentJson.getJSONObject("meta");
|
||||
if (metaJson.containsKey("permissionList")) {
|
||||
metaJson.getJSONArray("permissionList").add(json);
|
||||
} else {
|
||||
JSONArray permissionList = new JSONArray();
|
||||
permissionList.add(json);
|
||||
metaJson.put("permissionList", permissionList);
|
||||
}
|
||||
|
||||
} else if (permission.getMenuType() == 1) {
|
||||
if (parentJson.containsKey("children")) {
|
||||
parentJson.getJSONArray("children").add(json);
|
||||
} else {
|
||||
JSONArray children = new JSONArray();
|
||||
children.add(json);
|
||||
parentJson.put("children", children);
|
||||
}
|
||||
|
||||
if (!permission.isLeaf()) {
|
||||
getPermissionJsonArray(jsonArray, metaList, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject getPermissionJsonObject(SysPermission permission) {
|
||||
JSONObject json = new JSONObject();
|
||||
//类型(0:一级菜单 1:子菜单 2:按钮)
|
||||
if (permission.getMenuType() == 2) {
|
||||
json.put("action", permission.getPerms());
|
||||
json.put("describe", permission.getName());
|
||||
} else if (permission.getMenuType() == 0 || permission.getMenuType() == 1) {
|
||||
json.put("id", permission.getId());
|
||||
if (permission.getUrl() != null && (permission.getUrl().startsWith("http://") || permission.getUrl().startsWith("https://"))) {
|
||||
String url = new String(Base64.getUrlEncoder().encode(permission.getUrl().getBytes()));
|
||||
json.put("path", "/sys/link/" + url.replaceAll("=", ""));
|
||||
} else {
|
||||
json.put("path", permission.getUrl());
|
||||
}
|
||||
|
||||
//重要规则:路由name (通过URL生成路由name,路由name供前端开发,页面跳转使用)
|
||||
json.put("name", urlToRouteName(permission.getUrl()));
|
||||
|
||||
//是否隐藏路由,默认都是显示的
|
||||
if (permission.isHidden()) {
|
||||
json.put("hidden", true);
|
||||
}
|
||||
//聚合路由
|
||||
if (permission.isAlwaysShow()) {
|
||||
json.put("alwaysShow", true);
|
||||
}
|
||||
json.put("component", permission.getComponent());
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.put("title", permission.getName());
|
||||
if (oConvertUtils.isEmpty(permission.getParentId())) {
|
||||
//一级菜单跳转地址
|
||||
json.put("redirect", permission.getRedirect());
|
||||
meta.put("icon", oConvertUtils.getString(permission.getIcon(), ""));
|
||||
} else {
|
||||
meta.put("icon", oConvertUtils.getString(permission.getIcon(), ""));
|
||||
}
|
||||
if (permission.getUrl() != null && (permission.getUrl().startsWith("http://") || permission.getUrl().startsWith("https://"))) {
|
||||
meta.put("url", permission.getUrl());
|
||||
}
|
||||
json.put("meta", meta);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过URL生成路由name(去掉URL前缀斜杠,替换内容中的斜杠‘/’为-)
|
||||
* 举例: URL = /isystem/role
|
||||
* RouteName = isystem-role
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String urlToRouteName(String url) {
|
||||
if (oConvertUtils.isNotEmpty(url)) {
|
||||
if (url.startsWith("/")) {
|
||||
url = url.substring(1);
|
||||
}
|
||||
url = url.replace("/", "-");
|
||||
return url;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package digital.system.jeecg.group.query;
|
||||
|
||||
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
/**
|
||||
* 查询链接规则
|
||||
*
|
||||
* @Author Sunjianlei
|
||||
*/
|
||||
public enum MatchTypeEnum {
|
||||
|
||||
/**
|
||||
* 查询链接规则 AND
|
||||
*/
|
||||
AND("AND"),
|
||||
/**查询链接规则 OR*/
|
||||
OR("OR");
|
||||
|
||||
private String value;
|
||||
|
||||
MatchTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MatchTypeEnum getByValue(Object value) {
|
||||
if (oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
return getByValue(value.toString());
|
||||
}
|
||||
|
||||
public static MatchTypeEnum getByValue(String value) {
|
||||
if (oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
for (MatchTypeEnum val : values()) {
|
||||
if (val.getValue().toLowerCase().equals(value.toLowerCase())) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package digital.system.jeecg.group.query;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: QueryCondition
|
||||
* @author: smcp
|
||||
*/
|
||||
public class QueryCondition implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4740166316629191651L;
|
||||
|
||||
private String field;
|
||||
/** 组件的类型(例如:input、select、radio) */
|
||||
private String type;
|
||||
/**
|
||||
* 对应的数据库字段的类型
|
||||
* 支持:int、bigDecimal、short、long、float、double、boolean
|
||||
*/
|
||||
private String dbType;
|
||||
private String rule;
|
||||
private String val;
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDbType() {
|
||||
return dbType;
|
||||
}
|
||||
|
||||
public void setDbType(String dbType) {
|
||||
this.dbType = dbType;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(String rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public void setVal(String val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuffer sb =new StringBuffer();
|
||||
if(field == null || "".equals(field)){
|
||||
return "";
|
||||
}
|
||||
sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.dbType).append(" ").append(this.val);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,88 @@
|
||||
package digital.system.jeecg.group.query;
|
||||
|
||||
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
/**
|
||||
* Query 规则 常量
|
||||
*
|
||||
* @Author Scott
|
||||
* @Date 2019年02月14日
|
||||
*/
|
||||
public enum QueryRuleEnum {
|
||||
|
||||
/**查询规则 大于*/
|
||||
GT(">", "gt", "大于"),
|
||||
/**查询规则 大于等于*/
|
||||
GE(">=","ge","大于等于"),
|
||||
/**查询规则 小于*/
|
||||
LT("<","lt","小于"),
|
||||
/**查询规则 小于等于*/
|
||||
LE("<=","le","小于等于"),
|
||||
/**查询规则 等于*/
|
||||
EQ("=","eq","等于"),
|
||||
/**查询规则 不等于*/
|
||||
NE("!=","ne","不等于"),
|
||||
/**查询规则 包含*/
|
||||
IN("IN","in","包含"),
|
||||
/**查询规则 全模糊*/
|
||||
LIKE("LIKE","like","全模糊"),
|
||||
/**查询规则 左模糊*/
|
||||
LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
|
||||
/**查询规则 右模糊*/
|
||||
RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),
|
||||
/**查询规则 带加号等于*/
|
||||
EQ_WITH_ADD("EQWITHADD","eq_with_add","带加号等于"),
|
||||
/**查询规则 多词模糊匹配*/
|
||||
LIKE_WITH_AND("LIKEWITHAND","like_with_and","多词模糊匹配————暂时未用上"),
|
||||
/**查询规则 自定义SQL片段*/
|
||||
SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段");
|
||||
|
||||
private String value;
|
||||
|
||||
private String condition;
|
||||
|
||||
private String msg;
|
||||
|
||||
QueryRuleEnum(String value, String condition, String msg){
|
||||
this.value = value;
|
||||
this.condition = condition;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public static QueryRuleEnum getByValue(String value){
|
||||
if(oConvertUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
for(QueryRuleEnum val :values()){
|
||||
if (val.getValue().equals(value) || val.getCondition().equals(value)){
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package digital.system.jeecg.group.redis.client;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import digital.base.constant.GlobalConstants;
|
||||
import digital.bean.jeecg.BaseMap;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description: redis客户端
|
||||
* @author: scott
|
||||
* @date: 2020/01/01 16:01
|
||||
*/
|
||||
@Configuration
|
||||
public class JeecgRedisClient {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param handlerName
|
||||
* @param params
|
||||
*/
|
||||
public void sendMessage(String handlerName, BaseMap params) {
|
||||
// params.put(GlobalConstants.HANDLER_NAME, handlerName);
|
||||
// redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package digital.system.jeecg.group.redis.listener;
|
||||
|
||||
|
||||
import digital.bean.jeecg.BaseMap;
|
||||
|
||||
/**
|
||||
* @Description: 自定义消息监听
|
||||
* @author: scott
|
||||
* @date: 2020/01/01 16:02
|
||||
*/
|
||||
public interface JeecgRedisListener {
|
||||
/**
|
||||
* 接受消息
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
void onMessage(BaseMap message);
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package digital.system.jeecg.group.redis.receiver;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.Data;
|
||||
import org.springframework.stereotype.Component;
|
||||
import digital.base.constant.GlobalConstants;
|
||||
import digital.bean.jeecg.BaseMap;
|
||||
import digital.system.jeecg.group.redis.listener.JeecgRedisListener;
|
||||
import digital.util.util.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* @author zyf
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
public class RedisReceiver {
|
||||
|
||||
|
||||
/**
|
||||
* 接受消息并调用业务逻辑处理器
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
public void onMessage(BaseMap params) {
|
||||
Object handlerName = params.get(GlobalConstants.HANDLER_NAME);
|
||||
JeecgRedisListener messageListener = SpringContextHolder.getHandler(handlerName.toString(), JeecgRedisListener.class);
|
||||
if (ObjectUtil.isNotEmpty(messageListener)) {
|
||||
messageListener.onMessage(params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
package digital.system.jeecg.group.redis.writer;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.PessimisticLockingFailureException;
|
||||
import org.springframework.data.redis.cache.CacheStatistics;
|
||||
import org.springframework.data.redis.cache.CacheStatisticsCollector;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 该类参照 DefaultRedisCacheWriter 重写了 remove 方法实现通配符*删除
|
||||
*
|
||||
* @author: scott
|
||||
* @date: 2020/01/01 16:18
|
||||
*/
|
||||
@Slf4j
|
||||
public class JeecgRedisCacheWriter implements RedisCacheWriter {
|
||||
|
||||
private final RedisConnectionFactory connectionFactory;
|
||||
private final Duration sleepTime;
|
||||
|
||||
public JeecgRedisCacheWriter(RedisConnectionFactory connectionFactory) {
|
||||
this(connectionFactory, Duration.ZERO);
|
||||
}
|
||||
|
||||
public JeecgRedisCacheWriter(RedisConnectionFactory connectionFactory, Duration sleepTime) {
|
||||
Assert.notNull(connectionFactory, "ConnectionFactory must not be null!");
|
||||
Assert.notNull(sleepTime, "SleepTime must not be null!");
|
||||
this.connectionFactory = connectionFactory;
|
||||
this.sleepTime = sleepTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
Assert.notNull(value, "Value must not be null!");
|
||||
this.execute(name, (connection) -> {
|
||||
if (shouldExpireWithin(ttl)) {
|
||||
connection.set(key, value, Expiration.from(ttl.toMillis(), TimeUnit.MILLISECONDS), SetOption.upsert());
|
||||
} else {
|
||||
connection.set(key, value);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] get(String name, byte[] key) {
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
return (byte[])this.execute(name, (connection) -> {
|
||||
return connection.get(key);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
Assert.notNull(value, "Value must not be null!");
|
||||
return (byte[])this.execute(name, (connection) -> {
|
||||
if (this.isLockingCacheWriter()) {
|
||||
this.doLock(name, connection);
|
||||
}
|
||||
|
||||
Object var7;
|
||||
try {
|
||||
boolean put;
|
||||
if (shouldExpireWithin(ttl)) {
|
||||
put = connection.set(key, value, Expiration.from(ttl), SetOption.ifAbsent());
|
||||
} else {
|
||||
put = connection.setNX(key, value);
|
||||
}
|
||||
|
||||
if (!put) {
|
||||
byte[] var11 = connection.get(key);
|
||||
return var11;
|
||||
}
|
||||
|
||||
var7 = null;
|
||||
} finally {
|
||||
if (this.isLockingCacheWriter()) {
|
||||
this.doUnlock(name, connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (byte[])var7;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String name, byte[] key) {
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
String keyString = new String(key);
|
||||
log.info("redis remove key:" + keyString);
|
||||
String keyIsAll = "*";
|
||||
if(keyString!=null && keyString.endsWith(keyIsAll)){
|
||||
execute(name, connection -> {
|
||||
// 获取某个前缀所拥有的所有的键,某个前缀开头,后面肯定是*
|
||||
Set<byte[]> keys = connection.keys(key);
|
||||
int delNum = 0;
|
||||
for (byte[] keyByte : keys) {
|
||||
delNum += connection.del(keyByte);
|
||||
}
|
||||
return delNum;
|
||||
});
|
||||
}else{
|
||||
this.execute(name, (connection) -> {
|
||||
return connection.del(new byte[][]{key});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean(String name, byte[] pattern) {
|
||||
Assert.notNull(name, "Name must not be null!");
|
||||
Assert.notNull(pattern, "Pattern must not be null!");
|
||||
this.execute(name, (connection) -> {
|
||||
boolean wasLocked = false;
|
||||
|
||||
try {
|
||||
if (this.isLockingCacheWriter()) {
|
||||
this.doLock(name, connection);
|
||||
wasLocked = true;
|
||||
}
|
||||
|
||||
byte[][] keys = (byte[][])((Set)Optional.ofNullable(connection.keys(pattern)).orElse(Collections.emptySet())).toArray(new byte[0][]);
|
||||
if (keys.length > 0) {
|
||||
connection.del(keys);
|
||||
}
|
||||
} finally {
|
||||
if (wasLocked && this.isLockingCacheWriter()) {
|
||||
this.doUnlock(name, connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "OK";
|
||||
});
|
||||
}
|
||||
|
||||
void lock(String name) {
|
||||
this.execute(name, (connection) -> {
|
||||
return this.doLock(name, connection);
|
||||
});
|
||||
}
|
||||
|
||||
void unlock(String name) {
|
||||
this.executeLockFree((connection) -> {
|
||||
this.doUnlock(name, connection);
|
||||
});
|
||||
}
|
||||
|
||||
private Boolean doLock(String name, RedisConnection connection) {
|
||||
return connection.setNX(createCacheLockKey(name), new byte[0]);
|
||||
}
|
||||
|
||||
private Long doUnlock(String name, RedisConnection connection) {
|
||||
return connection.del(new byte[][]{createCacheLockKey(name)});
|
||||
}
|
||||
|
||||
boolean doCheckLock(String name, RedisConnection connection) {
|
||||
return connection.exists(createCacheLockKey(name));
|
||||
}
|
||||
|
||||
private boolean isLockingCacheWriter() {
|
||||
return !this.sleepTime.isZero() && !this.sleepTime.isNegative();
|
||||
}
|
||||
|
||||
private <T> T execute(String name, Function<RedisConnection, T> callback) {
|
||||
RedisConnection connection = this.connectionFactory.getConnection();
|
||||
|
||||
try {
|
||||
this.checkAndPotentiallyWaitUntilUnlocked(name, connection);
|
||||
return callback.apply(connection);
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executeLockFree(Consumer<RedisConnection> callback) {
|
||||
RedisConnection connection = this.connectionFactory.getConnection();
|
||||
|
||||
try {
|
||||
callback.accept(connection);
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkAndPotentiallyWaitUntilUnlocked(String name, RedisConnection connection) {
|
||||
if (this.isLockingCacheWriter()) {
|
||||
try {
|
||||
while(this.doCheckLock(name, connection)) {
|
||||
Thread.sleep(this.sleepTime.toMillis());
|
||||
}
|
||||
|
||||
} catch (InterruptedException var4) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new PessimisticLockingFailureException(String.format("Interrupted while waiting to unlock cache %s", name), var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldExpireWithin(@Nullable Duration ttl) {
|
||||
return ttl != null && !ttl.isZero() && !ttl.isNegative();
|
||||
}
|
||||
|
||||
private static byte[] createCacheLockKey(String name) {
|
||||
return (name + "~lock").getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
//update-begin-author:zyf date:20220216 for:升级springboot版本到2.4.0+以后需要实现的方法*
|
||||
private final CacheStatisticsCollector statistics = CacheStatisticsCollector.create();
|
||||
@Override
|
||||
public CacheStatistics getCacheStatistics(String cacheName) {
|
||||
return statistics.getCacheStatistics(cacheName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStatistics(String name) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisCacheWriter withStatisticsCollector(CacheStatisticsCollector cacheStatisticsCollector) {
|
||||
return null;
|
||||
}
|
||||
//update-begin-author:zyf date:20220216 for:升级springboot版本到2.4.0+以后需要实现的方法*
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//package digital.system.jeecg.group.util;
|
||||
//
|
||||
//import digital.base.constant.CommonConstant;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.system.jeecg.group.CommonAPI;
|
||||
//import digital.util.exception.JeecgBoot401Exception;
|
||||
//import digital.util.util.JeecgRedisUtil;
|
||||
//import digital.util.util.JwtUtil;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
///**
|
||||
// * @Author scott
|
||||
// * @Date 2019/9/23 14:12
|
||||
// * @Description: 编程校验token有效性
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class TokenUtils {
|
||||
//
|
||||
// /**
|
||||
// * 获取 request 里传递的 token
|
||||
// *
|
||||
// * @param request
|
||||
// * @return
|
||||
// */
|
||||
// public static String getTokenByRequest(HttpServletRequest request) {
|
||||
// String token = request.getParameter("token");
|
||||
// if (token == null) {
|
||||
// token = request.getHeader("X-Access-Token");
|
||||
// }
|
||||
// return token;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 验证Token
|
||||
// */
|
||||
// public static boolean verifyToken(HttpServletRequest request, CommonAPI commonApi, JeecgRedisUtil jeecgRedisUtil) {
|
||||
// log.debug(" -- url --" + request.getRequestURL());
|
||||
// String token = getTokenByRequest(request);
|
||||
// return TokenUtils.verifyToken(token, commonApi, jeecgRedisUtil);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 验证Token
|
||||
// */
|
||||
// public static boolean verifyToken(String token, CommonAPI commonApi, JeecgRedisUtil jeecgRedisUtil) {
|
||||
// if (StringUtils.isBlank(token)) {
|
||||
// throw new JeecgBoot401Exception("token不能为空!");
|
||||
// }
|
||||
//
|
||||
// // 解密获得username,用于和数据库进行对比
|
||||
// String username = JwtUtil.getUsername(token);
|
||||
// if (username == null) {
|
||||
// throw new JeecgBoot401Exception("token非法无效!");
|
||||
// }
|
||||
//
|
||||
// // 查询用户信息
|
||||
// LoginUser user = TokenUtils.getLoginUser(username, commonApi, jeecgRedisUtil);
|
||||
// //LoginUser user = commonApi.getUserByName(username);
|
||||
// if (user == null) {
|
||||
//
|
||||
//
|
||||
// throw new JeecgBoot401Exception("用户不存在!");
|
||||
// }
|
||||
// // 判断用户状态
|
||||
// if (user.getStatus() != 1) {
|
||||
// throw new JeecgBoot401Exception("账号已被锁定,请联系管理员!");
|
||||
// }
|
||||
// // 校验token是否超时失效 & 或者账号密码是否错误
|
||||
// if (!jwtTokenRefresh(token, username, user.getPassword(), jeecgRedisUtil)) {
|
||||
// throw new JeecgBoot401Exception(CommonConstant.TOKEN_IS_INVALID_MSG);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 刷新token(保证用户在线操作不掉线)
|
||||
// *
|
||||
// * @param token
|
||||
// * @param userName
|
||||
// * @param passWord
|
||||
// * @param jeecgRedisUtil
|
||||
// * @return
|
||||
// */
|
||||
// private static boolean jwtTokenRefresh(String token, String userName, String passWord, JeecgRedisUtil jeecgRedisUtil) {
|
||||
// String cacheToken = oConvertUtils.getString(jeecgRedisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token));
|
||||
// if (oConvertUtils.isNotEmpty(cacheToken)) {
|
||||
// // 校验token有效性
|
||||
// if (!JwtUtil.verify(cacheToken, userName, passWord)) {
|
||||
// String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||
// // 设置Toekn缓存有效时间
|
||||
// jeecgRedisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
||||
// jeecgRedisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取登录用户
|
||||
// *
|
||||
// * @param commonApi
|
||||
// * @param username
|
||||
// * @return
|
||||
// */
|
||||
// public static LoginUser getLoginUser(String username, CommonAPI commonApi, JeecgRedisUtil jeecgRedisUtil) {
|
||||
//// LoginUser loginUser = null;
|
||||
//// String loginUserKey = CacheConstant.SYS_USERS_CACHE + "::" + username;
|
||||
//// if(jeecgRedisUtil.hasKey(loginUserKey)){
|
||||
//// loginUser = (LoginUser) jeecgRedisUtil.get(loginUserKey);
|
||||
//// }else{
|
||||
//// // 查询用户信息
|
||||
//// loginUser = commonApi.getUserByName(username);
|
||||
//// }
|
||||
// log.info("====================getLoginUser======================");
|
||||
// LoginUser loginUser = commonApi.getUserByName(username);
|
||||
// return loginUser;
|
||||
// }
|
||||
//}
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
package digital.system.jeecg.group.util.aspect;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.PropertyFilter;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.enums.ModuleType;
|
||||
import digital.base.enums.OperateTypeEnum;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.Result;
|
||||
import digital.bean.jeecg.dto.LogDTO;
|
||||
import digital.system.jeecg.group.base.service.BaseCommonService;
|
||||
import digital.util.util.IpUtils;
|
||||
import digital.util.util.SpringContextUtils;
|
||||
import digital.util.util.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 系统日志,切面处理类
|
||||
*
|
||||
* @Author scott
|
||||
* @email jeecgos@163.com
|
||||
* @Date 2018年1月14日
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class AutoLogAspect {
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@Pointcut("@annotation(digital.base.annotation.AutoLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("logPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
|
||||
//保存日志
|
||||
saveSysLog(point, time, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint, long time, Object obj) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
LogDTO dto = new LogDTO();
|
||||
AutoLog syslog = method.getAnnotation(AutoLog.class);
|
||||
if(syslog != null){
|
||||
//update-begin-author:taoyan date:
|
||||
String content = syslog.value();
|
||||
if(syslog.module()== ModuleType.ONLINE){
|
||||
content = getOnlineLogContent(obj, content);
|
||||
}
|
||||
//注解上的描述,操作日志内容
|
||||
dto.setLogType(syslog.logType());
|
||||
dto.setLogContent(content);
|
||||
}
|
||||
|
||||
//请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
dto.setMethod(className + "." + methodName + "()");
|
||||
|
||||
|
||||
//设置操作类型
|
||||
if (CommonConstant.LOG_TYPE_2 == dto.getLogType()) {
|
||||
dto.setOperateType(getOperateType(methodName, syslog.operateType()));
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//请求的参数
|
||||
dto.setRequestParam(getReqestParams(request,joinPoint));
|
||||
//设置IP地址
|
||||
dto.setIp(IpUtils.getIpAddr(request));
|
||||
//获取登录用户信息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if (sysUser != null) {
|
||||
dto.setUserId(sysUser.getId());
|
||||
dto.setUsername(sysUser.getUsername());
|
||||
}
|
||||
String taskId = (String) request.getAttribute("taskId");
|
||||
dto.setUserId(taskId);
|
||||
//耗时
|
||||
dto.setCostTime(time);
|
||||
dto.setAppKey(request.getHeader("appKey"));
|
||||
dto.setCreateTime(new Date());
|
||||
//返回结果
|
||||
String content = "";
|
||||
if (Result.class.isInstance(obj)) {
|
||||
Result res = (Result) obj;
|
||||
Object result = res.getResult();
|
||||
String message = res.getMessage();
|
||||
if (res.isSuccess()) {
|
||||
content += "操作成功" + " message =" + message + " result= " + result;
|
||||
} else {
|
||||
content += "操作失败" + " message =" + message + " result= " + result;
|
||||
}
|
||||
}
|
||||
dto.setResult(content);
|
||||
//保存系统日志
|
||||
baseCommonService.addLog(dto);
|
||||
//给飞书发调用消息
|
||||
try {
|
||||
FeiShuUtils feiShuUtils = new FeiShuUtils();
|
||||
feiShuUtils.sendWebhookMes(dto);
|
||||
if ("submitContactInfo".equals(methodName)) {
|
||||
String requestParam = dto.getRequestParam();
|
||||
JSONArray jsonArray = JSONArray.parseArray(requestParam);
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
||||
String phone = jsonObject.getString("phone");
|
||||
String name = jsonObject.getString("name");
|
||||
String company = jsonObject.getString("company");
|
||||
String description = jsonObject.getString("description");
|
||||
String companyContent = "姓名:" + name + " 手机号:" + phone + " 公司:" + company + " 需求描述:" + description;
|
||||
ContactFeiShuUtils contactFeiShuUtils = new ContactFeiShuUtils();
|
||||
contactFeiShuUtils.sendWebhookMes(companyContent);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.info("给飞书发调用消息 :" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取操作类型
|
||||
*/
|
||||
private int getOperateType(String methodName,int operateType) {
|
||||
if (operateType > 0) {
|
||||
return operateType;
|
||||
}
|
||||
//update-begin---author:wangshuai ---date:20220331 for:阿里云代码扫描规范(不允许任何魔法值出现在代码中)------------
|
||||
return OperateTypeEnum.getTypeByMethodName(methodName);
|
||||
//update-end---author:wangshuai ---date:20220331 for:阿里云代码扫描规范(不允许任何魔法值出现在代码中)------------
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取请求参数
|
||||
* @author: scott
|
||||
* @date: 2020/4/16 0:10
|
||||
* @param request: request
|
||||
* @param joinPoint: joinPoint
|
||||
* @Return: java.lang.String
|
||||
*/
|
||||
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
|
||||
String httpMethod = request.getMethod();
|
||||
String params = "";
|
||||
if (CommonConstant.HTTP_POST.equals(httpMethod) || CommonConstant.HTTP_PUT.equals(httpMethod) || CommonConstant.HTTP_PATCH.equals(httpMethod)) {
|
||||
Object[] paramsArray = joinPoint.getArgs();
|
||||
// java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
|
||||
// https://my.oschina.net/mengzhang6/blog/2395893
|
||||
Object[] arguments = new Object[paramsArray.length];
|
||||
for (int i = 0; i < paramsArray.length; i++) {
|
||||
log.info("paramsArray=="+paramsArray[i]);
|
||||
if (paramsArray[i] instanceof BindingResult || paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) {
|
||||
//ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
|
||||
//ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
|
||||
continue;
|
||||
}
|
||||
arguments[i] = paramsArray[i];
|
||||
}
|
||||
//update-begin-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
|
||||
PropertyFilter profilter = new PropertyFilter() {
|
||||
@Override
|
||||
public boolean apply(Object o, String name, Object value) {
|
||||
// int length = 500;
|
||||
// if(value!=null && value.toString().length()>length){
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
};
|
||||
params = JSONObject.toJSONString(arguments, profilter);
|
||||
//update-end-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
|
||||
} else {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
// 请求的方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
// 请求的方法参数名称
|
||||
LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
|
||||
String[] paramNames = u.getParameterNames(method);
|
||||
if (args != null && paramNames != null) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
params += " " + paramNames[i] + ": " + args[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* online日志内容拼接
|
||||
* @param obj
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
private String getOnlineLogContent(Object obj, String content){
|
||||
if (Result.class.isInstance(obj)){
|
||||
Result res = (Result)obj;
|
||||
String msg = res.getMessage();
|
||||
String tableName = res.getOnlTable();
|
||||
if(oConvertUtils.isNotEmpty(tableName)){
|
||||
content+=",表名:"+tableName;
|
||||
}
|
||||
if(res.isSuccess()){
|
||||
content+= ","+(oConvertUtils.isEmpty(msg)?"操作成功":msg);
|
||||
}else{
|
||||
content+= ","+(oConvertUtils.isEmpty(msg)?"操作失败":msg);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
/* private void saveSysLog(ProceedingJoinPoint joinPoint, long time, Object obj) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
SysLog sysLog = new SysLog();
|
||||
AutoLog syslog = method.getAnnotation(AutoLog.class);
|
||||
if(syslog != null){
|
||||
//update-begin-author:taoyan date:
|
||||
String content = syslog.value();
|
||||
if(syslog.module()== ModuleType.ONLINE){
|
||||
content = getOnlineLogContent(obj, content);
|
||||
}
|
||||
//注解上的描述,操作日志内容
|
||||
sysLog.setLogContent(content);
|
||||
sysLog.setLogType(syslog.logType());
|
||||
}
|
||||
|
||||
//请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
sysLog.setMethod(className + "." + methodName + "()");
|
||||
|
||||
|
||||
//设置操作类型
|
||||
if (sysLog.getLogType() == CommonConstant.LOG_TYPE_2) {
|
||||
sysLog.setOperateType(getOperateType(methodName, syslog.operateType()));
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//请求的参数
|
||||
sysLog.setRequestParam(getReqestParams(request,joinPoint));
|
||||
|
||||
//设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request));
|
||||
|
||||
//获取登录用户信息
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
if(sysUser!=null){
|
||||
sysLog.setUserid(sysUser.getUsername());
|
||||
sysLog.setUsername(sysUser.getRealname());
|
||||
|
||||
}
|
||||
//耗时
|
||||
sysLog.setCostTime(time);
|
||||
sysLog.setCreateTime(new Date());
|
||||
//保存系统日志
|
||||
sysLogService.save(sysLog);
|
||||
}*/
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package digital.system.jeecg.group.util.aspect;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class ContactFeiShuUtils {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// FeiShuUtils feiShuUtils = new FeiShuUtils();
|
||||
// feiShuUtils.sendWebshookMes();
|
||||
}
|
||||
|
||||
public void sendWebhookMes(String dto) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("msg_type", "text");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("text", dto.toString());
|
||||
content.put("content", jsonObject);
|
||||
// log.info("发送内容 :" + content);
|
||||
RequestBody body = RequestBody.create(mediaType, content.toJSONString());
|
||||
Request request = new Request.Builder()
|
||||
.url("https://open.feishu.cn/open-apis/bot/v2/hook/79d931ff-f30b-4ad8-861c-2b5979931956")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
log.info("sendMes to 飞书 :" + response);
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
//package digital.system.jeecg.group.util.aspect;
|
||||
//import cn.hutool.core.bean.BeanUtil;
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.aspectj.lang.ProceedingJoinPoint;
|
||||
//import org.aspectj.lang.annotation.Around;
|
||||
//import org.aspectj.lang.annotation.Aspect;
|
||||
//import org.aspectj.lang.annotation.Pointcut;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.StringUtils;
|
||||
//import digital.base.annotation.Dict;
|
||||
//import digital.base.constant.CommonConstant;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.bean.jeecg.vo.DictModel;
|
||||
//import digital.system.jeecg.group.CommonAPI;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import java.lang.reflect.Field;
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.*;
|
||||
//import java.util.regex.Pattern;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * 字典aop类
|
||||
// * @author: dangzhenghui
|
||||
// * @version: 1.0
|
||||
// */
|
||||
//@Aspect
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class DictAspect {
|
||||
//
|
||||
// @Autowired
|
||||
// private CommonAPI commonAPI;
|
||||
// @Autowired
|
||||
// public RedisTemplate redisTemplate;
|
||||
//
|
||||
// private Pattern pattern = Pattern.compile("\\$\\{\\S+\\}");
|
||||
// // 定义切点Pointcut
|
||||
// @Pointcut("execution(public * *..*.*Controller.*(..)) || @annotation(digital.base.annotation.AutoDict)")
|
||||
// public void excudeService() {
|
||||
// }
|
||||
//
|
||||
// @Around("excudeService()")
|
||||
// public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
|
||||
// long time1=System.currentTimeMillis();
|
||||
// Object result = pjp.proceed();
|
||||
// long time2=System.currentTimeMillis();
|
||||
// log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
|
||||
// long start=System.currentTimeMillis();
|
||||
// this.parseDictText(result);
|
||||
// long end=System.currentTimeMillis();
|
||||
// log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
|
||||
// * 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 ,table字典 code table text配合使用与原来jeecg的用法相同
|
||||
// * 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text,已字段名称加_dictText形式返回到前端
|
||||
// * 例输入当前返回值的就会多出一个sex_dictText字段
|
||||
// * {
|
||||
// * sex:1,
|
||||
// * sex_dictText:"男"
|
||||
// * }
|
||||
// * 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
|
||||
// * customRender:function (text) {
|
||||
// * if(text==1){
|
||||
// * return "男";
|
||||
// * }else if(text==2){
|
||||
// * return "女";
|
||||
// * }else{
|
||||
// * return text;
|
||||
// * }
|
||||
// * }
|
||||
// * 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
|
||||
// * @param result
|
||||
// */
|
||||
// private void parseDictText(Object result) throws JsonProcessingException {
|
||||
// if (result instanceof Result) {
|
||||
// List records = null;
|
||||
//
|
||||
// List<JSONObject> items = new ArrayList<>();
|
||||
// //step.1 筛选出加了 Dict 注解的字段列表
|
||||
// List<Field> dictFieldList = new ArrayList<>();
|
||||
// // 字典数据列表, key = 字典code,value=数据列表
|
||||
// Map<String, List<String>> dataListMap = new HashMap<>();
|
||||
// if (((Result) result).getResult() instanceof IPage) {
|
||||
// records = ((IPage) ((Result) result).getResult()).getRecords();
|
||||
//
|
||||
// } else if (((Result) result).getResult() instanceof List) {
|
||||
// records = (List)((Result) result).getResult();
|
||||
// }
|
||||
// if(ObjectUtil.isNotEmpty(((Result<?>) result).getResult())) {
|
||||
// if (Objects.nonNull(records) && !records.isEmpty()) {
|
||||
// Object record = records.get(0);
|
||||
// if (!(record.getClass().getName().contains("java.lang") || record.getClass().getName().contains("java.util") || record.getClass().getName().contains("java.math"))) {
|
||||
// handleList(records, items, dictFieldList, dataListMap);
|
||||
// if (((Result) result).getResult() instanceof IPage) {
|
||||
// ((IPage) ((Result) result).getResult()).setRecords(items);
|
||||
//
|
||||
// } else if (((Result) result).getResult() instanceof List) {
|
||||
// ((Result) result).setResult(items);
|
||||
// }
|
||||
// } else {
|
||||
// ((Result) result).setResult(records);
|
||||
// }
|
||||
// } else if (!(((Result<?>) result).getResult().getClass().getName().contains("java.lang") || ((Result<?>) result).getResult().getClass().getName().contains("java.util") || ((Result<?>) result).getResult().getClass().getName().contains("java.math"))) {
|
||||
// ArrayList<Object> arrayList = new ArrayList<>();
|
||||
// arrayList.add(((Result<?>) result).getResult());
|
||||
// handleList(arrayList, items, dictFieldList, dataListMap);
|
||||
// ((Result) result).setResult(items.get(0));
|
||||
// }else if (!(((Result<?>) result).getResult().getClass().getClass().getName().contains("java.lang") || ((Result<?>) result).getResult().getClass().getClass().getName().contains("java.util") || ((Result<?>) result).getResult().getClass().getClass().getName().contains("java.math"))) {
|
||||
// ArrayList<Object> arrayList = new ArrayList<>();
|
||||
// arrayList.add(((Result<?>) result).getResult());
|
||||
// handleList(arrayList, items, dictFieldList, dataListMap);
|
||||
// ((Result) result).setResult(items.get(0));
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void handleList(List records, List<JSONObject> items, List<Field> dictFieldList, Map<String, List<String>> dataListMap) throws JsonProcessingException {
|
||||
// for (Object record : records) {
|
||||
// ObjectMapper mapper = new ObjectMapper();
|
||||
// String json = "{}";
|
||||
// try {
|
||||
// //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
|
||||
// json = mapper.writeValueAsString(record);
|
||||
// } catch (JsonProcessingException e) {
|
||||
// log.error("json解析失败" + e.getMessage(), e);
|
||||
// break;
|
||||
// }
|
||||
//// if (record.getClass().getName().contains("java.lang")){
|
||||
//// mapper.readValue(json, String.class);
|
||||
//// items.add(JSONObject.parseObject((String) record));
|
||||
//// continue;
|
||||
//// }
|
||||
// JSONObject item = JSONObject.parseObject(json);
|
||||
// //update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
|
||||
// //for (Field field : record.getClass().getDeclaredFields()) {
|
||||
// // 遍历所有字段,把字典Code取出来,放到 map 里
|
||||
// for (Field field : oConvertUtils.getAllFields(record)) {
|
||||
// Object value = item.get(field.getName());
|
||||
// if (value == null || (value instanceof String && oConvertUtils.isEmpty(value))) {
|
||||
// continue;
|
||||
// }
|
||||
// if (field.getType().getName().equals("java.util.List")) {
|
||||
// List list = (List) value;
|
||||
// if (list != null && list.size() >0 ){
|
||||
// Object ob = list.get(0);
|
||||
// if (ob.getClass().getName().contains("java.lang")){
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// List<JSONObject> itemsChildren = new ArrayList<>();
|
||||
// List<Field> dictFieldListChildren = new ArrayList<>();
|
||||
// // 字典数据列表, key = 字典code,value=数据列表
|
||||
// Map<String, List<String>> dataListMapChildren = new HashMap<>();
|
||||
//// private void hanldeList(List records, List<JSONObject> items, List<Field> dictFieldList, Map<String, List<String>> dataListMap)
|
||||
// handleList((List) BeanUtil.getFieldValue(record, field.getName()), itemsChildren, dictFieldListChildren, dataListMapChildren);
|
||||
// item.put(field.getName(), itemsChildren);
|
||||
// } else if(item.get(field.getName()) instanceof JSONObject){
|
||||
// List<JSONObject> itemsObject = new ArrayList<>();
|
||||
// //step.1 筛选出加了 Dict 注解的字段列表
|
||||
// List<Field> dictFieldListObject = new ArrayList<>();
|
||||
// // 字典数据列表, key = 字典code,value=数据列表
|
||||
// Map<String, List<String>> dataListMapObject = new HashMap<>();
|
||||
// ArrayList<Object> arrayList = new ArrayList<>();
|
||||
// arrayList.add( BeanUtil.getFieldValue(record,field.getName()));
|
||||
// handleList(arrayList, itemsObject, dictFieldListObject, dataListMapObject);
|
||||
// item.put(field.getName(), itemsObject.get(0));
|
||||
// }else {
|
||||
// handleField(dictFieldList, dataListMap, item, field, value.toString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// items.add(item);
|
||||
// }
|
||||
//
|
||||
// //step.2 调用翻译方法,一次性翻译
|
||||
// Map<String, List<DictModel>> translText = this.translateAllDict(dataListMap);
|
||||
//
|
||||
// //step.3 将翻译结果填充到返回结果里
|
||||
// for (JSONObject record : items) {
|
||||
// for (Field field : dictFieldList) {
|
||||
// String code = field.getAnnotation(Dict.class).dicCode();
|
||||
// String text = field.getAnnotation(Dict.class).dicText();
|
||||
// String table = field.getAnnotation(Dict.class).dictTable();
|
||||
//
|
||||
// String fieldDictCode = code;
|
||||
// if (!StringUtils.isEmpty(table)) {
|
||||
// fieldDictCode = String.format("%s,%s,%s", table, text, code);
|
||||
// }
|
||||
//
|
||||
// String value = record.getString(field.getName());
|
||||
// if (oConvertUtils.isNotEmpty(value)) {
|
||||
// List<DictModel> dictModels = translText.get(fieldDictCode);
|
||||
// if (dictModels == null || dictModels.size() == 0) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// String textValue = this.translDictText(dictModels, value);
|
||||
// log.debug(" 字典Val : " + textValue);
|
||||
// log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + ": " + textValue);
|
||||
// // TODO-sun 测试输出,待删
|
||||
// log.debug(" ---- dictCode: " + fieldDictCode);
|
||||
// log.debug(" ---- value: " + value);
|
||||
// log.debug(" ----- text: " + textValue);
|
||||
// log.debug(" ---- dictModels: " + JSON.toJSONString(dictModels));
|
||||
// record.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void handleField(List<Field> dictFieldList, Map<String, List<String>> dataListMap, JSONObject item, Field field, String value) {
|
||||
// //update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
|
||||
// if (field.getAnnotation(Dict.class) != null) {
|
||||
// if (!dictFieldList.contains(field)) {
|
||||
// dictFieldList.add(field);
|
||||
// }
|
||||
// String code = field.getAnnotation(Dict.class).dicCode();
|
||||
// String text = field.getAnnotation(Dict.class).dicText();
|
||||
// String table = field.getAnnotation(Dict.class).dictTable();
|
||||
// log.info("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
|
||||
// List<String> dataList;
|
||||
// String dictCode = code;
|
||||
// if (!StringUtils.isEmpty(table)) {
|
||||
// dictCode = String.format("%s,%s,%s", table, text, code);
|
||||
// }
|
||||
// dataList = dataListMap.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
// this.listAddAllDeduplicate(dataList, Arrays.asList(value.split(",")));
|
||||
// }
|
||||
// //date类型默认转换string格式化日期
|
||||
// if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
|
||||
// SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * list 去重添加
|
||||
// */
|
||||
// private void listAddAllDeduplicate(List<String> dataList, List<String> addList) {
|
||||
// // 筛选出dataList中没有的数据
|
||||
// List<String> filterList = addList.stream().filter(i -> !dataList.contains(i)).collect(Collectors.toList());
|
||||
// dataList.addAll(filterList);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 一次性把所有的字典都翻译了
|
||||
// * 1. 所有的普通数据字典的所有数据只执行一次SQL
|
||||
// * 2. 表字典相同的所有数据只执行一次SQL
|
||||
// * @param dataListMap
|
||||
// * @return
|
||||
// */
|
||||
// private Map<String, List<DictModel>> translateAllDict(Map<String, List<String>> dataListMap) {
|
||||
// // 翻译后的字典文本,key=dictCode
|
||||
// Map<String, List<DictModel>> translText = new HashMap<>();
|
||||
// // 需要翻译的数据(有些可以从redis缓存中获取,就不走数据库查询)
|
||||
// List<String> needTranslData = new ArrayList<>();
|
||||
// //step.1 先通过redis中获取缓存字典数据
|
||||
// for (String dictCode : dataListMap.keySet()) {
|
||||
// List<String> dataList = dataListMap.get(dictCode);
|
||||
// if (dataList.size() == 0) {
|
||||
// continue;
|
||||
// }
|
||||
// // 表字典需要翻译的数据
|
||||
// List<String> needTranslDataTable = new ArrayList<>();
|
||||
// for (String s : dataList) {
|
||||
// String data = s.trim();
|
||||
// if (data.length() == 0) {
|
||||
// continue; //跳过循环
|
||||
// }
|
||||
// if (dictCode.contains(",")) {
|
||||
// String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, data);
|
||||
// if (redisTemplate.hasKey(keyString)) {
|
||||
// try {
|
||||
// String text = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||
// List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
// list.add(new DictModel(data, text));
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage());
|
||||
// }
|
||||
// } else if (!needTranslDataTable.contains(data)) {
|
||||
// // 去重添加
|
||||
// needTranslDataTable.add(data);
|
||||
// }
|
||||
// } else {
|
||||
// String keyString = String.format("sys:cache:dict::%s:%s", dictCode, data);
|
||||
// if (redisTemplate.hasKey(keyString)) {
|
||||
// try {
|
||||
// String text = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||
// List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
// list.add(new DictModel(data, text));
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage());
|
||||
// }
|
||||
// } else if (!needTranslData.contains(data)) {
|
||||
// // 去重添加
|
||||
// needTranslData.add(data);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// //step.2 调用数据库翻译表字典
|
||||
// if (needTranslDataTable.size() > 0) {
|
||||
// String[] arr = dictCode.split(",");
|
||||
// String table = arr[0], text = arr[1], code = arr[2];
|
||||
// String values = String.join(",", needTranslDataTable);
|
||||
// log.info("translateDictFromTableByKeys.dictCode:" + dictCode);
|
||||
// log.info("translateDictFromTableByKeys.values:" + values);
|
||||
// List<DictModel> texts = commonAPI.translateDictFromTableByKeys(table, text, code, values);
|
||||
// log.info("translateDictFromTableByKeys.result:" + texts);
|
||||
// List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
// list.addAll(texts);
|
||||
//
|
||||
// // 做 redis 缓存
|
||||
// for (DictModel dict : texts) {
|
||||
// String redisKey = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, dict.getValue());
|
||||
// try {
|
||||
// redisTemplate.opsForValue().set(redisKey, dict.getText());
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //step.3 调用数据库进行翻译普通字典
|
||||
// if (needTranslData.size() > 0) {
|
||||
// List<String> dictCodeList = Arrays.asList(dataListMap.keySet().toArray(new String[]{}));
|
||||
// // 将不包含逗号的字典code筛选出来,因为带逗号的是表字典,而不是普通的数据字典
|
||||
// List<String> filterDictCodes = dictCodeList.stream().filter(key -> !key.contains(",")).collect(Collectors.toList());
|
||||
// String dictCodes = String.join(",", filterDictCodes);
|
||||
// String values = String.join(",", needTranslData);
|
||||
// log.info("translateManyDict.dictCodes:" + dictCodes);
|
||||
// log.info("translateManyDict.values:" + values);
|
||||
// Map<String, List<DictModel>> manyDict = commonAPI.translateManyDict(dictCodes, values);
|
||||
// log.info("translateManyDict.result:" + manyDict);
|
||||
// for (String dictCode : manyDict.keySet()) {
|
||||
// List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
|
||||
// List<DictModel> newList = manyDict.get(dictCode);
|
||||
// list.addAll(newList);
|
||||
//
|
||||
// // 做 redis 缓存
|
||||
// for (DictModel dict : newList) {
|
||||
// String redisKey = String.format("sys:cache:dict::%s:%s", dictCode, dict.getValue());
|
||||
// try {
|
||||
// redisTemplate.opsForValue().set(redisKey, dict.getText());
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return translText;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 字典值替换文本
|
||||
// *
|
||||
// * @param dictModels
|
||||
// * @param values
|
||||
// * @return
|
||||
// */
|
||||
// private String translDictText(List<DictModel> dictModels, String values) {
|
||||
// List<String> result = new ArrayList<>();
|
||||
//
|
||||
// // 允许多个逗号分隔,允许传数组对象
|
||||
// String[] splitVal = values.split(",");
|
||||
// for (String val : splitVal) {
|
||||
// String dictText = val;
|
||||
// for (DictModel dict : dictModels) {
|
||||
// if (val.equals(dict.getValue())) {
|
||||
// dictText = dict.getText();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// result.add(dictText);
|
||||
// }
|
||||
// return String.join(",", result);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 翻译字典文本
|
||||
// * @param code
|
||||
// * @param text
|
||||
// * @param table
|
||||
// * @param key
|
||||
// * @return
|
||||
// */
|
||||
// @Deprecated
|
||||
// private String translateDictValue(String code, String text, String table, String key) {
|
||||
// if(oConvertUtils.isEmpty(key)) {
|
||||
// return null;
|
||||
// }
|
||||
// StringBuffer textValue=new StringBuffer();
|
||||
// String[] keys = key.split(",");
|
||||
// for (String k : keys) {
|
||||
// String tmpValue = null;
|
||||
// log.debug(" 字典 key : "+ k);
|
||||
// if (k.trim().length() == 0) {
|
||||
// continue; //跳过循环
|
||||
// }
|
||||
// //update-begin--Author:scott -- Date:20210531 ----for: !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
|
||||
// if (!StringUtils.isEmpty(table)){
|
||||
// log.info("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
|
||||
// String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim());
|
||||
// if (redisTemplate.hasKey(keyString)){
|
||||
// try {
|
||||
// tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage());
|
||||
// }
|
||||
// }else {
|
||||
// tmpValue= commonAPI.translateDictFromTable(table,text,code,k.trim());
|
||||
// }
|
||||
// }else {
|
||||
// String keyString = String.format("sys:cache:dict::%s:%s",code,k.trim());
|
||||
// if (redisTemplate.hasKey(keyString)){
|
||||
// try {
|
||||
// tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
|
||||
// } catch (Exception e) {
|
||||
// log.warn(e.getMessage());
|
||||
// }
|
||||
// }else {
|
||||
// tmpValue = commonAPI.translateDict(code, k.trim());
|
||||
// }
|
||||
// }
|
||||
// //update-end--Author:scott -- Date:20210531 ----for: !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
|
||||
//
|
||||
// if (tmpValue != null) {
|
||||
// if (!"".equals(textValue.toString())) {
|
||||
// textValue.append(",");
|
||||
// }
|
||||
// textValue.append(tmpValue);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return textValue.toString();
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,38 @@
|
||||
package digital.system.jeecg.group.util.aspect;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import digital.bean.jeecg.dto.LogDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class FeiShuUtils {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// FeiShuUtils feiShuUtils = new FeiShuUtils();
|
||||
// feiShuUtils.sendWebshookMes();
|
||||
}
|
||||
|
||||
public void sendWebhookMes(LogDTO dto) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("msg_type", "text");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("text", dto.toString());
|
||||
content.put("content", jsonObject);
|
||||
// log.info("发送内容 :" + content);
|
||||
RequestBody body = RequestBody.create(mediaType, content.toJSONString());
|
||||
Request request = new Request.Builder()
|
||||
.url("https://open.feishu.cn/open-apis/bot/v2/hook/69de5c32-67cc-4c10-ac5d-ce10a7e03ead")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
log.info("sendMes to 飞书 :" + response);
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package digital.system.jeecg.group.util.aspect;
|
||||
|
||||
import digital.system.jeecg.group.CommonAPI;
|
||||
import digital.system.jeecg.group.query.QueryRuleEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import digital.base.annotation.PermissionData;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.constant.SymbolConstant;
|
||||
import digital.base.enums.UrlMatchEnum;
|
||||
import digital.base.vo.SysPermissionDataRuleModel;
|
||||
import digital.util.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据权限切面处理类
|
||||
* 当被请求的方法有注解PermissionData时,会在往当前request中写入数据权限信息
|
||||
* @Date 2019年4月10日
|
||||
* @Version: 1.0
|
||||
* @author: smcp
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PermissionDataAspect {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CommonAPI commonApi;
|
||||
|
||||
@Pointcut("@annotation(digital.base.annotation.PermissionData)")
|
||||
public void pointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("pointCut()")
|
||||
public Object arround(ProceedingJoinPoint point) throws Throwable{
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
PermissionData pd = method.getAnnotation(PermissionData.class);
|
||||
String component = pd.pageComponent();
|
||||
String requestMethod = request.getMethod();
|
||||
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
|
||||
requestPath = filterUrl(requestPath);
|
||||
//update-begin-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效
|
||||
//先判断是否online报表请求
|
||||
// TODO 参数顺序调整有隐患
|
||||
if(requestPath.indexOf(UrlMatchEnum.CGREPORT_DATA.getMatchUrl())>=0){
|
||||
// 获取地址栏参数
|
||||
String urlParamString = request.getParameter(CommonConstant.ONL_REP_URL_PARAM_STR);
|
||||
if(oConvertUtils.isNotEmpty(urlParamString)){
|
||||
requestPath+="?"+urlParamString;
|
||||
}
|
||||
}
|
||||
//update-end-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效
|
||||
log.info("拦截请求 >> {} ; 请求类型 >> {} . ", requestPath, requestMethod);
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
//查询数据权限信息
|
||||
//TODO 微服务情况下也得支持缓存机制
|
||||
List<SysPermissionDataRuleModel> dataRules = commonApi.queryPermissionDataRule(component, requestPath, username);
|
||||
if(dataRules!=null && dataRules.size()>0) {
|
||||
//临时存储
|
||||
JeecgDataAutorUtils.installDataSearchConditon(request, dataRules);
|
||||
//TODO 微服务情况下也得支持缓存机制
|
||||
SysUserCacheInfo userinfo = commonApi.getCacheUser(username);
|
||||
JeecgDataAutorUtils.installUserInfo(request, userinfo);
|
||||
}
|
||||
return point.proceed();
|
||||
}
|
||||
|
||||
private String filterUrl(String requestPath){
|
||||
String url = "";
|
||||
if(oConvertUtils.isNotEmpty(requestPath)){
|
||||
url = requestPath.replace("\\", "/");
|
||||
url = url.replace("//", "/");
|
||||
if(url.indexOf(SymbolConstant.DOUBLE_SLASH)>=0){
|
||||
url = filterUrl(url);
|
||||
}
|
||||
/*if(url.startsWith("/")){
|
||||
url=url.substring(1);
|
||||
}*/
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求地址
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
private String getJgAuthRequsetPath(HttpServletRequest request) {
|
||||
String queryString = request.getQueryString();
|
||||
String requestPath = request.getRequestURI();
|
||||
if(oConvertUtils.isNotEmpty(queryString)){
|
||||
requestPath += "?" + queryString;
|
||||
}
|
||||
// 去掉其他参数(保留一个参数) 例如:loginController.do?login
|
||||
if (requestPath.indexOf(SymbolConstant.AND) > -1) {
|
||||
requestPath = requestPath.substring(0, requestPath.indexOf("&"));
|
||||
}
|
||||
if(requestPath.indexOf(QueryRuleEnum.EQ.getValue())!=-1){
|
||||
if(requestPath.indexOf(CommonConstant.SPOT_DO)!=-1){
|
||||
requestPath = requestPath.substring(0,requestPath.indexOf(".do")+3);
|
||||
}else{
|
||||
requestPath = requestPath.substring(0,requestPath.indexOf("?"));
|
||||
}
|
||||
}
|
||||
// 去掉项目路径
|
||||
requestPath = requestPath.substring(request.getContextPath().length() + 1);
|
||||
return filterUrl(requestPath);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private boolean moHuContain(List<String> list,String key){
|
||||
for(String str : list){
|
||||
if(key.contains(str)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
//package digital.system.jeecg.group.util.db;
|
||||
//
|
||||
//import com.alibaba.druid.pool.DruidDataSource;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import digital.base.constant.CacheConstant;
|
||||
//import digital.bean.jeecg.vo.DynamicDataSourceModel;
|
||||
//import digital.system.jeecg.group.CommonAPI;
|
||||
//import digital.util.util.SpringContextUtils;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * 数据源缓存池
|
||||
// * @author: smcp
|
||||
// */
|
||||
//public class DataSourceCachePool {
|
||||
// /** 数据源连接池缓存【本地 class缓存 - 不支持分布式】 */
|
||||
// private static Map<String, DruidDataSource> dbSources = new HashMap<>();
|
||||
// private static RedisTemplate<String, Object> redisTemplate;
|
||||
//
|
||||
// private static RedisTemplate<String, Object> getRedisTemplate() {
|
||||
// if (redisTemplate == null) {
|
||||
// redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
|
||||
// }
|
||||
// return redisTemplate;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取多数据源缓存
|
||||
// *
|
||||
// * @param dbKey
|
||||
// * @return
|
||||
// */
|
||||
// public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
|
||||
// String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
|
||||
// if (getRedisTemplate().hasKey(redisCacheKey)) {
|
||||
// return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
|
||||
// }
|
||||
// CommonAPI commonApi = SpringContextUtils.getBean(CommonAPI.class);
|
||||
// DynamicDataSourceModel dbSource = commonApi.getDynamicDbSourceByCode(dbKey);
|
||||
// if (dbSource != null) {
|
||||
// getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
|
||||
// }
|
||||
// return dbSource;
|
||||
// }
|
||||
//
|
||||
// public static DruidDataSource getCacheBasicDataSource(String dbKey) {
|
||||
// return dbSources.get(dbKey);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * put 数据源缓存
|
||||
// *
|
||||
// * @param dbKey
|
||||
// * @param db
|
||||
// */
|
||||
// public static void putCacheBasicDataSource(String dbKey, DruidDataSource db) {
|
||||
// dbSources.put(dbKey, db);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 清空数据源缓存
|
||||
// */
|
||||
// public static void cleanAllCache() {
|
||||
// //关闭数据源连接
|
||||
// for(Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()){
|
||||
// String dbkey = entry.getKey();
|
||||
// DruidDataSource druidDataSource = entry.getValue();
|
||||
// if(druidDataSource!=null && druidDataSource.isEnable()){
|
||||
// druidDataSource.close();
|
||||
// }
|
||||
// //清空redis缓存
|
||||
// getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbkey);
|
||||
// }
|
||||
// //清空缓存
|
||||
// dbSources.clear();
|
||||
// }
|
||||
//
|
||||
// public static void removeCache(String dbKey) {
|
||||
// //关闭数据源连接
|
||||
// DruidDataSource druidDataSource = dbSources.get(dbKey);
|
||||
// if(druidDataSource!=null && druidDataSource.isEnable()){
|
||||
// druidDataSource.close();
|
||||
// }
|
||||
// //清空redis缓存
|
||||
// getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbKey);
|
||||
// //清空缓存
|
||||
// dbSources.remove(dbKey);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,122 @@
|
||||
package digital.system.jeecg.group.util.db;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import digital.base.constant.DataBaseConstant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据库类型判断
|
||||
* 【有些数据库引擎是一样的,以达到复用目的】
|
||||
* @author: smcp
|
||||
*/
|
||||
public class DbTypeUtils {
|
||||
|
||||
public static Map<String, String> dialectMap = new HashMap<String, String>();
|
||||
static{
|
||||
dialectMap.put("mysql", "org.hibernate.dialect.MySQL5InnoDBDialect");
|
||||
// mariadb数据库 1 --
|
||||
dialectMap.put("mariadb", "org.hibernate.dialect.MariaDBDialect");
|
||||
//oracle数据库 1
|
||||
dialectMap.put("oracle", "org.hibernate.dialect.OracleDialect");
|
||||
// TODO 没找到不确定
|
||||
dialectMap.put("oracle12c", "org.hibernate.dialect.OracleDialect");
|
||||
// db2数据库 1xx
|
||||
dialectMap.put("db2", "org.hibernate.dialect.DB2390Dialect");
|
||||
// H2数据库
|
||||
dialectMap.put("h2", "org.hibernate.dialect.HSQLDialect");
|
||||
// HSQL数据库 1
|
||||
dialectMap.put("hsql", "org.hibernate.dialect.HSQLDialect");
|
||||
//SQLite数据库 应用平台mobile
|
||||
dialectMap.put("sqlite", "org.jeecg.modules.online.config.dialect.SQLiteDialect");
|
||||
//PostgreSQL数据库1 --
|
||||
dialectMap.put("postgresql", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
dialectMap.put("sqlserver2005", "org.hibernate.dialect.SQLServer2005Dialect");
|
||||
//sqlserver数据库1
|
||||
dialectMap.put("sqlserver", "org.hibernate.dialect.SQLServerDialect");
|
||||
//达梦数据库 [国产] 1--
|
||||
dialectMap.put("dm", "org.hibernate.dialect.DmDialect");
|
||||
//虚谷数据库
|
||||
dialectMap.put("xugu", "org.hibernate.dialect.HSQLDialect");
|
||||
//人大金仓 [国产] 1
|
||||
dialectMap.put("kingbasees", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
// Phoenix HBase数据库
|
||||
dialectMap.put("phoenix", "org.hibernate.dialect.HSQLDialect");
|
||||
// Gauss 数据库
|
||||
dialectMap.put("zenith", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
//阿里云PolarDB
|
||||
dialectMap.put("clickhouse", "org.hibernate.dialect.MySQLDialect");
|
||||
// 南大通用数据库 TODO 没找到不确定
|
||||
dialectMap.put("gbase", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
//神通数据库 [国产] TODO 没找到不确定
|
||||
dialectMap.put("oscar", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
//Sybase ASE 数据库
|
||||
dialectMap.put("sybase", "org.hibernate.dialect.SybaseDialect");
|
||||
dialectMap.put("oceanbase", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
dialectMap.put("Firebird", "org.hibernate.dialect.FirebirdDialect");
|
||||
//瀚高数据库
|
||||
dialectMap.put("highgo", "org.hibernate.dialect.HSQLDialect");
|
||||
dialectMap.put("other", "org.hibernate.dialect.PostgreSQLDialect");
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsMySql(DbType dbType) {
|
||||
return dbTypeIf(dbType, DbType.MYSQL, DbType.MARIADB, DbType.CLICK_HOUSE, DbType.SQLITE);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsOracle(DbType dbType) {
|
||||
return dbTypeIf(dbType, DbType.ORACLE, DbType.ORACLE_12C, DbType.DM);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsSqlServer(DbType dbType) {
|
||||
return dbTypeIf(dbType, DbType.SQL_SERVER, DbType.SQL_SERVER2005);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsPostgre(DbType dbType) {
|
||||
return dbTypeIf(dbType, DbType.POSTGRE_SQL, DbType.KINGBASE_ES, DbType.GAUSS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据枚举类 获取数据库类型的字符串
|
||||
* @param dbType
|
||||
* @return
|
||||
*/
|
||||
public static String getDbTypeString(DbType dbType){
|
||||
if(DbType.DB2.equals(dbType)){
|
||||
return DataBaseConstant.DB_TYPE_DB2;
|
||||
}else if(DbType.HSQL.equals(dbType)){
|
||||
return DataBaseConstant.DB_TYPE_HSQL;
|
||||
}else if(dbTypeIsOracle(dbType)){
|
||||
return DataBaseConstant.DB_TYPE_ORACLE;
|
||||
}else if(dbTypeIsSqlServer(dbType)){
|
||||
return DataBaseConstant.DB_TYPE_SQLSERVER;
|
||||
}else if(dbTypeIsPostgre(dbType)){
|
||||
return DataBaseConstant.DB_TYPE_POSTGRESQL;
|
||||
}
|
||||
return DataBaseConstant.DB_TYPE_MYSQL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据枚举类 获取数据库方言字符串
|
||||
* @param dbType
|
||||
* @return
|
||||
*/
|
||||
public static String getDbDialect(DbType dbType){
|
||||
return dialectMap.get(dbType.getDb());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据库类型
|
||||
*/
|
||||
public static boolean dbTypeIf(DbType dbType, DbType... correctTypes) {
|
||||
for (DbType type : correctTypes) {
|
||||
if (type.equals(dbType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
//package digital.system.jeecg.group.util.db;
|
||||
//
|
||||
//import com.alibaba.druid.pool.DruidDataSource;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.ArrayUtils;
|
||||
//import org.springframework.jdbc.core.JdbcTemplate;
|
||||
//import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
//import digital.bean.jeecg.vo.DynamicDataSourceModel;
|
||||
//import digital.util.exception.JeecgBootException;
|
||||
//import digital.util.util.ReflectHelper;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import java.sql.SQLException;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * Spring JDBC 实时数据库访问
|
||||
// *
|
||||
// * @author chenguobin
|
||||
// * @version 1.0
|
||||
// * @date 2014-09-05
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class DynamicDBUtil {
|
||||
//
|
||||
// /**
|
||||
// * 获取数据源【最底层方法,不要随便调用】
|
||||
// *
|
||||
// * @param dbSource
|
||||
// * @return
|
||||
// */
|
||||
// private static DruidDataSource getJdbcDataSource(final DynamicDataSourceModel dbSource) {
|
||||
// DruidDataSource dataSource = new DruidDataSource();
|
||||
//
|
||||
// String driverClassName = dbSource.getDbDriver();
|
||||
// String url = dbSource.getDbUrl();
|
||||
// String dbUser = dbSource.getDbUsername();
|
||||
// String dbPassword = dbSource.getDbPassword();
|
||||
// dataSource.setDriverClassName(driverClassName);
|
||||
// dataSource.setUrl(url);
|
||||
// //dataSource.setValidationQuery("SELECT 1 FROM DUAL");
|
||||
// dataSource.setTestWhileIdle(true);
|
||||
// dataSource.setTestOnBorrow(false);
|
||||
// dataSource.setTestOnReturn(false);
|
||||
// dataSource.setBreakAfterAcquireFailure(true);
|
||||
// dataSource.setConnectionErrorRetryAttempts(0);
|
||||
// dataSource.setUsername(dbUser);
|
||||
// dataSource.setMaxWait(30000);
|
||||
// dataSource.setPassword(dbPassword);
|
||||
//
|
||||
// log.info("******************************************");
|
||||
// log.info("* *");
|
||||
// log.info("*====【"+dbSource.getCode()+"】=====Druid连接池已启用 ====*");
|
||||
// log.info("* *");
|
||||
// log.info("******************************************");
|
||||
// return dataSource;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过 dbKey ,获取数据源
|
||||
// *
|
||||
// * @param dbKey
|
||||
// * @return
|
||||
// */
|
||||
// public static DruidDataSource getDbSourceByDbKey(final String dbKey) {
|
||||
// //获取多数据源配置
|
||||
// DynamicDataSourceModel dbSource = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
|
||||
// //先判断缓存中是否存在数据库链接
|
||||
// DruidDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
|
||||
// if (cacheDbSource != null && !cacheDbSource.isClosed()) {
|
||||
// log.debug("--------getDbSourceBydbKey------------------从缓存中获取DB连接-------------------");
|
||||
// return cacheDbSource;
|
||||
// } else {
|
||||
// DruidDataSource dataSource = getJdbcDataSource(dbSource);
|
||||
// if(dataSource!=null && dataSource.isEnable()){
|
||||
// DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
|
||||
// }else{
|
||||
// throw new JeecgBootException("动态数据源连接失败,dbKey:"+dbKey);
|
||||
// }
|
||||
// log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
|
||||
// return dataSource;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 关闭数据库连接池
|
||||
// *
|
||||
// * @param dbKey
|
||||
// * @return
|
||||
// */
|
||||
// public static void closeDbKey(final String dbKey) {
|
||||
// DruidDataSource dataSource = getDbSourceByDbKey(dbKey);
|
||||
// try {
|
||||
// if (dataSource != null && !dataSource.isClosed()) {
|
||||
// dataSource.getConnection().commit();
|
||||
// dataSource.getConnection().close();
|
||||
// dataSource.close();
|
||||
// }
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static JdbcTemplate getJdbcTemplate(String dbKey) {
|
||||
// DruidDataSource dataSource = getDbSourceByDbKey(dbKey);
|
||||
// return new JdbcTemplate(dataSource);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据数据源获取NamedParameterJdbcTemplate
|
||||
// * @param dbKey
|
||||
// * @return
|
||||
// */
|
||||
// private static NamedParameterJdbcTemplate getNamedParameterJdbcTemplate(String dbKey) {
|
||||
// DruidDataSource dataSource = getDbSourceByDbKey(dbKey);
|
||||
// return new NamedParameterJdbcTemplate(dataSource);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Executes the SQL statement in this <code>PreparedStatement</code> object,
|
||||
// * which must be an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or
|
||||
// * <code>DELETE</code>; or an SQL statement that returns nothing,
|
||||
// * such as a DDL statement.
|
||||
// */
|
||||
// public static int update(final String dbKey, String sql, Object... param) {
|
||||
// int effectCount;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
// if (ArrayUtils.isEmpty(param)) {
|
||||
// effectCount = jdbcTemplate.update(sql);
|
||||
// } else {
|
||||
// effectCount = jdbcTemplate.update(sql, param);
|
||||
// }
|
||||
// return effectCount;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的Update
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static int updateByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
// int effectCount;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
// //根据模板获取sql
|
||||
// sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
// NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
// effectCount = namedParameterJdbcTemplate.update(sql, data);
|
||||
// return effectCount;
|
||||
// }
|
||||
//
|
||||
// public static Object findOne(final String dbKey, String sql, Object... param) {
|
||||
// List<Map<String, Object>> list;
|
||||
// list = findList(dbKey, sql, param);
|
||||
// if (oConvertUtils.listIsEmpty(list)) {
|
||||
// log.error("Except one, but not find actually");
|
||||
// return null;
|
||||
// }
|
||||
// if (list.size() > 1) {
|
||||
// log.error("Except one, but more than one actually");
|
||||
// }
|
||||
// return list.get(0);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的查询 返回HashMap
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static Object findOneByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
// List<Map<String, Object>> list;
|
||||
// list = findListByHash(dbKey, sql, data);
|
||||
// if (oConvertUtils.listIsEmpty(list)) {
|
||||
// log.error("Except one, but not find actually");
|
||||
// }
|
||||
// if (list.size() > 1) {
|
||||
// log.error("Except one, but more than one actually");
|
||||
// }
|
||||
// return list.get(0);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 直接sql查询 根据clazz返回单个实例
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句
|
||||
// * @param clazz 返回实例的Class
|
||||
// * @param param
|
||||
// * @return
|
||||
// */
|
||||
// @SuppressWarnings("unchecked")
|
||||
// public static <T> Object findOne(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
// Map<String, Object> map = (Map<String, Object>) findOne(dbKey, sql, param);
|
||||
// return ReflectHelper.setAll(clazz, map);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的查询 返回单个实例
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param clazz 返回实例的Class
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// @SuppressWarnings("unchecked")
|
||||
// public static <T> Object findOneByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
// Map<String, Object> map = (Map<String, Object>) findOneByHash(dbKey, sql, data);
|
||||
// return ReflectHelper.setAll(clazz, map);
|
||||
// }
|
||||
//
|
||||
// public static List<Map<String, Object>> findList(final String dbKey, String sql, Object... param) {
|
||||
// List<Map<String, Object>> list;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
//
|
||||
// if (ArrayUtils.isEmpty(param)) {
|
||||
// list = jdbcTemplate.queryForList(sql);
|
||||
// } else {
|
||||
// list = jdbcTemplate.queryForList(sql, param);
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询数量
|
||||
// * @param dbKey
|
||||
// * @param sql
|
||||
// * @param param
|
||||
// * @return
|
||||
// */
|
||||
// public static Map<String, Object> queryCount(String dbKey, String sql, Map<String, Object> param){
|
||||
// NamedParameterJdbcTemplate npJdbcTemplate = getNamedParameterJdbcTemplate(dbKey);
|
||||
// return npJdbcTemplate.queryForMap(sql, param);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询列表数据
|
||||
// * @param dbKey
|
||||
// * @param sql
|
||||
// * @param param
|
||||
// * @return
|
||||
// */
|
||||
// public static List<Map<String, Object>> findListByNamedParam(final String dbKey, String sql, Map<String, Object> param) {
|
||||
// NamedParameterJdbcTemplate npJdbcTemplate = getNamedParameterJdbcTemplate(dbKey);
|
||||
// List<Map<String, Object>> list = npJdbcTemplate.queryForList(sql, param);
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的查询
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static List<Map<String, Object>> findListByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
// List<Map<String, Object>> list;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
// //根据模板获取sql
|
||||
// sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
// NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
// list = namedParameterJdbcTemplate.queryForList(sql, data);
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 此方法只能返回单列,不能返回实体类
|
||||
// * @param dbKey 数据源的key
|
||||
// * @param sql sal
|
||||
// * @param clazz 类
|
||||
// * @param param 参数
|
||||
// * @param <T>
|
||||
// * @return
|
||||
// */
|
||||
// public static <T> List<T> findList(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
// List<T> list;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
//
|
||||
// if (ArrayUtils.isEmpty(param)) {
|
||||
// list = jdbcTemplate.queryForList(sql, clazz);
|
||||
// } else {
|
||||
// list = jdbcTemplate.queryForList(sql, clazz, param);
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的查询 返回单列数据list
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param clazz 类型Long、String等
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static <T> List<T> findListByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
// List<T> list;
|
||||
// JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
// //根据模板获取sql
|
||||
// sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
// NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
// list = namedParameterJdbcTemplate.queryForList(sql, data, clazz);
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 直接sql查询 返回实体类列表
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持 minidao 语法逻辑
|
||||
// * @param clazz 返回实体类列表的class
|
||||
// * @param param sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static <T> List<T> findListEntities(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
// List<Map<String, Object>> queryList = findList(dbKey, sql, param);
|
||||
// return ReflectHelper.transList2Entrys(queryList, clazz);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 支持miniDao语法操作的查询 返回实体类列表
|
||||
// *
|
||||
// * @param dbKey 数据源标识
|
||||
// * @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
// * @param clazz 返回实体类列表的class
|
||||
// * @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
// * @return
|
||||
// */
|
||||
// public static <T> List<T> findListEntitiesByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
// List<Map<String, Object>> queryList = findListByHash(dbKey, sql, data);
|
||||
// return ReflectHelper.transList2Entrys(queryList, clazz);
|
||||
// }
|
||||
//}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package digital.system.jeecg.group.util.db;
|
||||
|
||||
import freemarker.cache.StringTemplateLoader;
|
||||
import freemarker.core.ParseException;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.codegenerate.generate.util.SimpleFormat;
|
||||
import digital.base.constant.DataBaseConstant;
|
||||
import digital.base.constant.SymbolConstant;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author 赵俊夫
|
||||
* @version V1.0
|
||||
* @Title:FreemarkerHelper
|
||||
* @description:Freemarker引擎协助类
|
||||
* @date Jul 5, 2013 2:58:29 PM
|
||||
*/
|
||||
@Slf4j
|
||||
public class FreemarkerParseFactory {
|
||||
|
||||
private static final String ENCODE = "utf-8";
|
||||
/**
|
||||
* 参数格式化工具类
|
||||
*/
|
||||
private static final String MINI_DAO_FORMAT = "DaoFormat";
|
||||
|
||||
/**
|
||||
* 文件缓存
|
||||
*/
|
||||
private static final Configuration TPL_CONFIG = new Configuration();
|
||||
/**
|
||||
* SQL 缓存
|
||||
*/
|
||||
private static final Configuration SQL_CONFIG = new Configuration();
|
||||
|
||||
private static StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
|
||||
|
||||
/**使用内嵌的(?ms)打开单行和多行模式*/
|
||||
private final static Pattern NOTES_PATTERN = Pattern
|
||||
.compile("(?ms)/\\*.*?\\*/|^\\s*//.*?$");
|
||||
|
||||
static {
|
||||
TPL_CONFIG.setClassForTemplateLoading(
|
||||
new FreemarkerParseFactory().getClass(), "/");
|
||||
TPL_CONFIG.setNumberFormat("0.#####################");
|
||||
SQL_CONFIG.setTemplateLoader(stringTemplateLoader);
|
||||
SQL_CONFIG.setNumberFormat("0.#####################");
|
||||
//classic_compatible设置,解决报空指针错误
|
||||
SQL_CONFIG.setClassicCompatible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断模板是否存在
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static boolean isExistTemplate(String tplName) throws Exception {
|
||||
try {
|
||||
Template mytpl = TPL_CONFIG.getTemplate(tplName, "UTF-8");
|
||||
if (mytpl == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//update-begin--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误-----
|
||||
if (e instanceof ParseException) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
throw new Exception(e);
|
||||
}
|
||||
log.debug("----isExistTemplate----" + e.toString());
|
||||
//update-end--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误------
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析ftl模板
|
||||
*
|
||||
* @param tplName 模板名
|
||||
* @param paras 参数
|
||||
* @return
|
||||
*/
|
||||
public static String parseTemplate(String tplName, Map<String, Object> paras) {
|
||||
try {
|
||||
log.debug(" minidao sql templdate : " + tplName);
|
||||
StringWriter swriter = new StringWriter();
|
||||
Template mytpl = TPL_CONFIG.getTemplate(tplName, ENCODE);
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString());
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
return sql;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
log.error("发送一次的模板key:{ " + tplName + " }");
|
||||
//System.err.println(e.getMessage());
|
||||
//System.err.println("模板名:{ "+ tplName +" }");
|
||||
throw new RuntimeException("解析SQL模板异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析ftl
|
||||
*
|
||||
* @param tplContent 模板内容
|
||||
* @param paras 参数
|
||||
* @return String 模板解析后内容
|
||||
*/
|
||||
public static String parseTemplateContent(String tplContent,
|
||||
Map<String, Object> paras) {
|
||||
try {
|
||||
String sqlUnderline="sql_";
|
||||
StringWriter swriter = new StringWriter();
|
||||
if (stringTemplateLoader.findTemplateSource(sqlUnderline + tplContent.hashCode()) == null) {
|
||||
stringTemplateLoader.putTemplate(sqlUnderline + tplContent.hashCode(), tplContent);
|
||||
}
|
||||
Template mytpl = SQL_CONFIG.getTemplate(sqlUnderline + tplContent.hashCode(), ENCODE);
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString());
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
return sql;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
log.error("发送一次的模板key:{ " + tplContent + " }");
|
||||
//System.err.println(e.getMessage());
|
||||
//System.err.println("模板内容:{ "+ tplContent +" }");
|
||||
throw new RuntimeException("解析SQL模板异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 除去无效字段,去掉注释 不然批量处理可能报错 去除无效的等于
|
||||
*/
|
||||
private static String getSqlText(String sql) {
|
||||
// 将注释替换成""
|
||||
sql = NOTES_PATTERN.matcher(sql).replaceAll("");
|
||||
sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ")
|
||||
.replaceAll("\\s{1,}", " ").trim();
|
||||
// 去掉 最后是 where这样的问题
|
||||
//where空格 "where "
|
||||
String whereSpace = DataBaseConstant.SQL_WHERE+" ";
|
||||
//"where and"
|
||||
String whereAnd = DataBaseConstant.SQL_WHERE+" and";
|
||||
//", where"
|
||||
String commaWhere = SymbolConstant.COMMA+" "+DataBaseConstant.SQL_WHERE;
|
||||
//", "
|
||||
String commaSpace = SymbolConstant.COMMA + " ";
|
||||
if (sql.endsWith(DataBaseConstant.SQL_WHERE) || sql.endsWith(whereSpace)) {
|
||||
sql = sql.substring(0, sql.lastIndexOf("where"));
|
||||
}
|
||||
// 去掉where and 这样的问题
|
||||
int index = 0;
|
||||
while ((index = StringUtils.indexOfIgnoreCase(sql, whereAnd, index)) != -1) {
|
||||
sql = sql.substring(0, index + 5)
|
||||
+ sql.substring(index + 9, sql.length());
|
||||
}
|
||||
// 去掉 , where 这样的问题
|
||||
index = 0;
|
||||
while ((index = StringUtils.indexOfIgnoreCase(sql, commaWhere, index)) != -1) {
|
||||
sql = sql.substring(0, index)
|
||||
+ sql.substring(index + 1, sql.length());
|
||||
}
|
||||
// 去掉 最后是 ,这样的问题
|
||||
if (sql.endsWith(SymbolConstant.COMMA) || sql.endsWith(commaSpace)) {
|
||||
sql = sql.substring(0, sql.lastIndexOf(","));
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package digital.system.jeecg.group.util.db;
|
||||
|
||||
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页自定义
|
||||
* 通过角色编码与首页组件路径配置
|
||||
* 枚举的顺序有权限高低权重作用(也就是配置多个角色,在前面的角色首页,会优先生效)
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
public enum RoleIndexConfigEnum {
|
||||
|
||||
/**
|
||||
* 首页自定义 admin
|
||||
*/
|
||||
ADMIN("admin", "dashboard/Analysis"),
|
||||
//TEST("test", "dashboard/IndexChart"),
|
||||
/**
|
||||
* 首页自定义 hr
|
||||
*/
|
||||
HR("hr", "dashboard/IndexBdc");
|
||||
//DM("dm", "dashboard/IndexTask"),
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
String roleCode;
|
||||
/**
|
||||
* 路由index
|
||||
*/
|
||||
String componentUrl;
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*
|
||||
* @param roleCode 角色编码
|
||||
* @param componentUrl 首页组件路径(规则跟菜单配置一样)
|
||||
*/
|
||||
RoleIndexConfigEnum(String roleCode, String componentUrl) {
|
||||
this.roleCode = roleCode;
|
||||
this.componentUrl = componentUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code找枚举
|
||||
*
|
||||
* @param roleCode 角色编码
|
||||
* @return
|
||||
*/
|
||||
private static RoleIndexConfigEnum getEnumByCode(String roleCode) {
|
||||
for (RoleIndexConfigEnum e : RoleIndexConfigEnum.values()) {
|
||||
if (e.roleCode.equals(roleCode)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code找index
|
||||
*
|
||||
* @param roleCode 角色编码
|
||||
* @return
|
||||
*/
|
||||
private static String getIndexByCode(String roleCode) {
|
||||
for (RoleIndexConfigEnum e : RoleIndexConfigEnum.values()) {
|
||||
if (e.roleCode.equals(roleCode)) {
|
||||
return e.componentUrl;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getIndexByRoles(List<String> roles) {
|
||||
String[] rolesArray = roles.toArray(new String[roles.size()]);
|
||||
for (RoleIndexConfigEnum e : RoleIndexConfigEnum.values()) {
|
||||
if (oConvertUtils.isIn(e.roleCode, rolesArray)) {
|
||||
return e.componentUrl;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode;
|
||||
}
|
||||
|
||||
public void setRoleCode(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public String getComponentUrl() {
|
||||
return componentUrl;
|
||||
}
|
||||
|
||||
public void setComponentUrl(String componentUrl) {
|
||||
this.componentUrl = componentUrl;
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package digital.system.jeecg.message.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.message.service.ISysMessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
import digital.system.jeecg.message.entity.SysMessage;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @author: smcp
|
||||
* @date: 2019-04-09
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/message/sysMessage")
|
||||
public class SysMessageController extends JeecgController<SysMessage, ISysMessageService> {
|
||||
@Autowired
|
||||
private ISysMessageService sysMessageService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysMessage
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysMessage sysMessage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
QueryWrapper<SysMessage> queryWrapper = QueryGenerator.initQueryWrapper(sysMessage, req.getParameterMap());
|
||||
Page<SysMessage> page = new Page<SysMessage>(pageNo, pageSize);
|
||||
IPage<SysMessage> pageList = sysMessageService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysMessage
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysMessage sysMessage) {
|
||||
sysMessageService.save(sysMessage);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysMessage
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysMessage sysMessage) {
|
||||
sysMessageService.updateById(sysMessage);
|
||||
return Result.ok("修改成功!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysMessageService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
|
||||
this.sysMessageService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysMessage sysMessage = sysMessageService.getById(id);
|
||||
return Result.ok(sysMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysMessage sysMessage) {
|
||||
return super.exportXls(request, sysMessage, SysMessage.class, "推送消息模板");
|
||||
}
|
||||
|
||||
/**
|
||||
* excel导入
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/importExcel")
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysMessage.class);
|
||||
}
|
||||
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
//package digital.system.jeecg.message.controller;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import digital.system.jeecg.group.query.QueryGenerator;
|
||||
//import digital.system.jeecg.message.service.ISysMessageTemplateService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
//import digital.system.jeecg.message.entity.MsgParams;
|
||||
//import digital.system.jeecg.message.entity.SysMessageTemplate;
|
||||
//import digital.system.jeecg.message.util.PushMsgUtil;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * @Description: 消息模板
|
||||
// * @Author: zita
|
||||
// * @Sate: 2019-04-09
|
||||
// * @Version: V1.0
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/message/sysMessageTemplate")
|
||||
//public class SysMessageTemplateController extends JeecgController<SysMessageTemplate, ISysMessageTemplateService> {
|
||||
// @Autowired
|
||||
// private ISysMessageTemplateService sysMessageTemplateService;
|
||||
// @Autowired
|
||||
// private PushMsgUtil pushMsgUtil;
|
||||
//
|
||||
// /**
|
||||
// * 分页列表查询
|
||||
// *
|
||||
// * @param sysMessageTemplate
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param req
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping(value = "/list")
|
||||
// public Result<?> queryPageList(SysMessageTemplate sysMessageTemplate, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
// QueryWrapper<SysMessageTemplate> queryWrapper = QueryGenerator.initQueryWrapper(sysMessageTemplate, req.getParameterMap());
|
||||
// Page<SysMessageTemplate> page = new Page<SysMessageTemplate>(pageNo, pageSize);
|
||||
// IPage<SysMessageTemplate> pageList = sysMessageTemplateService.page(page, queryWrapper);
|
||||
// return Result.ok(pageList);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加
|
||||
// *
|
||||
// * @param sysMessageTemplate
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping(value = "/add")
|
||||
// public Result<?> add(@RequestBody SysMessageTemplate sysMessageTemplate) {
|
||||
// sysMessageTemplateService.save(sysMessageTemplate);
|
||||
// return Result.ok("添加成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// *
|
||||
// * @param sysMessageTemplate
|
||||
// * @return
|
||||
// */
|
||||
// @PutMapping(value = "/edit")
|
||||
// public Result<?> edit(@RequestBody SysMessageTemplate sysMessageTemplate) {
|
||||
// sysMessageTemplateService.updateById(sysMessageTemplate);
|
||||
// return Result.ok("更新成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @DeleteMapping(value = "/delete")
|
||||
// public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// sysMessageTemplateService.removeById(id);
|
||||
// return Result.ok("删除成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除
|
||||
// *
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @DeleteMapping(value = "/deleteBatch")
|
||||
// public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
// this.sysMessageTemplateService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
// return Result.ok("批量删除成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id查询
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping(value = "/queryById")
|
||||
// public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
// SysMessageTemplate sysMessageTemplate = sysMessageTemplateService.getById(id);
|
||||
// return Result.ok(sysMessageTemplate);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出excel
|
||||
// *
|
||||
// * @param request
|
||||
// */
|
||||
// @GetMapping(value = "/exportXls")
|
||||
// public ModelAndView exportXls(HttpServletRequest request, SysMessageTemplate sysMessageTemplate) {
|
||||
// return super.exportXls(request, sysMessageTemplate, SysMessageTemplate.class, "推送消息模板");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * excel导入
|
||||
// *
|
||||
// * @param request
|
||||
// * @param response
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping(value = "/importExcel")
|
||||
// public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// return super.importExcel(request, response, SysMessageTemplate.class);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送消息
|
||||
// */
|
||||
// @PostMapping(value = "/sendMsg")
|
||||
// public Result<SysMessageTemplate> sendMessage(@RequestBody MsgParams msgParams) {
|
||||
// Result<SysMessageTemplate> result = new Result<SysMessageTemplate>();
|
||||
// Map<String, String> map = null;
|
||||
// try {
|
||||
// map = (Map<String, String>) JSON.parse(msgParams.getTestData());
|
||||
// } catch (Exception e) {
|
||||
// result.error500("解析Json出错!");
|
||||
// return result;
|
||||
// }
|
||||
// boolean is_sendSuccess = pushMsgUtil.sendMessage(msgParams.getMsgType(), msgParams.getTemplateCode(), map, msgParams.getReceiver());
|
||||
// if (is_sendSuccess) {
|
||||
// result.success("发送消息任务添加成功!");
|
||||
// } else {
|
||||
// result.error500("发送消息任务添加失败!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,36 @@
|
||||
package digital.system.jeecg.message.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 发送消息实体
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
@Data
|
||||
public class MsgParams implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String msgType;
|
||||
|
||||
/**
|
||||
* 消息接收方
|
||||
*/
|
||||
private String receiver;
|
||||
|
||||
/**
|
||||
* 消息模板码
|
||||
*/
|
||||
private String templateCode;
|
||||
|
||||
/**
|
||||
* 测试数据
|
||||
*/
|
||||
private String testData;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package digital.system.jeecg.message.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import digital.base.annotation.Dict;
|
||||
import digital.bean.jeecg.entity.JeecgEntity;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_sms")
|
||||
public class SysMessage extends JeecgEntity {
|
||||
/**
|
||||
* 推送内容
|
||||
*/
|
||||
@Excel(name = "推送内容", width = 15)
|
||||
private java.lang.String esContent;
|
||||
/**
|
||||
* 推送所需参数Json格式
|
||||
*/
|
||||
@Excel(name = "推送所需参数Json格式", width = 15)
|
||||
private java.lang.String esParam;
|
||||
/**
|
||||
* 接收人
|
||||
*/
|
||||
@Excel(name = "接收人", width = 15)
|
||||
private java.lang.String esReceiver;
|
||||
/**
|
||||
* 推送失败原因
|
||||
*/
|
||||
@Excel(name = "推送失败原因", width = 15)
|
||||
private java.lang.String esResult;
|
||||
/**
|
||||
* 发送次数
|
||||
*/
|
||||
@Excel(name = "发送次数", width = 15)
|
||||
private Integer esSendNum;
|
||||
/**
|
||||
* 推送状态 0未推送 1推送成功 2推送失败
|
||||
*/
|
||||
@Excel(name = "推送状态 0未推送 1推送成功 2推送失败", width = 15)
|
||||
@Dict(dicCode = "msgSendStatus")
|
||||
private java.lang.String esSendStatus;
|
||||
/**
|
||||
* 推送时间
|
||||
*/
|
||||
@Excel(name = "推送时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date esSendTime;
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
@Excel(name = "消息标题", width = 15)
|
||||
private java.lang.String esTitle;
|
||||
/**
|
||||
* 推送方式:1短信 2邮件 3微信
|
||||
*/
|
||||
@Excel(name = "推送方式:1短信 2邮件 3微信", width = 15)
|
||||
@Dict(dicCode = "msgType")
|
||||
private java.lang.String esType;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
private java.lang.String remark;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package digital.system.jeecg.message.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import digital.bean.jeecg.entity.JeecgEntity;
|
||||
|
||||
/**
|
||||
* @Description: 消息模板
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_sms_template")
|
||||
public class SysMessageTemplate extends JeecgEntity {
|
||||
/**
|
||||
* 模板CODE
|
||||
*/
|
||||
@Excel(name = "模板CODE", width = 15)
|
||||
private java.lang.String templateCode;
|
||||
/**
|
||||
* 模板标题
|
||||
*/
|
||||
@Excel(name = "模板标题", width = 30)
|
||||
private java.lang.String templateName;
|
||||
/**
|
||||
* 模板内容
|
||||
*/
|
||||
@Excel(name = "模板内容", width = 50)
|
||||
private java.lang.String templateContent;
|
||||
/**
|
||||
* 模板测试json
|
||||
*/
|
||||
@Excel(name = "模板测试json", width = 15)
|
||||
private java.lang.String templateTestJson;
|
||||
/**
|
||||
* 模板类型
|
||||
*/
|
||||
@Excel(name = "模板类型", width = 15)
|
||||
private java.lang.String templateType;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package digital.system.jeecg.message.handle;
|
||||
|
||||
/**
|
||||
* @Description: 发送信息接口
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface ISendMsgHandle {
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*
|
||||
* @param es_receiver 发送人
|
||||
* @param es_title 标题
|
||||
* @param es_content 内容
|
||||
*/
|
||||
// void SendMsg(String es_receiver, String es_title, String es_content);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package digital.system.jeecg.message.handle.enums;
|
||||
|
||||
/**
|
||||
* 推送状态枚举
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
public enum SendMsgStatusEnum {
|
||||
|
||||
//推送状态 0未推送 1推送成功 2推送失败
|
||||
WAIT("0"), SUCCESS("1"), FAIL("2");
|
||||
|
||||
private String code;
|
||||
|
||||
private SendMsgStatusEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setStatusCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package digital.system.jeecg.message.handle.enums;
|
||||
|
||||
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
/**
|
||||
* 发送消息类型枚举
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
public enum SendMsgTypeEnum {
|
||||
|
||||
/**
|
||||
* 短信
|
||||
*/
|
||||
SMS("1", "digital.system.modules.message.handle.impl.SmsSendMsgHandle"),
|
||||
/**
|
||||
* 邮件
|
||||
*/
|
||||
EMAIL("2", "digital.system.modules.message.handle.impl.EmailSendMsgHandle"),
|
||||
/**
|
||||
* 微信
|
||||
*/
|
||||
WX("3", "digital.system.modules.message.handle.impl.WxSendMsgHandle"),
|
||||
/**
|
||||
* 系统消息
|
||||
*/
|
||||
SYSTEM_MESSAGE("4", "digital.system.modules.message.handle.impl.SystemSendMsgHandle");
|
||||
|
||||
private String type;
|
||||
|
||||
private String implClass;
|
||||
|
||||
private SendMsgTypeEnum(String type, String implClass) {
|
||||
this.type = type;
|
||||
this.implClass = implClass;
|
||||
}
|
||||
|
||||
public static SendMsgTypeEnum getByType(String type) {
|
||||
if (oConvertUtils.isEmpty(type)) {
|
||||
return null;
|
||||
}
|
||||
for (SendMsgTypeEnum val : values()) {
|
||||
if (val.getType().equals(type)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getImplClass() {
|
||||
return implClass;
|
||||
}
|
||||
|
||||
public void setImplClass(String implClass) {
|
||||
this.implClass = implClass;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
//package digital.system.modules.message.handle.impl;
|
||||
//
|
||||
//
|
||||
//import org.springframework.mail.javamail.JavaMailSender;
|
||||
//import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
//import digital.system.modules.message.handle.ISendMsgHandle;
|
||||
//import digital.util.util.SpringContextUtils;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
///**
|
||||
// * @Description: 邮箱发送信息
|
||||
// * @author: smcp
|
||||
// */
|
||||
//public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
// static String emailFrom;
|
||||
//
|
||||
// public static void setEmailFrom(String emailFrom) {
|
||||
// EmailSendMsgHandle.emailFrom = emailFrom;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
// JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
// MimeMessage message = mailSender.createMimeMessage();
|
||||
// MimeMessageHelper helper = null;
|
||||
// //update-begin-author:taoyan date:20200811 for:配置类数据获取
|
||||
// if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
// StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
// setEmailFrom(staticConfig.getEmailFrom());
|
||||
// }
|
||||
// //update-end-author:taoyan date:20200811 for:配置类数据获取
|
||||
// try {
|
||||
// helper = new MimeMessageHelper(message, true);
|
||||
// // 设置发送方邮箱地址
|
||||
// helper.setFrom(emailFrom);
|
||||
// helper.setTo(es_receiver);
|
||||
// helper.setSubject(es_title);
|
||||
// helper.setText(es_content, true);
|
||||
// mailSender.send(message);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//package digital.system.modules.message.handle.impl;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import digital.system.modules.message.handle.ISendMsgHandle;
|
||||
//
|
||||
///**
|
||||
// * @Description: 短信发送
|
||||
// * @author: smcp
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class SmsSendMsgHandle implements ISendMsgHandle {
|
||||
////
|
||||
//// @Override
|
||||
//// public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
//// // TODO Auto-generated method stub
|
||||
//// log.info("发短信");
|
||||
//// }
|
||||
//
|
||||
//}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package digital.system.jeecg.message.handle.impl;
|
||||
|
||||
import digital.system.jeecg.message.handle.ISendMsgHandle;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 发送系统消息
|
||||
* @Author: wangshuai
|
||||
* @Date: 2022年3月22日 18:48:20
|
||||
*/
|
||||
public class SystemSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
public static final String FROM_USER = "system";
|
||||
|
||||
// @Override
|
||||
// public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
// if (oConvertUtils.isEmpty(es_receiver)) {
|
||||
// throw new JeecgBootException("被发送人不能为空");
|
||||
// }
|
||||
// ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
|
||||
// MessageDTO messageDTO = new MessageDTO(FROM_USER, es_receiver, es_title, es_content);
|
||||
// sysBaseAPI.sendSysAnnouncement(messageDTO);
|
||||
// }
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//package digital.system.modules.message.handle.impl;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import digital.system.modules.message.handle.ISendMsgHandle;
|
||||
//
|
||||
///**
|
||||
// * @Description: 发微信消息模板
|
||||
// * @author: smcp
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class WxSendMsgHandle implements ISendMsgHandle {
|
||||
//
|
||||
// @Override
|
||||
// public void SendMsg(String es_receiver, String es_title, String es_content) {
|
||||
// // TODO Auto-generated method stub
|
||||
// log.info("发微信消息模板");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package digital.system.jeecg.message.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import digital.system.jeecg.message.entity.SysMessage;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysMessageMapper extends BaseMapper<SysMessage> {
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package digital.system.jeecg.message.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import digital.system.jeecg.message.entity.SysMessageTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 消息模板
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysMessageTemplateMapper extends BaseMapper<SysMessageTemplate> {
|
||||
|
||||
/**
|
||||
* 通过模板CODE查询消息模板
|
||||
*
|
||||
* @param code 模板CODE
|
||||
* @return List<SysMessageTemplate>
|
||||
*/
|
||||
@Select("SELECT * FROM SYS_SMS_TEMPLATE WHERE TEMPLATE_CODE = #{code}")
|
||||
List<SysMessageTemplate> selectByCode(String code);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="digital.system.jeecg.message.mapper.SysMessageMapper">
|
||||
|
||||
</mapper>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="digital.system.jeecg.message.mapper.SysMessageTemplateMapper">
|
||||
|
||||
</mapper>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package digital.system.jeecg.message.service;
|
||||
|
||||
|
||||
import digital.system.jeecg.group.base.service.JeecgService;
|
||||
import digital.system.jeecg.message.entity.SysMessage;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysMessageService extends JeecgService<SysMessage> {
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package digital.system.jeecg.message.service;
|
||||
|
||||
import digital.system.jeecg.group.base.service.JeecgService;
|
||||
import digital.system.jeecg.message.entity.SysMessageTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 消息模板
|
||||
* @Author: zita
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysMessageTemplateService extends JeecgService<SysMessageTemplate> {
|
||||
|
||||
/**
|
||||
* 通过模板CODE查询消息模板
|
||||
*
|
||||
* @param code 模板CODE
|
||||
* @return
|
||||
*/
|
||||
List<SysMessageTemplate> selectByCode(String code);
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package digital.system.jeecg.message.service.impl;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.system.jeecg.group.base.service.impl.JeecgServiceImpl;
|
||||
import digital.system.jeecg.message.entity.SysMessage;
|
||||
import digital.system.jeecg.message.mapper.SysMessageMapper;
|
||||
import digital.system.jeecg.message.service.ISysMessageService;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: digital
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysMessageServiceImpl extends JeecgServiceImpl<SysMessageMapper, SysMessage> implements ISysMessageService {
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package digital.system.jeecg.message.service.impl;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.system.jeecg.group.base.service.impl.JeecgServiceImpl;
|
||||
import digital.system.jeecg.message.entity.SysMessageTemplate;
|
||||
import digital.system.jeecg.message.mapper.SysMessageTemplateMapper;
|
||||
import digital.system.jeecg.message.service.ISysMessageTemplateService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 消息模板
|
||||
* @Author: digital
|
||||
* @Date: 2019-04-09
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysMessageTemplateServiceImpl extends JeecgServiceImpl<SysMessageTemplateMapper, SysMessageTemplate> implements ISysMessageTemplateService {
|
||||
|
||||
@Autowired
|
||||
private SysMessageTemplateMapper sysMessageTemplateMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysMessageTemplate> selectByCode(String code) {
|
||||
return sysMessageTemplateMapper.selectByCode(code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//package digital.system.jeecg.message.util;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import digital.system.jeecg.message.entity.SysMessage;
|
||||
//import digital.system.jeecg.message.entity.SysMessageTemplate;
|
||||
//import digital.system.jeecg.message.handle.enums.SendMsgStatusEnum;
|
||||
//import digital.system.jeecg.message.service.ISysMessageService;
|
||||
//import digital.system.jeecg.message.service.ISysMessageTemplateService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.io.StringWriter;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 消息生成工具
|
||||
// *
|
||||
// * @author: smcp
|
||||
// */
|
||||
//
|
||||
//@Component
|
||||
//public class PushMsgUtil {
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysMessageService sysMessageService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysMessageTemplateService sysMessageTemplateService;
|
||||
//
|
||||
// @Autowired
|
||||
// private Configuration freemarkerConfig;
|
||||
//
|
||||
// /**
|
||||
// * @param msgType 消息类型 1短信 2邮件 3微信
|
||||
// * @param templateCode 消息模板码
|
||||
// * @param map 消息参数
|
||||
// * @param sentTo 接收消息方
|
||||
// */
|
||||
// public boolean sendMessage(String msgType, String templateCode, Map<String, String> map, String sentTo) {
|
||||
// List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
// SysMessage sysMessage = new SysMessage();
|
||||
// if (sysSmsTemplates.size() > 0) {
|
||||
// SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
|
||||
// sysMessage.setEsType(msgType);
|
||||
// sysMessage.setEsReceiver(sentTo);
|
||||
// //模板标题
|
||||
// String title = sysSmsTemplate.getTemplateName();
|
||||
// //模板内容
|
||||
// String content = sysSmsTemplate.getTemplateContent();
|
||||
// StringWriter stringWriter = new StringWriter();
|
||||
// Template template = null;
|
||||
// try {
|
||||
// template = new Template("SysMessageTemplate", content, freemarkerConfig);
|
||||
// template.process(map, stringWriter);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// } catch (TemplateException e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// }
|
||||
// content = stringWriter.toString();
|
||||
// sysMessage.setEsTitle(title);
|
||||
// sysMessage.setEsContent(content);
|
||||
// sysMessage.setEsParam(JSONObject.toJSONString(map));
|
||||
// sysMessage.setEsSendTime(new Date());
|
||||
// sysMessage.setEsSendStatus(SendMsgStatusEnum.WAIT.getCode());
|
||||
// sysMessage.setEsSendNum(0);
|
||||
// if (sysMessageService.save(sysMessage)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package digital.system.jeecg.message.websocket;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import digital.base.constant.CommonSendStatus;
|
||||
import digital.bean.jeecg.BaseMap;
|
||||
import digital.system.jeecg.group.redis.listener.JeecgRedisListener;
|
||||
|
||||
/**
|
||||
* 监听消息(采用redis发布订阅方式发送消息)
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SocketHandler implements JeecgRedisListener {
|
||||
|
||||
@Autowired
|
||||
private WebSocket webSocket;
|
||||
|
||||
@Override
|
||||
public void onMessage(BaseMap map) {
|
||||
log.info("【SocketHandler消息】Redis Listerer:" + map.toString());
|
||||
|
||||
String userId = map.get("userId");
|
||||
String message = map.get("message");
|
||||
if (ObjectUtil.isNotEmpty(userId)) {
|
||||
webSocket.pushMessage(userId, message);
|
||||
//app端消息推送
|
||||
webSocket.pushMessage(userId + CommonSendStatus.APP_SESSION_SUFFIX, message);
|
||||
} else {
|
||||
webSocket.pushMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package digital.system.jeecg.message.websocket;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import digital.base.constant.WebsocketConst;
|
||||
import digital.base.vo.Result;
|
||||
|
||||
/**
|
||||
* @Description: TestSocketController
|
||||
* @author: smcp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/socketTest")
|
||||
public class TestSocketController {
|
||||
|
||||
@Autowired
|
||||
private WebSocket webSocket;
|
||||
|
||||
@PostMapping("/sendAll")
|
||||
public Result<String> sendAll(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String message = jsonObject.getString("message");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
|
||||
obj.put(WebsocketConst.MSG_ID, "M0001");
|
||||
obj.put(WebsocketConst.MSG_TXT, message);
|
||||
webSocket.sendMessage(obj.toJSONString());
|
||||
result.setResult("群发!");
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/sendUser")
|
||||
public Result<String> sendUser(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String userId = jsonObject.getString("userId");
|
||||
String message = jsonObject.getString("message");
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
|
||||
obj.put(WebsocketConst.MSG_USER_ID, userId);
|
||||
obj.put(WebsocketConst.MSG_ID, "M0001");
|
||||
obj.put(WebsocketConst.MSG_TXT, message);
|
||||
webSocket.sendMessage(userId, obj.toJSONString());
|
||||
result.setResult("单发");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package digital.system.jeecg.message.websocket;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import digital.base.constant.WebsocketConst;
|
||||
import digital.bean.jeecg.BaseMap;
|
||||
import digital.system.jeecg.group.redis.client.JeecgRedisClient;
|
||||
import javax.annotation.Resource;
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2019/11/29 9:41
|
||||
* @Description: 此注解相当于设置访问URL
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@ServerEndpoint("/websocket/{userId}")
|
||||
public class WebSocket {
|
||||
|
||||
private static final String REDIS_TOPIC_NAME = "socketHandler";
|
||||
/**
|
||||
* 缓存 webSocket连接到单机服务class中(整体方案支持集群)
|
||||
*/
|
||||
private static CopyOnWriteArraySet<WebSocket> webSockets = new CopyOnWriteArraySet<>();
|
||||
/**
|
||||
* 线程安全Map
|
||||
*/
|
||||
private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
private Session session;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
@Resource
|
||||
private JeecgRedisClient jeecgRedisClient;
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam(value = "userId") String userId) {
|
||||
try {
|
||||
//TODO 通过header中获取token,进行check
|
||||
this.session = session;
|
||||
this.userId = userId;
|
||||
webSockets.add(this);
|
||||
sessionPool.put(userId, session);
|
||||
log.info("【websocket消息】有新的连接,总数为:" + webSockets.size());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose() {
|
||||
try {
|
||||
webSockets.remove(this);
|
||||
sessionPool.remove(this.userId);
|
||||
log.info("【websocket消息】连接断开,总数为:" + webSockets.size());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 服务端推送消息
|
||||
*
|
||||
* @param userId
|
||||
* @param message
|
||||
*/
|
||||
public void pushMessage(String userId, String message) {
|
||||
Session session = sessionPool.get(userId);
|
||||
if (session != null && session.isOpen()) {
|
||||
try {
|
||||
//update-begin-author:taoyan date:20211012 for: websocket报错 https://gitee.com/jeecg/smcp/issues/I4C0MU
|
||||
synchronized (session) {
|
||||
log.info("【websocket消息】 单点消息:" + message);
|
||||
session.getBasicRemote().sendText(message);
|
||||
}
|
||||
//update-end-author:taoyan date:20211012 for: websocket报错 https://gitee.com/jeecg/smcp/issues/I4C0MU
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务器端推送消息
|
||||
*/
|
||||
public void pushMessage(String message) {
|
||||
try {
|
||||
webSockets.forEach(ws -> ws.session.getAsyncRemote().sendText(message));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message) {
|
||||
//todo 现在有个定时任务刷,应该去掉
|
||||
log.debug("【websocket消息】收到客户端消息:" + message);
|
||||
JSONObject obj = new JSONObject();
|
||||
//业务类型
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK);
|
||||
//消息内容
|
||||
obj.put(WebsocketConst.MSG_TXT, "心跳响应");
|
||||
//update-begin-author:taoyan date:20220308 for: 消息通知长连接启动心跳机制,后端代码小bug #3473
|
||||
for (WebSocket webSocket : webSockets) {
|
||||
webSocket.pushMessage(obj.toJSONString());
|
||||
}
|
||||
//update-end-author:taoyan date:20220308 for: 消息通知长连接启动心跳机制,后端代码小bug #3473
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台发送消息到redis
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void sendMessage(String message) {
|
||||
log.info("【websocket消息】广播消息:" + message);
|
||||
BaseMap baseMap = new BaseMap();
|
||||
baseMap.put("userId", "");
|
||||
baseMap.put("message", message);
|
||||
jeecgRedisClient.sendMessage(REDIS_TOPIC_NAME, baseMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此为单点消息
|
||||
*
|
||||
* @param userId
|
||||
* @param message
|
||||
*/
|
||||
public void sendMessage(String userId, String message) {
|
||||
BaseMap baseMap = new BaseMap();
|
||||
baseMap.put("userId", userId);
|
||||
baseMap.put("message", message);
|
||||
jeecgRedisClient.sendMessage(REDIS_TOPIC_NAME, baseMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此为单点消息(多人)
|
||||
*
|
||||
* @param userIds
|
||||
* @param message
|
||||
*/
|
||||
public void sendMessage(String[] userIds, String message) {
|
||||
for (String userId : userIds) {
|
||||
sendMessage(userId, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package digital.system.jeecg.monitor.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.monitor.domain.RedisInfo;
|
||||
import digital.system.jeecg.monitor.service.RedisService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: ActuatorRedisController
|
||||
* @author: smcp
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/actuator/redis")
|
||||
public class ActuatorRedisController {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* Redis详细信息
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public Result<?> getRedisInfo() throws Exception {
|
||||
List<RedisInfo> infoList = this.redisService.getRedisInfo();
|
||||
log.info(infoList.toString());
|
||||
return Result.ok(infoList);
|
||||
}
|
||||
|
||||
@GetMapping("/keysSize")
|
||||
public Map<String, Object> getKeysSize() throws Exception {
|
||||
return redisService.getKeysSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取redis key数量 for 报表
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/keysSizeForReport")
|
||||
public Map<String, JSONArray> getKeysSizeReport() throws Exception {
|
||||
return redisService.getMapForReport("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取redis 内存 for 报表
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/memoryForReport")
|
||||
public Map<String, JSONArray> memoryForReport() throws Exception {
|
||||
return redisService.getMapForReport("2");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取redis 全部信息 for 报表
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/infoForReport")
|
||||
public Map<String, JSONArray> infoForReport() throws Exception {
|
||||
return redisService.getMapForReport("3");
|
||||
}
|
||||
|
||||
@GetMapping("/memoryInfo")
|
||||
public Map<String, Object> getMemoryInfo() throws Exception {
|
||||
return redisService.getMemoryInfo();
|
||||
}
|
||||
|
||||
//update-begin--Author:zhangweijian Date:20190425 for:获取磁盘信息
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @功能:获取磁盘信息
|
||||
*/
|
||||
@GetMapping("/queryDiskInfo")
|
||||
public Result<List<Map<String, Object>>> queryDiskInfo(HttpServletRequest request, HttpServletResponse response) {
|
||||
Result<List<Map<String, Object>>> res = new Result<>();
|
||||
try {
|
||||
// 当前文件系统类
|
||||
FileSystemView fsv = FileSystemView.getFileSystemView();
|
||||
// 列出所有windows 磁盘
|
||||
File[] fs = File.listRoots();
|
||||
log.info("查询磁盘信息:" + fs.length + "个");
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < fs.length; i++) {
|
||||
if (fs[i].getTotalSpace() == 0) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = new HashMap(5);
|
||||
map.put("name", fsv.getSystemDisplayName(fs[i]));
|
||||
map.put("max", fs[i].getTotalSpace());
|
||||
map.put("rest", fs[i].getFreeSpace());
|
||||
map.put("restPPT", (fs[i].getTotalSpace() - fs[i].getFreeSpace()) * 100 / fs[i].getTotalSpace());
|
||||
list.add(map);
|
||||
log.info(map.toString());
|
||||
}
|
||||
res.setResult(list);
|
||||
res.success("查询成功");
|
||||
} catch (Exception e) {
|
||||
res.error500("查询失败" + e.getMessage());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//update-end--Author:zhangweijian Date:20190425 for:获取磁盘信息
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package digital.system.jeecg.monitor.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: redis信息
|
||||
* @author: smcp
|
||||
*/
|
||||
public class RedisInfo {
|
||||
|
||||
private static Map<String, String> map = new HashMap(5);
|
||||
|
||||
static {
|
||||
map.put("redis_version", "Redis 服务器版本");
|
||||
map.put("redis_git_sha1", "Git SHA1");
|
||||
map.put("redis_git_dirty", "Git dirty flag");
|
||||
map.put("os", "Redis 服务器的宿主操作系统");
|
||||
map.put("arch_bits", " 架构(32 或 64 位)");
|
||||
map.put("multiplexing_api", "Redis 所使用的事件处理机制");
|
||||
map.put("gcc_version", "编译 Redis 时所使用的 GCC 版本");
|
||||
map.put("process_id", "服务器进程的 PID");
|
||||
map.put("run_id", "Redis 服务器的随机标识符(用于 Sentinel 和集群)");
|
||||
map.put("tcp_port", "TCP/IP 监听端口");
|
||||
map.put("uptime_in_seconds", "自 Redis 服务器启动以来,经过的秒数");
|
||||
map.put("uptime_in_days", "自 Redis 服务器启动以来,经过的天数");
|
||||
map.put("lru_clock", " 以分钟为单位进行自增的时钟,用于 LRU 管理");
|
||||
map.put("connected_clients", "已连接客户端的数量(不包括通过从属服务器连接的客户端)");
|
||||
map.put("client_longest_output_list", "当前连接的客户端当中,最长的输出列表");
|
||||
map.put("client_longest_input_buf", "当前连接的客户端当中,最大输入缓存");
|
||||
map.put("blocked_clients", "正在等待阻塞命令(BLPOP、BRPOP、BRPOPLPUSH)的客户端的数量");
|
||||
map.put("used_memory", "由 Redis 分配器分配的内存总量,以字节(byte)为单位");
|
||||
map.put("used_memory_human", "以人类可读的格式返回 Redis 分配的内存总量");
|
||||
map.put("used_memory_rss", "从操作系统的角度,返回 Redis 已分配的内存总量(俗称常驻集大小)。这个值和 top 、 ps 等命令的输出一致");
|
||||
map.put("used_memory_peak", " Redis 的内存消耗峰值(以字节为单位)");
|
||||
map.put("used_memory_peak_human", "以人类可读的格式返回 Redis 的内存消耗峰值");
|
||||
map.put("used_memory_lua", "Lua 引擎所使用的内存大小(以字节为单位)");
|
||||
map.put("mem_fragmentation_ratio", "sed_memory_rss 和 used_memory 之间的比率");
|
||||
map.put("mem_allocator", "在编译时指定的, Redis 所使用的内存分配器。可以是 libc 、 jemalloc 或者 tcmalloc");
|
||||
|
||||
map.put("redis_build_id", "redis_build_id");
|
||||
map.put("redis_mode", "运行模式,单机(standalone)或者集群(cluster)");
|
||||
map.put("atomicvar_api", "atomicvar_api");
|
||||
map.put("hz", "redis内部调度(进行关闭timeout的客户端,删除过期key等等)频率,程序规定serverCron每秒运行10次。");
|
||||
map.put("executable", "server脚本目录");
|
||||
map.put("config_file", "配置文件目录");
|
||||
map.put("client_biggest_input_buf", "当前连接的客户端当中,最大输入缓存,用client list命令观察qbuf和qbuf-free两个字段最大值");
|
||||
map.put("used_memory_rss_human", "以人类可读的方式返回 Redis 已分配的内存总量");
|
||||
map.put("used_memory_peak_perc", "内存使用率峰值");
|
||||
map.put("total_system_memory", "系统总内存");
|
||||
map.put("total_system_memory_human", "以人类可读的方式返回系统总内存");
|
||||
map.put("used_memory_lua_human", "以人类可读的方式返回Lua 引擎所使用的内存大小");
|
||||
map.put("maxmemory", "最大内存限制,0表示无限制");
|
||||
map.put("maxmemory_human", "以人类可读的方式返回最大限制内存");
|
||||
map.put("maxmemory_policy", "超过内存限制后的处理策略");
|
||||
map.put("loading", "服务器是否正在载入持久化文件");
|
||||
map.put("rdb_changes_since_last_save", "离最近一次成功生成rdb文件,写入命令的个数,即有多少个写入命令没有持久化");
|
||||
map.put("rdb_bgsave_in_progress", "服务器是否正在创建rdb文件");
|
||||
map.put("rdb_last_save_time", "离最近一次成功创建rdb文件的时间戳。当前时间戳 - rdb_last_save_time=多少秒未成功生成rdb文件");
|
||||
map.put("rdb_last_bgsave_status", "最近一次rdb持久化是否成功");
|
||||
map.put("rdb_last_bgsave_time_sec", "最近一次成功生成rdb文件耗时秒数");
|
||||
map.put("rdb_current_bgsave_time_sec", "如果服务器正在创建rdb文件,那么这个域记录的就是当前的创建操作已经耗费的秒数");
|
||||
map.put("aof_enabled", "是否开启了aof");
|
||||
map.put("aof_rewrite_in_progress", "标识aof的rewrite操作是否在进行中");
|
||||
map.put("aof_rewrite_scheduled", "rewrite任务计划,当客户端发送bgrewriteaof指令,如果当前rewrite子进程正在执行,那么将客户端请求的bgrewriteaof变为计划任务,待aof子进程结束后执行rewrite ");
|
||||
|
||||
map.put("aof_last_rewrite_time_sec", "最近一次aof rewrite耗费的时长");
|
||||
map.put("aof_current_rewrite_time_sec", "如果rewrite操作正在进行,则记录所使用的时间,单位秒");
|
||||
map.put("aof_last_bgrewrite_status", "上次bgrewrite aof操作的状态");
|
||||
map.put("aof_last_write_status", "上次aof写入状态");
|
||||
|
||||
map.put("total_commands_processed", "redis处理的命令数");
|
||||
map.put("total_connections_received", "新创建连接个数,如果新创建连接过多,过度地创建和销毁连接对性能有影响,说明短连接严重或连接池使用有问题,需调研代码的连接设置");
|
||||
map.put("instantaneous_ops_per_sec", "redis当前的qps,redis内部较实时的每秒执行的命令数");
|
||||
map.put("total_net_input_bytes", "redis网络入口流量字节数");
|
||||
map.put("total_net_output_bytes", "redis网络出口流量字节数");
|
||||
|
||||
map.put("instantaneous_input_kbps", "redis网络入口kps");
|
||||
map.put("instantaneous_output_kbps", "redis网络出口kps");
|
||||
map.put("rejected_connections", "拒绝的连接个数,redis连接个数达到maxclients限制,拒绝新连接的个数");
|
||||
map.put("sync_full", "主从完全同步成功次数");
|
||||
|
||||
map.put("sync_partial_ok", "主从部分同步成功次数");
|
||||
map.put("sync_partial_err", "主从部分同步失败次数");
|
||||
map.put("expired_keys", "运行以来过期的key的数量");
|
||||
map.put("evicted_keys", "运行以来剔除(超过了maxmemory后)的key的数量");
|
||||
map.put("keyspace_hits", "命中次数");
|
||||
map.put("keyspace_misses", "没命中次数");
|
||||
map.put("pubsub_channels", "当前使用中的频道数量");
|
||||
map.put("pubsub_patterns", "当前使用的模式的数量");
|
||||
map.put("latest_fork_usec", "最近一次fork操作阻塞redis进程的耗时数,单位微秒");
|
||||
map.put("role", "实例的角色,是master or slave");
|
||||
map.put("connected_slaves", "连接的slave实例个数");
|
||||
map.put("master_repl_offset", "主从同步偏移量,此值如果和上面的offset相同说明主从一致没延迟");
|
||||
map.put("repl_backlog_active", "复制积压缓冲区是否开启");
|
||||
map.put("repl_backlog_size", "复制积压缓冲大小");
|
||||
map.put("repl_backlog_first_byte_offset", "复制缓冲区里偏移量的大小");
|
||||
map.put("repl_backlog_histlen", "此值等于 master_repl_offset - repl_backlog_first_byte_offset,该值不会超过repl_backlog_size的大小");
|
||||
map.put("used_cpu_sys", "将所有redis主进程在核心态所占用的CPU时求和累计起来");
|
||||
map.put("used_cpu_user", "将所有redis主进程在用户态所占用的CPU时求和累计起来");
|
||||
map.put("used_cpu_sys_children", "将后台进程在核心态所占用的CPU时求和累计起来");
|
||||
map.put("used_cpu_user_children", "将后台进程在用户态所占用的CPU时求和累计起来");
|
||||
map.put("cluster_enabled", "实例是否启用集群模式");
|
||||
map.put("db0", "db0的key的数量,以及带有生存期的key的数,平均存活时间");
|
||||
|
||||
}
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
private String description;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
this.description = map.get(this.key);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RedisInfo{" + "key='" + key + '\'' + ", value='" + value + '\'' + ", desctiption='" + description + '\'' + '}';
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package digital.system.jeecg.monitor.exception;
|
||||
|
||||
/**
|
||||
* Redis 连接异常
|
||||
*
|
||||
* @author: smcp
|
||||
*/
|
||||
public class RedisConnectException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1639374111871115063L;
|
||||
|
||||
public RedisConnectException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package digital.system.jeecg.monitor.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import digital.system.jeecg.monitor.domain.RedisInfo;
|
||||
import digital.system.jeecg.monitor.exception.RedisConnectException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: redis信息service接口
|
||||
* @author: smcp
|
||||
*/
|
||||
public interface RedisService {
|
||||
|
||||
/**
|
||||
* 获取 redis 的详细信息
|
||||
*
|
||||
* @return List
|
||||
* @throws RedisConnectException
|
||||
*/
|
||||
List<RedisInfo> getRedisInfo() throws RedisConnectException;
|
||||
|
||||
/**
|
||||
* 获取 redis key 数量
|
||||
*
|
||||
* @return Map
|
||||
* @throws RedisConnectException
|
||||
*/
|
||||
Map<String, Object> getKeysSize() throws RedisConnectException;
|
||||
|
||||
/**
|
||||
* 获取 redis 内存信息
|
||||
*
|
||||
* @return Map
|
||||
* @throws RedisConnectException
|
||||
*/
|
||||
Map<String, Object> getMemoryInfo() throws RedisConnectException;
|
||||
|
||||
/**
|
||||
* 获取 报表需要个redis信息
|
||||
*
|
||||
* @param type
|
||||
* @return Map
|
||||
* @throws RedisConnectException
|
||||
*/
|
||||
Map<String, JSONArray> getMapForReport(String type) throws RedisConnectException;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
//package digital.system.jeecg.monitor.service.impl;
|
||||
//
|
||||
//import org.springframework.boot.actuate.health.Health;
|
||||
//import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 功能说明:自定义邮件检测
|
||||
// *
|
||||
// * @author: 李波
|
||||
// * @email: 503378406@qq.com
|
||||
// * @date: 2019-06-29
|
||||
// */
|
||||
//@Component
|
||||
//public class MailHealthIndicator implements HealthIndicator {
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public Health health() {
|
||||
// int errorCode = check();
|
||||
// if (errorCode != 0) {
|
||||
// return Health.down().withDetail("Error Code", errorCode).build();
|
||||
// }
|
||||
// return Health.up().build();
|
||||
// }
|
||||
//
|
||||
// int check() {
|
||||
// //可以实现自定义的数据库检测逻辑
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package digital.system.jeecg.monitor.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cglib.beans.BeanMap;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import digital.system.jeecg.monitor.domain.RedisInfo;
|
||||
import digital.system.jeecg.monitor.exception.RedisConnectException;
|
||||
import digital.system.jeecg.monitor.service.RedisService;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Redis 监控信息获取
|
||||
*
|
||||
* @Author MrBird
|
||||
*/
|
||||
@Service("redisService")
|
||||
@Slf4j
|
||||
public class RedisServiceImpl implements RedisService {
|
||||
|
||||
@Resource
|
||||
private RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
/**
|
||||
* Redis详细信息
|
||||
*/
|
||||
@Override
|
||||
public List<RedisInfo> getRedisInfo() throws RedisConnectException {
|
||||
Properties info = redisConnectionFactory.getConnection().info();
|
||||
List<RedisInfo> infoList = new ArrayList<>();
|
||||
RedisInfo redisInfo = null;
|
||||
for (Map.Entry<Object, Object> entry : info.entrySet()) {
|
||||
redisInfo = new RedisInfo();
|
||||
redisInfo.setKey(oConvertUtils.getString(entry.getKey()));
|
||||
redisInfo.setValue(oConvertUtils.getString(entry.getValue()));
|
||||
infoList.add(redisInfo);
|
||||
}
|
||||
return infoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKeysSize() throws RedisConnectException {
|
||||
Long dbSize = redisConnectionFactory.getConnection().dbSize();
|
||||
Map<String, Object> map = new HashMap(5);
|
||||
map.put("create_time", System.currentTimeMillis());
|
||||
map.put("dbSize", dbSize);
|
||||
|
||||
log.debug("--getKeysSize--: " + map.toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMemoryInfo() throws RedisConnectException {
|
||||
Map<String, Object> map = null;
|
||||
Properties info = redisConnectionFactory.getConnection().info();
|
||||
for (Map.Entry<Object, Object> entry : info.entrySet()) {
|
||||
String key = oConvertUtils.getString(entry.getKey());
|
||||
if ("used_memory".equals(key)) {
|
||||
map = new HashMap(5);
|
||||
map.put("used_memory", entry.getValue());
|
||||
map.put("create_time", System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
log.debug("--getMemoryInfo--: " + map.toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询redis信息for报表
|
||||
*
|
||||
* @param type 1redis key数量 2 占用内存 3redis信息
|
||||
* @return
|
||||
* @throws RedisConnectException
|
||||
*/
|
||||
@Override
|
||||
public Map<String, JSONArray> getMapForReport(String type) throws RedisConnectException {
|
||||
Map<String, JSONArray> mapJson = new HashMap(5);
|
||||
JSONArray json = new JSONArray();
|
||||
if ("3".equals(type)) {
|
||||
List<RedisInfo> redisInfo = getRedisInfo();
|
||||
for (RedisInfo info : redisInfo) {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
BeanMap beanMap = BeanMap.create(info);
|
||||
for (Object key : beanMap.keySet()) {
|
||||
map.put(key + "", beanMap.get(key));
|
||||
}
|
||||
json.add(map);
|
||||
}
|
||||
mapJson.put("data", json);
|
||||
return mapJson;
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
JSONObject jo = new JSONObject();
|
||||
Map<String, Object> map;
|
||||
if ("1".equals(type)) {
|
||||
map = getKeysSize();
|
||||
jo.put("value", map.get("dbSize"));
|
||||
} else {
|
||||
map = getMemoryInfo();
|
||||
Integer used_memory = Integer.valueOf(map.get("used_memory").toString());
|
||||
jo.put("value", used_memory / 1000);
|
||||
}
|
||||
String create_time = DateUtil.formatTime(DateUtil.date((Long) map.get("create_time") - (4 - i) * 1000));
|
||||
jo.put("name", create_time);
|
||||
json.add(jo);
|
||||
}
|
||||
mapJson.put("data", json);
|
||||
return mapJson;
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package digital.system.jeecg.oss.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.oss.entity.OSSFile;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.oss.service.IOSSFileService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/oss/file")
|
||||
@Api(tags = "通用上传接口")
|
||||
public class OSSFileController {
|
||||
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<OSSFile>> queryPageList(OSSFile file,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<OSSFile>> result = new Result<>();
|
||||
QueryWrapper<OSSFile> queryWrapper = QueryGenerator.initQueryWrapper(file, req.getParameterMap());
|
||||
Page<OSSFile> page = new Page<>(pageNo, pageSize);
|
||||
IPage<OSSFile> pageList = ossFileService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/upload")
|
||||
//@RequiresRoles({"admin"})
|
||||
public Result upload(@RequestParam("file") MultipartFile multipartFile) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
ossFileService.upload(multipartFile);
|
||||
result.success("上传成功!");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.info(ex.getMessage(), ex);
|
||||
result.error500("上传失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@DeleteMapping("/delete")
|
||||
public Result delete(@RequestParam(name = "id") String id) {
|
||||
Result result = new Result();
|
||||
OSSFile file = ossFileService.getById(id);
|
||||
if (file == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}
|
||||
else {
|
||||
boolean ok = ossFileService.delete(file);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询.
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询")
|
||||
@ResponseBody
|
||||
@GetMapping("/queryById")
|
||||
public Result<OSSFile> queryById(@RequestParam(name = "id") String id) {
|
||||
Result<OSSFile> result = new Result<>();
|
||||
OSSFile file = ossFileService.getById(id);
|
||||
if (file == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}
|
||||
else {
|
||||
result.setResult(file);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package digital.system.jeecg.oss.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import digital.bean.jeecg.entity.JeecgEntity;
|
||||
|
||||
@Data
|
||||
@TableName("oss_file")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class OSSFile extends JeecgEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
@Excel(name = "文件地址")
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package digital.system.jeecg.oss.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import digital.system.jeecg.oss.entity.OSSFile;
|
||||
|
||||
public interface OSSFileMapper extends BaseMapper<OSSFile> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package digital.system.jeecg.oss.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import digital.system.jeecg.oss.entity.OSSFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IOSSFileService extends IService<OSSFile> {
|
||||
|
||||
void upload(MultipartFile multipartFile) throws IOException;
|
||||
|
||||
boolean delete(OSSFile ossFile);
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package digital.system.jeecg.oss.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import digital.system.jeecg.oss.entity.OSSFile;
|
||||
import digital.system.jeecg.oss.mapper.OSSFileMapper;
|
||||
import digital.system.jeecg.oss.service.IOSSFileService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import digital.util.oss.OssBootUtil;
|
||||
import digital.util.util.CommonUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service("ossFileService")
|
||||
public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> implements IOSSFileService {
|
||||
|
||||
@Override
|
||||
public void upload(MultipartFile multipartFile) throws IOException {
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
fileName = CommonUtils.getFileName(fileName);
|
||||
OSSFile ossFile = new OSSFile();
|
||||
ossFile.setFileName(fileName);
|
||||
String url = OssBootUtil.upload(multipartFile,"upload/test");
|
||||
ossFile.setUrl(url);
|
||||
this.save(ossFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(OSSFile ossFile) {
|
||||
try {
|
||||
this.removeById(ossFile.getId());
|
||||
OssBootUtil.deleteUrl(ossFile.getUrl());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package digital.system.jeecg.system.DTO;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* author: smcp
|
||||
* date:2022-08-18 23:19
|
||||
* description:
|
||||
**/
|
||||
@Data
|
||||
public class UserRegisterDTO {
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "手机验证码")
|
||||
private String smscode;
|
||||
|
||||
@ApiModelProperty(value = "账号")
|
||||
private String username;
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import digital.system.jeecg.system.mapper.SysDictMapper;
|
||||
import digital.system.jeecg.system.model.DuplicateCheckVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import digital.base.constant.LanguageTypeConstants;
|
||||
import digital.base.constant.SymbolConstant;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.system.security.DictQueryBlackListHandler;
|
||||
import digital.util.util.SqlInjectionUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Title: DuplicateCheckAction
|
||||
* @Description: 重复校验工具
|
||||
* @Author 张代浩
|
||||
* @Date 2019-03-25
|
||||
* @Version V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/duplicate")
|
||||
@Api(tags = "重复校验")
|
||||
public class DuplicateCheckController {
|
||||
|
||||
@Autowired
|
||||
SysDictMapper sysDictMapper;
|
||||
|
||||
@Autowired
|
||||
DictQueryBlackListHandler dictQueryBlackListHandler;
|
||||
|
||||
/**
|
||||
* 校验数据是否在系统中是否存在
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/check", method = RequestMethod.GET)
|
||||
@ApiOperation("重复校验接口")
|
||||
public Result<String> doDuplicateCheck(DuplicateCheckVo duplicateCheckVo, HttpServletRequest request) {
|
||||
Long num = null;
|
||||
|
||||
log.info("----duplicate check------:" + duplicateCheckVo.toString());
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {duplicateCheckVo.getTableName(), duplicateCheckVo.getFieldName()};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
// update-begin-author:taoyan date:20211227 for: JTC-25 【online报表】oracle 操作问题 录入弹框啥都不填直接保存 ①编码不是应该提示必填么?②报错也应该是具体文字提示,不是后台错误日志
|
||||
if (StringUtils.isEmpty(duplicateCheckVo.getFieldVal())) {
|
||||
Result rs = new Result();
|
||||
rs.setCode(500);
|
||||
rs.setSuccess(true);
|
||||
rs.setMessage("数据为空,不作处理!");
|
||||
return rs;
|
||||
}
|
||||
//update-begin-author:taoyan date:20220329 for: VUEN-223【安全漏洞】当前被攻击的接口
|
||||
String checkSql = duplicateCheckVo.getTableName() + SymbolConstant.COMMA + duplicateCheckVo.getFieldName() + SymbolConstant.COMMA;
|
||||
if (!dictQueryBlackListHandler.isPass(checkSql)) {
|
||||
return Result.error(dictQueryBlackListHandler.getError());
|
||||
}
|
||||
//update-end-author:taoyan date:20220329 for: VUEN-223【安全漏洞】当前被攻击的接口
|
||||
// update-end-author:taoyan date:20211227 for: JTC-25 【online报表】oracle 操作问题 录入弹框啥都不填直接保存 ①编码不是应该提示必填么?②报错也应该是具体文字提示,不是后台错误日志
|
||||
if (StringUtils.isNotBlank(duplicateCheckVo.getDataId())) {
|
||||
// [2].编辑页面校验
|
||||
num = sysDictMapper.duplicateCheckCountSql(duplicateCheckVo);
|
||||
} else {
|
||||
// [1].添加页面校验
|
||||
num = sysDictMapper.duplicateCheckCountSqlNoDataId(duplicateCheckVo);
|
||||
}
|
||||
|
||||
if (num == null || num == 0) {
|
||||
// 该值可用
|
||||
return Result.ok("该值可用!");
|
||||
} else {
|
||||
// 该值不可用
|
||||
log.info("该值不可用,系统中已存在!");
|
||||
return Result.error((LanguageTypeConstants.LANGUAGE_TYPE_DUPLICATE_CHECK));
|
||||
}
|
||||
}
|
||||
}
|
||||
+515
@@ -0,0 +1,515 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysCategory;
|
||||
import digital.system.jeecg.system.model.TreeSelectModel;
|
||||
import digital.system.jeecg.system.service.ISysCategoryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.Result;
|
||||
import digital.bean.jeecg.vo.DictModel;
|
||||
import digital.util.util.ImportExcelUtil;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: zita
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/category")
|
||||
@Slf4j
|
||||
public class SysCategoryController {
|
||||
@Autowired
|
||||
private ISysCategoryService sysCategoryService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCategory
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/rootList")
|
||||
public Result<IPage<SysCategory>> queryPageList(SysCategory sysCategory,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
if (oConvertUtils.isEmpty(sysCategory.getPid())) {
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
|
||||
//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start
|
||||
//--author:liusq---date:20211119 -----for: 【vue3】分类字典页面查询条件配置--------start
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
String name = sysCategory.getName();
|
||||
String code = sysCategory.getCode();
|
||||
//QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<SysCategory>();
|
||||
if (StringUtils.isBlank(name) && StringUtils.isBlank(code)) {
|
||||
queryWrapper.eq("pid", sysCategory.getPid());
|
||||
}
|
||||
//--author:liusq---date:20211119 -----for: 分类字典页面查询条件配置--------end
|
||||
//--author:os_chengtgen---date:20190804 -----for:【vue3】 分类字典页面显示错误,issues:377--------end
|
||||
|
||||
Page<SysCategory> page = new Page<SysCategory>(pageNo, pageSize);
|
||||
IPage<SysCategory> pageList = sysCategoryService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory, HttpServletRequest req) {
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SysCategory> add(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
|
||||
if (sysCategoryEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<SysCategory> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(id);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(ids);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(sysCategory);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
|
||||
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
|
||||
// Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if (oConvertUtils.isEmpty(selections)) {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
} else {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
}
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:" + user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// 错误信息
|
||||
List<String> errorMessage = new ArrayList<>();
|
||||
int successLines = 0, errorLines = 0;
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SysCategory> listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params);
|
||||
//按照编码长度排序
|
||||
Collections.sort(listSysCategorys);
|
||||
log.info("排序后的list====>", listSysCategorys);
|
||||
for (int i = 0; i < listSysCategorys.size(); i++) {
|
||||
SysCategory sysCategoryExcel = listSysCategorys.get(i);
|
||||
String code = sysCategoryExcel.getCode();
|
||||
if (code.length() > 3) {
|
||||
String pCode = sysCategoryExcel.getCode().substring(0, code.length() - 3);
|
||||
log.info("pCode====>", pCode);
|
||||
String pId = sysCategoryService.queryIdByCode(pCode);
|
||||
log.info("pId====>", pId);
|
||||
if (StringUtils.isNotBlank(pId)) {
|
||||
sysCategoryExcel.setPid(pId);
|
||||
}
|
||||
} else {
|
||||
sysCategoryExcel.setPid("0");
|
||||
}
|
||||
try {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
successLines++;
|
||||
} catch (Exception e) {
|
||||
errorLines++;
|
||||
String message = e.getMessage().toLowerCase();
|
||||
int lineNumber = i + 1;
|
||||
// 通过索引名判断出错信息
|
||||
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CATEGORY_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:分类编码已经存在,忽略导入。");
|
||||
} else {
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage.add("发生异常:" + e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
public Result<SysCategory> loadOne(@RequestParam(name = "field") String field, @RequestParam(name = "val") String val) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if (ls == null || ls.size() == 0) {
|
||||
result.setMessage("查询无果");
|
||||
result.setSuccess(false);
|
||||
} else if (ls.size() > 1) {
|
||||
result.setMessage("查询数据异常,[" + field + "]存在多个值:" + val);
|
||||
result.setSuccess(false);
|
||||
} else {
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if (!async) {
|
||||
loadAllCategoryChildren(ls);
|
||||
}
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归求子节点 同步加载用到
|
||||
*/
|
||||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
List<TreeSelectModel> temp = this.sysCategoryService.queryListByPid(tsm.getKey());
|
||||
if (temp != null && temp.size() > 0) {
|
||||
tsm.setChildren(temp);
|
||||
loadAllCategoryChildren(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验编码
|
||||
*
|
||||
* @param pid
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/checkCode")
|
||||
public Result<?> checkCode(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "code", required = false) String code) {
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("错误,类型编码为空!");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
return Result.ok();
|
||||
}
|
||||
SysCategory parent = this.sysCategoryService.getById(pid);
|
||||
if (code.startsWith(parent.getCode())) {
|
||||
return Result.ok();
|
||||
} else {
|
||||
return Result.error("编码不符合规范,须以\"" + parent.getCode() + "\"开头!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类字典树控件 加载节点
|
||||
*
|
||||
* @param pid
|
||||
* @param pcode
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "pcode", required = false) String pcode, @RequestParam(name = "condition", required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
//pid如果传值了 就忽略pcode的作用
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pcode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[null]!");
|
||||
return result;
|
||||
} else {
|
||||
if (ISysCategoryService.ROOT_PID_VALUE.equals(pcode)) {
|
||||
pid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
} else {
|
||||
pid = this.sysCategoryService.queryIdByCode(pcode);
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[code]!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> query = null;
|
||||
if (oConvertUtils.isNotEmpty(condition)) {
|
||||
query = JSON.parseObject(condition, Map.class);
|
||||
}
|
||||
List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid, query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("ids 不能为空");
|
||||
return result;
|
||||
}
|
||||
// 查询数据
|
||||
List<String> textList = sysCategoryService.loadDictItem(ids, delNotExist);
|
||||
result.setSuccess(true);
|
||||
result.setResult(textList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [列表页面]加载分类字典数据 用于值的替换
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name = "code", required = true) String code) {
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
|
||||
if (oConvertUtils.isNotEmpty(code) && !"0".equals(code)) {
|
||||
query.likeRight(SysCategory::getCode, code);
|
||||
}
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
if (list == null || list.size() == 0) {
|
||||
result.setMessage("无数据,参数有误.[code]");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
List<DictModel> rdList = new ArrayList<DictModel>();
|
||||
for (SysCategory c : list) {
|
||||
rdList.add(new DictModel(c.getId(), c.getName()));
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(rdList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id批量查询子节点
|
||||
*
|
||||
* @param parentIds
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getChildListBatch")
|
||||
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
queryWrapper.in("pid", parentIdList);
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
IPage<SysCategory> pageList = new Page<>(1, 10, list.size());
|
||||
pageList.setRecords(list);
|
||||
return Result.OK(pageList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("批量查询子节点失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysCheckRule;
|
||||
import digital.system.jeecg.system.service.ISysCheckRuleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: zita
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "编码校验规则")
|
||||
@RestController
|
||||
@RequestMapping("/sys/checkRule")
|
||||
public class SysCheckRuleController extends JeecgController<SysCheckRule, ISysCheckRuleService> {
|
||||
|
||||
@Autowired
|
||||
private ISysCheckRuleService sysCheckRuleService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-分页列表查询")
|
||||
@ApiOperation(value = "编码校验规则-分页列表查询", notes = "编码校验规则-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result queryPageList(
|
||||
SysCheckRule sysCheckRule,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest request
|
||||
) {
|
||||
QueryWrapper<SysCheckRule> queryWrapper = QueryGenerator.initQueryWrapper(sysCheckRule, request.getParameterMap());
|
||||
Page<SysCheckRule> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysCheckRule> pageList = sysCheckRuleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过Code校验传入的值")
|
||||
@ApiOperation(value = "编码校验规则-通过Code校验传入的值", notes = "编码校验规则-通过Code校验传入的值")
|
||||
@GetMapping(value = "/checkByCode")
|
||||
public Result checkByCode(
|
||||
@RequestParam(name = "ruleCode") String ruleCode,
|
||||
@RequestParam(name = "value") String value
|
||||
) throws UnsupportedEncodingException {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getByCode(ruleCode);
|
||||
if (sysCheckRule == null) {
|
||||
return Result.error("该编码不存在");
|
||||
}
|
||||
JSONObject errorResult = sysCheckRuleService.checkValue(sysCheckRule, URLDecoder.decode(value, "UTF-8"));
|
||||
if (errorResult == null) {
|
||||
return Result.ok();
|
||||
} else {
|
||||
Result<Object> r = Result.error(errorResult.getString("message"));
|
||||
r.setResult(errorResult);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-添加")
|
||||
@ApiOperation(value = "编码校验规则-添加", notes = "编码校验规则-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result add(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.save(sysCheckRule);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-编辑")
|
||||
@ApiOperation(value = "编码校验规则-编辑", notes = "编码校验规则-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result edit(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.updateById(sysCheckRule);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id删除")
|
||||
@ApiOperation(value = "编码校验规则-通过id删除", notes = "编码校验规则-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysCheckRuleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-批量删除")
|
||||
@ApiOperation(value = "编码校验规则-批量删除", notes = "编码校验规则-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.sysCheckRuleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id查询")
|
||||
@ApiOperation(value = "编码校验规则-通过id查询", notes = "编码校验规则-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getById(id);
|
||||
return Result.ok(sysCheckRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysCheckRule
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCheckRule sysCheckRule) {
|
||||
return super.exportXls(request, sysCheckRule, SysCheckRule.class, "编码校验规则");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysCheckRule.class);
|
||||
}
|
||||
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysDataLog;
|
||||
import digital.system.jeecg.system.service.ISysDataLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import digital.base.vo.Result;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 系统数据日志
|
||||
* @author: smcp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/dataLog")
|
||||
@Slf4j
|
||||
public class SysDataLogController {
|
||||
@Autowired
|
||||
private ISysDataLogService service;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysDataLog>> queryPageList(SysDataLog dataLog, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<SysDataLog>> result = new Result<IPage<SysDataLog>>();
|
||||
QueryWrapper<SysDataLog> queryWrapper = QueryGenerator.initQueryWrapper(dataLog, req.getParameterMap());
|
||||
Page<SysDataLog> page = new Page<SysDataLog>(pageNo, pageSize);
|
||||
IPage<SysDataLog> pageList = service.page(page, queryWrapper);
|
||||
log.info("查询当前页:" + pageList.getCurrent());
|
||||
log.info("查询当前页数量:" + pageList.getSize());
|
||||
log.info("查询结果数量:" + pageList.getRecords().size());
|
||||
log.info("数据总数:" + pageList.getTotal());
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询对比数据
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryCompareList", method = RequestMethod.GET)
|
||||
public Result<List<SysDataLog>> queryCompareList(HttpServletRequest req) {
|
||||
Result<List<SysDataLog>> result = new Result<>();
|
||||
String dataId1 = req.getParameter("dataId1");
|
||||
String dataId2 = req.getParameter("dataId2");
|
||||
List<String> idList = new ArrayList<String>();
|
||||
idList.add(dataId1);
|
||||
idList.add(dataId2);
|
||||
try {
|
||||
List<SysDataLog> list = (List<SysDataLog>) service.listByIds(idList);
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询版本信息
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDataVerList", method = RequestMethod.GET)
|
||||
public Result<List<SysDataLog>> queryDataVerList(HttpServletRequest req) {
|
||||
Result<List<SysDataLog>> result = new Result<>();
|
||||
String dataTable = req.getParameter("dataTable");
|
||||
String dataId = req.getParameter("dataId");
|
||||
QueryWrapper<SysDataLog> queryWrapper = new QueryWrapper<SysDataLog>();
|
||||
queryWrapper.eq("data_table", dataTable);
|
||||
queryWrapper.eq("data_id", dataId);
|
||||
List<SysDataLog> list = service.list(queryWrapper);
|
||||
if (list == null || list.size() <= 0) {
|
||||
result.error500("未找到版本信息");
|
||||
} else {
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//import digital.base.annotation.AutoLog;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
//import digital.system.jeecg.group.query.QueryGenerator;
|
||||
//import digital.system.jeecg.group.util.db.DataSourceCachePool;
|
||||
//import digital.system.jeecg.system.entity.SysDataSource;
|
||||
//import digital.system.jeecg.system.service.ISysDataSourceService;
|
||||
//import digital.system.jeecg.system.util.SecurityUtil;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @Description: 多数据源管理
|
||||
// * @Author: zita
|
||||
// * @Date: 2019-12-25
|
||||
// * @Version: V1.0
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Api(tags = "多数据源管理")
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/dataSource")
|
||||
//public class SysDataSourceController extends JeecgController<SysDataSource, ISysDataSourceService> {
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysDataSourceService sysDataSourceService;
|
||||
//
|
||||
// /**
|
||||
// * 分页列表查询
|
||||
// *
|
||||
// * @param sysDataSource
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param req
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-分页列表查询")
|
||||
// @ApiOperation(value = "多数据源管理-分页列表查询", notes = "多数据源管理-分页列表查询")
|
||||
// //@RequiresRoles("admin")
|
||||
// @GetMapping(value = "/list")
|
||||
// public Result<?> queryPageList(
|
||||
// SysDataSource sysDataSource,
|
||||
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
// HttpServletRequest req
|
||||
// ) {
|
||||
// QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
// Page<SysDataSource> page = new Page<>(pageNo, pageSize);
|
||||
// IPage<SysDataSource> pageList = sysDataSourceService.page(page, queryWrapper);
|
||||
// try {
|
||||
// List<SysDataSource> records = pageList.getRecords();
|
||||
// records.forEach(item -> {
|
||||
// String dbPassword = item.getDbPassword();
|
||||
// if (StringUtils.isNotBlank(dbPassword)) {
|
||||
// String decodedStr = SecurityUtil.jiemi(dbPassword);
|
||||
// item.setDbPassword(decodedStr);
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return Result.ok(pageList);
|
||||
// }
|
||||
//
|
||||
// @GetMapping(value = "/options")
|
||||
// public Result<?> queryOptions(SysDataSource sysDataSource, HttpServletRequest req) {
|
||||
// QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
// List<SysDataSource> pageList = sysDataSourceService.list(queryWrapper);
|
||||
// JSONArray array = new JSONArray(pageList.size());
|
||||
// for (SysDataSource item : pageList) {
|
||||
// JSONObject option = new JSONObject(3);
|
||||
// option.put("value", item.getCode());
|
||||
// option.put("label", item.getName());
|
||||
// option.put("text", item.getName());
|
||||
// array.add(option);
|
||||
// }
|
||||
// return Result.ok(array);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加
|
||||
// *
|
||||
// * @param sysDataSource
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-添加")
|
||||
// @ApiOperation(value = "多数据源管理-添加", notes = "多数据源管理-添加")
|
||||
// @PostMapping(value = "/add")
|
||||
// public Result<?> add(@RequestBody SysDataSource sysDataSource) {
|
||||
// try {
|
||||
// String dbPassword = sysDataSource.getDbPassword();
|
||||
// if (StringUtils.isNotBlank(dbPassword)) {
|
||||
// String encrypt = SecurityUtil.jiami(dbPassword);
|
||||
// sysDataSource.setDbPassword(encrypt);
|
||||
// }
|
||||
// sysDataSourceService.save(sysDataSource);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return Result.ok("添加成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// *
|
||||
// * @param sysDataSource
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-编辑")
|
||||
// @ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
|
||||
// @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
|
||||
// try {
|
||||
// SysDataSource d = sysDataSourceService.getById(sysDataSource.getId());
|
||||
// DataSourceCachePool.removeCache(d.getCode());
|
||||
// String dbPassword = sysDataSource.getDbPassword();
|
||||
// if (StringUtils.isNotBlank(dbPassword)) {
|
||||
// String encrypt = SecurityUtil.jiami(dbPassword);
|
||||
// sysDataSource.setDbPassword(encrypt);
|
||||
// }
|
||||
// sysDataSourceService.updateById(sysDataSource);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return Result.ok("编辑成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-通过id删除")
|
||||
// @ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
|
||||
// @DeleteMapping(value = "/delete")
|
||||
// public Result<?> delete(@RequestParam(name = "id") String id) {
|
||||
// SysDataSource sysDataSource = sysDataSourceService.getById(id);
|
||||
// DataSourceCachePool.removeCache(sysDataSource.getCode());
|
||||
// sysDataSourceService.removeById(id);
|
||||
// return Result.ok("删除成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除
|
||||
// *
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-批量删除")
|
||||
// @ApiOperation(value = "多数据源管理-批量删除", notes = "多数据源管理-批量删除")
|
||||
// @DeleteMapping(value = "/deleteBatch")
|
||||
// public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
// List<String> idList = Arrays.asList(ids.split(","));
|
||||
// idList.forEach(item -> {
|
||||
// SysDataSource sysDataSource = sysDataSourceService.getById(item);
|
||||
// DataSourceCachePool.removeCache(sysDataSource.getCode());
|
||||
// });
|
||||
// this.sysDataSourceService.removeByIds(idList);
|
||||
// return Result.ok("批量删除成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id查询
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @AutoLog(value = "多数据源管理-通过id查询")
|
||||
// @ApiOperation(value = "多数据源管理-通过id查询", notes = "多数据源管理-通过id查询")
|
||||
// @GetMapping(value = "/queryById")
|
||||
// public Result<?> queryById(@RequestParam(name = "id") String id) {
|
||||
// SysDataSource sysDataSource = sysDataSourceService.getById(id);
|
||||
// return Result.ok(sysDataSource);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出excel
|
||||
// *
|
||||
// * @param request
|
||||
// * @param sysDataSource
|
||||
// */
|
||||
// @RequestMapping(value = "/exportXls")
|
||||
// public ModelAndView exportXls(HttpServletRequest request, SysDataSource sysDataSource) {
|
||||
// return super.exportXls(request, sysDataSource, SysDataSource.class, "多数据源管理");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过excel导入数据
|
||||
// *
|
||||
// * @param request
|
||||
// * @param response
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
// public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// return super.importExcel(request, response, SysDataSource.class);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+629
@@ -0,0 +1,629 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//import org.jeecgframework.poi.excel.ExcelImportCheckUtil;
|
||||
//import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
//import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
//import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
//import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
//import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//import digital.base.constant.CacheConstant;
|
||||
//import digital.base.constant.CommonConstant;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.bean.jeecg.vo.DictModel;
|
||||
//import digital.bean.jeecg.vo.DictQuery;
|
||||
//import digital.system.jeecg.group.query.QueryGenerator;
|
||||
//import digital.system.jeecg.system.entity.SysDict;
|
||||
//import digital.system.jeecg.system.entity.SysDictItem;
|
||||
//import digital.system.jeecg.system.model.SysDictTree;
|
||||
//import digital.system.jeecg.system.model.TreeSelectModel;
|
||||
//import digital.system.jeecg.system.security.DictQueryBlackListHandler;
|
||||
//import digital.system.jeecg.system.service.ISysDictItemService;
|
||||
//import digital.system.jeecg.system.service.ISysDictService;
|
||||
//import digital.system.jeecg.system.vo.SysDictPage;
|
||||
//import digital.util.util.ImportExcelUtil;
|
||||
//import digital.util.util.SqlInjectionUtil;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.util.*;
|
||||
//
|
||||
///**
|
||||
// * <p>
|
||||
// * 字典表 前端控制器
|
||||
// * </p>
|
||||
// *
|
||||
// * @Author zhangweijian
|
||||
// * @since 2018-12-28
|
||||
// */
|
||||
//@Api(tags = "字典表 前端控制器")
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/dict")
|
||||
//@Slf4j
|
||||
//public class SysDictController {
|
||||
//
|
||||
// @Autowired
|
||||
// public RedisTemplate<String, Object> redisTemplate;
|
||||
// @Autowired
|
||||
// private ISysDictService sysDictService;
|
||||
// @Autowired
|
||||
// private ISysDictItemService sysDictItemService;
|
||||
// @Autowired
|
||||
// private DictQueryBlackListHandler dictQueryBlackListHandler;
|
||||
//
|
||||
// @RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
// public Result<IPage<SysDict>> queryPageList(SysDict sysDict, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
// Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
|
||||
// QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
|
||||
// queryWrapper.lambda().orderByDesc(SysDict::getCreateTime);
|
||||
// Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
|
||||
// IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
|
||||
// log.debug("查询当前页:" + pageList.getCurrent());
|
||||
// log.debug("查询当前页数量:" + pageList.getSize());
|
||||
// log.debug("查询结果数量:" + pageList.getRecords().size());
|
||||
// log.debug("数据总数:" + pageList.getTotal());
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(pageList);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param sysDict
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param req
|
||||
// * @return
|
||||
// * @功能:获取树形字典数据
|
||||
// */
|
||||
// @SuppressWarnings("unchecked")
|
||||
// @RequestMapping(value = "/treeList", method = RequestMethod.GET)
|
||||
// public Result<List<SysDictTree>> treeList(SysDict sysDict, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
// Result<List<SysDictTree>> result = new Result<>();
|
||||
// LambdaQueryWrapper<SysDict> query = new LambdaQueryWrapper<>();
|
||||
// // 构造查询条件
|
||||
// String dictName = sysDict.getDictName();
|
||||
// if (oConvertUtils.isNotEmpty(dictName)) {
|
||||
// query.like(true, SysDict::getDictName, dictName);
|
||||
// }
|
||||
// query.orderByDesc(true, SysDict::getCreateTime);
|
||||
// List<SysDict> list = sysDictService.list(query);
|
||||
// List<SysDictTree> treeList = new ArrayList<>();
|
||||
// for (SysDict node : list) {
|
||||
// treeList.add(new SysDictTree(node));
|
||||
// }
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(treeList);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取全部字典数据
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryAllDictItems", method = RequestMethod.GET)
|
||||
// public Result<?> queryAllDictItems(HttpServletRequest request) {
|
||||
// Map<String, List<DictModel>> res = new HashMap(5);
|
||||
// res = sysDictService.queryAllDictItems();
|
||||
// return Result.ok(res);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取字典数据
|
||||
// *
|
||||
// * @param dictCode
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getDictText/{dictCode}/{key}", method = RequestMethod.GET)
|
||||
// public Result<String> getDictText(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key) {
|
||||
// log.info(" dictCode : " + dictCode);
|
||||
// Result<String> result = new Result<String>();
|
||||
// String text = null;
|
||||
// try {
|
||||
// text = sysDictService.queryDictTextByKey(dictCode, key);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(text);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// return result;
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 获取字典数据 【接口签名验证】
|
||||
// *
|
||||
// * @param dictCode 字典code
|
||||
// * @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
// public Result<List<DictModel>> getDictItems(@PathVariable("dictCode") String dictCode,
|
||||
// @RequestParam(value = "sign", required = false) String sign,
|
||||
// HttpServletRequest request) {
|
||||
// log.info(" dictCode ===============================: " + dictCode);
|
||||
// Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
// //update-begin-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// if (!dictQueryBlackListHandler.isPass(dictCode)) {
|
||||
// return result.error500(dictQueryBlackListHandler.getError());
|
||||
// }
|
||||
// //update-end-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// try {
|
||||
// List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
// if (ls == null) {
|
||||
// result.error500("字典Code格式不正确!");
|
||||
// return result;
|
||||
// }
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(ls);
|
||||
// log.debug(result.toString());
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// return result;
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【接口签名验证】
|
||||
// * 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
// * 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
// *
|
||||
// * @param dictCode 字典code格式:table,text,code
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
// public Result<List<DictModel>> loadDict(@PathVariable("dictCode") String dictCode,
|
||||
// @RequestParam(name = "keyword", required = false) String keyword,
|
||||
// @RequestParam(value = "sign", required = false) String sign,
|
||||
// @RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
// log.info(" 加载字典表数据,加载关键字: " + keyword);
|
||||
// Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
// //update-begin-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// if (!dictQueryBlackListHandler.isPass(dictCode)) {
|
||||
// return result.error500(dictQueryBlackListHandler.getError());
|
||||
// }
|
||||
// //update-end-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// try {
|
||||
// List<DictModel> ls = sysDictService.loadDict(dictCode, keyword, pageSize);
|
||||
// if (ls == null) {
|
||||
// result.error500("字典Code格式不正确!");
|
||||
// return result;
|
||||
// }
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(ls);
|
||||
// log.info(result.toString());
|
||||
// return result;
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【接口签名验证】
|
||||
// * 【给表单设计器的表字典使用】下拉搜索模式,有值时动态拼接数据
|
||||
// *
|
||||
// * @param dictCode
|
||||
// * @param keyword 当前控件的值,可以逗号分割
|
||||
// * @param sign
|
||||
// * @param pageSize
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
|
||||
// public Result<List<DictModel>> loadDictOrderByValue(
|
||||
// @PathVariable("dictCode") String dictCode,
|
||||
// @RequestParam(name = "keyword") String keyword,
|
||||
// @RequestParam(value = "sign", required = false) String sign,
|
||||
// @RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
// // 首次查询查出来用户选中的值,并且不分页
|
||||
// Result<List<DictModel>> firstRes = this.loadDict(dictCode, keyword, sign, null);
|
||||
// if (!firstRes.isSuccess()) {
|
||||
// return firstRes;
|
||||
// }
|
||||
// // 然后再查询出第一页的数据
|
||||
// Result<List<DictModel>> result = this.loadDict(dictCode, "", sign, pageSize);
|
||||
// if (!result.isSuccess()) {
|
||||
// return result;
|
||||
// }
|
||||
// // 合并两次查询的数据
|
||||
// List<DictModel> firstList = firstRes.getResult();
|
||||
// List<DictModel> list = result.getResult();
|
||||
// for (DictModel firstItem : firstList) {
|
||||
// // anyMatch 表示:判断的条件里,任意一个元素匹配成功,返回true
|
||||
// // allMatch 表示:判断条件里的元素,所有的都匹配成功,返回true
|
||||
// // noneMatch 跟 allMatch 相反,表示:判断条件里的元素,所有的都匹配失败,返回true
|
||||
// boolean none = list.stream().noneMatch(item -> item.getValue().equals(firstItem.getValue()));
|
||||
// // 当元素不存在时,再添加到集合里
|
||||
// if (none) {
|
||||
// list.add(0, firstItem);
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【接口签名验证】
|
||||
// * 根据字典code加载字典text 返回
|
||||
// *
|
||||
// * @param dictCode 顺序:tableName,text,code
|
||||
// * @param keys 要查询的key
|
||||
// * @param sign
|
||||
// * @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
// * @param request
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
// public Result<List<String>> loadDictItem(@PathVariable("dictCode") String dictCode, @RequestParam(name = "key") String keys, @RequestParam(value = "sign", required = false) String sign, @RequestParam(value = "delNotExist", required = false, defaultValue = "true") boolean delNotExist, HttpServletRequest request) {
|
||||
// Result<List<String>> result = new Result<>();
|
||||
// //update-begin-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// if (!dictQueryBlackListHandler.isPass(dictCode)) {
|
||||
// return result.error500(dictQueryBlackListHandler.getError());
|
||||
// }
|
||||
// //update-end-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口,加一些安全机制
|
||||
// try {
|
||||
// if (dictCode.indexOf(",") != -1) {
|
||||
// String[] params = dictCode.split(",");
|
||||
// if (params.length != 3) {
|
||||
// result.error500("字典Code格式不正确!");
|
||||
// return result;
|
||||
// }
|
||||
// List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys, delNotExist);
|
||||
//
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(texts);
|
||||
// log.info(result.toString());
|
||||
// } else {
|
||||
// result.error500("字典Code格式不正确!");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【接口签名验证】
|
||||
// * 根据表名——显示字段-存储字段 pid 加载树形数据
|
||||
// */
|
||||
// @SuppressWarnings("unchecked")
|
||||
// @RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
// public Result<List<TreeSelectModel>> loadTreeData(@RequestParam(name = "pid") String pid, @RequestParam(name = "pidField") String pidField,
|
||||
// @RequestParam(name = "tableName") String tbname,
|
||||
// @RequestParam(name = "text") String text,
|
||||
// @RequestParam(name = "code") String code,
|
||||
// @RequestParam(name = "hasChildField") String hasChildField,
|
||||
// @RequestParam(name = "condition") String condition,
|
||||
// @RequestParam(value = "sign", required = false) String sign, HttpServletRequest request) {
|
||||
// Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
// Map<String, String> query = null;
|
||||
// if (oConvertUtils.isNotEmpty(condition)) {
|
||||
// query = JSON.parseObject(condition, Map.class);
|
||||
// }
|
||||
// // SQL注入漏洞 sign签名校验(表名,label字段,val字段,条件)
|
||||
// String dictCode = tbname + "," + text + "," + code + "," + condition;
|
||||
// SqlInjectionUtil.filterContent(dictCode);
|
||||
// List<TreeSelectModel> ls = sysDictService.queryTreeList(query, tbname, text, code, pidField, pid, hasChildField);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(ls);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【APP接口】根据字典配置查询表字典数据(目前暂未找到调用的地方)
|
||||
// *
|
||||
// * @param query
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @return
|
||||
// */
|
||||
// @Deprecated
|
||||
// @GetMapping("/queryTableData")
|
||||
// public Result<List<DictModel>> queryTableData(DictQuery query,
|
||||
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
// @RequestParam(value = "sign", required = false) String sign, HttpServletRequest request) {
|
||||
// Result<List<DictModel>> res = new Result<List<DictModel>>();
|
||||
// // SQL注入漏洞 sign签名校验
|
||||
// String dictCode = query.getTable() + "," + query.getText() + "," + query.getCode();
|
||||
// SqlInjectionUtil.filterContent(dictCode);
|
||||
// List<DictModel> ls = this.sysDictService.queryDictTablePageList(query, pageSize, pageNo);
|
||||
// res.setResult(ls);
|
||||
// res.setSuccess(true);
|
||||
// return res;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param sysDict
|
||||
// * @return
|
||||
// * @功能:新增
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// public Result<SysDict> add(@RequestBody SysDict sysDict) {
|
||||
// Result<SysDict> result = new Result<SysDict>();
|
||||
// try {
|
||||
// sysDict.setCreateTime(new Date());
|
||||
// sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
// sysDictService.save(sysDict);
|
||||
// result.success("保存成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param sysDict
|
||||
// * @return
|
||||
// * @功能:编辑
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<SysDict> edit(@RequestBody SysDict sysDict) {
|
||||
// Result<SysDict> result = new Result<SysDict>();
|
||||
// SysDict sysdict = sysDictService.getById(sysDict.getId());
|
||||
// if (sysdict == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// sysDict.setUpdateTime(new Date());
|
||||
// boolean ok = sysDictService.updateById(sysDict);
|
||||
// if (ok) {
|
||||
// result.success("编辑成功!");
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param id
|
||||
// * @return
|
||||
// * @功能:删除
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
// @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
// public Result<SysDict> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysDict> result = new Result<SysDict>();
|
||||
// boolean ok = sysDictService.removeById(id);
|
||||
// if (ok) {
|
||||
// result.success("删除成功!");
|
||||
// } else {
|
||||
// result.error500("删除失败!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param ids
|
||||
// * @return
|
||||
// * @功能:批量删除
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
// @CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
// public Result<SysDict> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
// Result<SysDict> result = new Result<SysDict>();
|
||||
// if (oConvertUtils.isEmpty(ids)) {
|
||||
// result.error500("参数不识别!");
|
||||
// } else {
|
||||
// sysDictService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
// result.success("删除成功!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return
|
||||
// * @功能:刷新缓存
|
||||
// */
|
||||
// @RequestMapping(value = "/refleshCache")
|
||||
// public Result<?> refleshCache() {
|
||||
// Result<?> result = new Result<SysDict>();
|
||||
// //清空字典缓存
|
||||
// Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
|
||||
// Set keys7 = redisTemplate.keys(CacheConstant.SYS_ENABLE_DICT_CACHE + "*");
|
||||
// Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
|
||||
// Set keys21 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_BY_KEYS_CACHE + "*");
|
||||
// Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
|
||||
// Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
|
||||
// Set keys5 = redisTemplate.keys("jmreport:cache:dict*");
|
||||
// Set keys6 = redisTemplate.keys("jmreport:cache:dictTable*");
|
||||
// redisTemplate.delete(keys);
|
||||
// redisTemplate.delete(keys2);
|
||||
// redisTemplate.delete(keys21);
|
||||
// redisTemplate.delete(keys3);
|
||||
// redisTemplate.delete(keys4);
|
||||
// redisTemplate.delete(keys5);
|
||||
// redisTemplate.delete(keys6);
|
||||
// redisTemplate.delete(keys7);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出excel
|
||||
// *
|
||||
// * @param request
|
||||
// */
|
||||
// @RequestMapping(value = "/exportXls")
|
||||
// public ModelAndView exportXls(SysDict sysDict, HttpServletRequest request) {
|
||||
// // Step.1 组装查询条件
|
||||
// QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
|
||||
// //Step.2 AutoPoi 导出Excel
|
||||
// ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// List<SysDictPage> pageList = new ArrayList<SysDictPage>();
|
||||
//
|
||||
// List<SysDict> sysDictList = sysDictService.list(queryWrapper);
|
||||
// for (SysDict dictMain : sysDictList) {
|
||||
// SysDictPage vo = new SysDictPage();
|
||||
// BeanUtils.copyProperties(dictMain, vo);
|
||||
// // 查询机票
|
||||
// List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByMainId(dictMain.getId());
|
||||
// vo.setSysDictItemList(sysDictItemList);
|
||||
// pageList.add(vo);
|
||||
// }
|
||||
//
|
||||
// // 导出文件名称
|
||||
// mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
|
||||
// // 注解对象Class
|
||||
// mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
|
||||
// // 自定义表格参数
|
||||
// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:" + user.getRealname(), "数据字典"));
|
||||
// // 导出数据列表
|
||||
// mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
// return mv;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过excel导入数据
|
||||
// *
|
||||
// * @param request
|
||||
// * @param
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
// public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
// Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// // 获取上传文件对象
|
||||
// MultipartFile file = entity.getValue();
|
||||
// ImportParams params = new ImportParams();
|
||||
// params.setTitleRows(2);
|
||||
// params.setHeadRows(2);
|
||||
// params.setNeedSave(true);
|
||||
// try {
|
||||
// //导入Excel格式校验,看匹配的字段文本概率
|
||||
// Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), SysDictPage.class, params);
|
||||
// if (t != null && !t) {
|
||||
// throw new RuntimeException("导入Excel校验失败 !");
|
||||
// }
|
||||
// List<SysDictPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SysDictPage.class, params);
|
||||
// // 错误信息
|
||||
// List<String> errorMessage = new ArrayList<>();
|
||||
// int successLines = 0, errorLines = 0;
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// SysDict po = new SysDict();
|
||||
// BeanUtils.copyProperties(list.get(i), po);
|
||||
// po.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
// try {
|
||||
// Integer integer = sysDictService.saveMain(po, list.get(i).getSysDictItemList());
|
||||
// if (integer > 0) {
|
||||
// successLines++;
|
||||
// //update-begin---author:wangshuai ---date:20220211 for:[JTC-1168]如果字典项值为空,则字典项忽略导入------------
|
||||
// } else if (integer == -1) {
|
||||
// errorLines++;
|
||||
// errorMessage.add("字典名称:" + po.getDictName() + ",对应字典列表的字典项值不能为空,忽略导入。");
|
||||
// } else {
|
||||
// //update-end---author:wangshuai ---date:20220211 for:[JTC-1168]如果字典项值为空,则字典项忽略导入------------
|
||||
// errorLines++;
|
||||
// int lineNumber = i + 1;
|
||||
// //update-begin---author:wangshuai ---date:20220209 for:[JTC-1168]字典编号不能为空------------
|
||||
// if (oConvertUtils.isEmpty(po.getDictCode())) {
|
||||
// errorMessage.add("第 " + lineNumber + " 行:字典编码不能为空,忽略导入。");
|
||||
// } else {
|
||||
// errorMessage.add("第 " + lineNumber + " 行:字典编码已经存在,忽略导入。");
|
||||
// }
|
||||
// //update-end---author:wangshuai ---date:20220209 for:[JTC-1168]字典编号不能为空------------
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// errorLines++;
|
||||
// int lineNumber = i + 1;
|
||||
// errorMessage.add("第 " + lineNumber + " 行:字典编码已经存在,忽略导入。");
|
||||
// }
|
||||
// }
|
||||
// return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// return Result.error("文件导入失败:" + e.getMessage());
|
||||
// } finally {
|
||||
// try {
|
||||
// file.getInputStream().close();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return Result.error("文件导入失败!");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 查询被删除的列表
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/deleteList", method = RequestMethod.GET)
|
||||
// public Result<List<SysDict>> deleteList() {
|
||||
// Result<List<SysDict>> result = new Result<List<SysDict>>();
|
||||
// List<SysDict> list = this.sysDictService.queryDeleteList();
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(list);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 物理删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/deletePhysic/{id}", method = RequestMethod.DELETE)
|
||||
// public Result<?> deletePhysic(@PathVariable("id") String id) {
|
||||
// try {
|
||||
// sysDictService.deleteOneDictPhysically(id);
|
||||
// return Result.ok("删除成功!");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return Result.error("删除失败!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 逻辑删除的字段,进行取回
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/back/{id}", method = RequestMethod.PUT)
|
||||
// public Result<?> back(@PathVariable("id") String id) {
|
||||
// try {
|
||||
// sysDictService.updateDictDelFlag(0, id);
|
||||
// return Result.ok("操作成功!");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return Result.error("操作失败!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysDictItem;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import digital.base.constant.CacheConstant;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.system.service.ISysDictItemService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @Author zhangweijian
|
||||
* @since 2018-12-28
|
||||
*/
|
||||
@Api(tags = "数据字典")
|
||||
@RestController
|
||||
@RequestMapping("/sys/dictItem")
|
||||
@Slf4j
|
||||
public class SysDictItemController {
|
||||
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
|
||||
/**
|
||||
* @param sysDictItem
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
* @功能:查询字典数据
|
||||
*/
|
||||
@ApiOperation(value = "查询字典数据")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysDictItem>> queryPageList(SysDictItem sysDictItem, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<SysDictItem>> result = new Result<IPage<SysDictItem>>();
|
||||
QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("sort_order");
|
||||
Page<SysDictItem> page = new Page<SysDictItem>(pageNo, pageSize);
|
||||
IPage<SysDictItem> pageList = sysDictItemService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @功能:新增
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
try {
|
||||
sysDictItem.setCreateTime(new Date());
|
||||
sysDictItemService.save(sysDictItem);
|
||||
result.success("保存成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sysDictItem
|
||||
* @return
|
||||
* @功能:编辑
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
@CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
public Result<SysDictItem> edit(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
SysDictItem sysdict = sysDictItemService.getById(sysDictItem.getId());
|
||||
if (sysdict == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
sysDictItem.setUpdateTime(new Date());
|
||||
boolean ok = sysDictItemService.updateById(sysDictItem);
|
||||
//TODO 返回false说明什么?
|
||||
if (ok) {
|
||||
result.success("编辑成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* @功能:删除字典数据
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
public Result<SysDictItem> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
SysDictItem joinSystem = sysDictItemService.getById(id);
|
||||
if (joinSystem == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = sysDictItemService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ids
|
||||
* @return
|
||||
* @功能:批量删除字典数据
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value = {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries = true)
|
||||
public Result<SysDictItem> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.sysDictItemService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典值重复校验
|
||||
*
|
||||
* @param sysDictItem
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/dictItemCheck", method = RequestMethod.GET)
|
||||
@ApiOperation("字典重复校验接口")
|
||||
public Result<Object> doDictItemCheck(SysDictItem sysDictItem, HttpServletRequest request) {
|
||||
Long num = Long.valueOf(0);
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
|
||||
queryWrapper.eq(SysDictItem::getItemValue, sysDictItem.getItemValue());
|
||||
queryWrapper.eq(SysDictItem::getDictId, sysDictItem.getDictId());
|
||||
if (StringUtils.isNotBlank(sysDictItem.getId())) {
|
||||
// 编辑页面校验
|
||||
queryWrapper.ne(SysDictItem::getId, sysDictItem.getId());
|
||||
}
|
||||
num = sysDictItemService.count(queryWrapper);
|
||||
if (num == 0) {
|
||||
// 该值可用
|
||||
return Result.ok("该值可用!");
|
||||
} else {
|
||||
// 该值不可用
|
||||
log.info("该值不可用,系统中已存在!");
|
||||
return Result.error("该值不可用,系统中已存在!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysFillRule;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
import digital.system.jeecg.system.service.ISysFillRuleService;
|
||||
import digital.util.util.FillRuleUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 填值规则
|
||||
* @Author: zita
|
||||
* @Date: 2019-11-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "填值规则")
|
||||
@RestController
|
||||
@RequestMapping("/sys/fillRule")
|
||||
public class SysFillRuleController extends JeecgController<SysFillRule, ISysFillRuleService> {
|
||||
@Autowired
|
||||
private ISysFillRuleService sysFillRuleService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysFillRule
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-分页列表查询")
|
||||
@ApiOperation(value = "填值规则-分页列表查询", notes = "填值规则-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysFillRule sysFillRule,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysFillRule> queryWrapper = QueryGenerator.initQueryWrapper(sysFillRule, req.getParameterMap());
|
||||
Page<SysFillRule> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysFillRule> pageList = sysFillRuleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 ruleCode
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/testFillRule")
|
||||
public Result testFillRule(@RequestParam("ruleCode") String ruleCode) {
|
||||
Object result = FillRuleUtil.executeRule(ruleCode, new JSONObject());
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysFillRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-添加")
|
||||
@ApiOperation(value = "填值规则-添加", notes = "填值规则-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysFillRule sysFillRule) {
|
||||
sysFillRuleService.save(sysFillRule);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysFillRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-编辑")
|
||||
@ApiOperation(value = "填值规则-编辑", notes = "填值规则-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<?> edit(@RequestBody SysFillRule sysFillRule) {
|
||||
sysFillRuleService.updateById(sysFillRule);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-通过id删除")
|
||||
@ApiOperation(value = "填值规则-通过id删除", notes = "填值规则-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysFillRuleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-批量删除")
|
||||
@ApiOperation(value = "填值规则-批量删除", notes = "填值规则-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.sysFillRuleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "填值规则-通过id查询")
|
||||
@ApiOperation(value = "填值规则-通过id查询", notes = "填值规则-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysFillRule sysFillRule = sysFillRuleService.getById(id);
|
||||
return Result.ok(sysFillRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysFillRule
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysFillRule sysFillRule) {
|
||||
return super.exportXls(request, sysFillRule, SysFillRule.class, "填值规则");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysFillRule.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 ruleCode 执行自定义填值规则
|
||||
*
|
||||
* @param ruleCode 要执行的填值规则编码
|
||||
* @param formData 表单数据,可根据表单数据的不同生成不同的填值结果
|
||||
* @return 运行后的结果
|
||||
*/
|
||||
@PutMapping("/executeRuleByCode/{ruleCode}")
|
||||
public Result executeByRuleCode(@PathVariable("ruleCode") String ruleCode, @RequestBody JSONObject formData) {
|
||||
Object result = FillRuleUtil.executeRule(ruleCode, formData);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量通过 ruleCode 执行自定义填值规则
|
||||
*
|
||||
* @param ruleData 要执行的填值规则JSON数组:
|
||||
* 示例: { "commonFormData": {}, rules: [ { "ruleCode": "xxx", "formData": null } ] }
|
||||
* @return 运行后的结果,返回示例: [{"ruleCode": "order_num_rule", "result": "CN2019111117212984"}]
|
||||
*/
|
||||
@PutMapping("/executeRuleByCodeBatch")
|
||||
public Result executeByRuleCodeBatch(@RequestBody JSONObject ruleData) {
|
||||
JSONObject commonFormData = ruleData.getJSONObject("commonFormData");
|
||||
JSONArray rules = ruleData.getJSONArray("rules");
|
||||
// 遍历 rules ,批量执行规则
|
||||
JSONArray results = new JSONArray(rules.size());
|
||||
for (int i = 0; i < rules.size(); i++) {
|
||||
JSONObject rule = rules.getJSONObject(i);
|
||||
String ruleCode = rule.getString("ruleCode");
|
||||
JSONObject formData = rule.getJSONObject("formData");
|
||||
// 如果没有传递 formData,就用common的
|
||||
if (formData == null) {
|
||||
formData = commonFormData;
|
||||
}
|
||||
// 执行填值规则
|
||||
Object result = FillRuleUtil.executeRule(ruleCode, formData);
|
||||
JSONObject obj = new JSONObject(rules.size());
|
||||
obj.put("ruleCode", ruleCode);
|
||||
obj.put("result", result);
|
||||
results.add(obj);
|
||||
}
|
||||
return Result.ok(results);
|
||||
}
|
||||
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
//import digital.system.jeecg.system.entity.SysGatewayRoute;
|
||||
//import digital.system.jeecg.system.service.ISysGatewayRouteService;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @Description: gateway路由管理
|
||||
// * @Author: zita
|
||||
// * @Date: 2020-05-26
|
||||
// * @Version: V1.0
|
||||
// */
|
||||
//@Api(tags = "gateway路由管理")
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/gatewayRoute")
|
||||
//@Slf4j
|
||||
//public class SysGatewayRouteController extends JeecgController<SysGatewayRoute, ISysGatewayRouteService> {
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysGatewayRouteService sysGatewayRouteService;
|
||||
//
|
||||
// @PostMapping(value = "/updateAll")
|
||||
// public Result<?> updateAll(@RequestBody JSONObject json) {
|
||||
// sysGatewayRouteService.updateAll(json);
|
||||
// return Result.ok("操作成功!");
|
||||
// }
|
||||
//
|
||||
// @GetMapping(value = "/list")
|
||||
// public Result<?> queryPageList(SysGatewayRoute sysGatewayRoute) {
|
||||
// LambdaQueryWrapper<SysGatewayRoute> query = new LambdaQueryWrapper<>();
|
||||
// List<SysGatewayRoute> ls = sysGatewayRouteService.list(query);
|
||||
// JSONArray array = new JSONArray();
|
||||
// for (SysGatewayRoute rt : ls) {
|
||||
// JSONObject obj = (JSONObject) JSONObject.toJSON(rt);
|
||||
// if (oConvertUtils.isNotEmpty(rt.getPredicates())) {
|
||||
// obj.put("predicates", JSONArray.parseArray(rt.getPredicates()));
|
||||
// }
|
||||
// if (oConvertUtils.isNotEmpty(rt.getFilters())) {
|
||||
// obj.put("filters", JSONArray.parseArray(rt.getFilters()));
|
||||
// }
|
||||
// array.add(obj);
|
||||
// }
|
||||
// return Result.ok(array);
|
||||
// }
|
||||
//
|
||||
// @GetMapping(value = "/clearRedis")
|
||||
// public Result<?> clearRedis() {
|
||||
// sysGatewayRouteService.clearRedis();
|
||||
// return Result.ok("清除成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({"admin"})
|
||||
// @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
// public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// sysGatewayRouteService.deleteById(id);
|
||||
// return Result.ok("删除路由成功");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysLog;
|
||||
import digital.system.jeecg.system.entity.SysRole;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.system.service.ISysLogService;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统日志表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @Author zhangweijian
|
||||
* @since 2018-12-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/log")
|
||||
@Slf4j
|
||||
public class SysLogController {
|
||||
|
||||
@Autowired
|
||||
private ISysLogService sysLogService;
|
||||
|
||||
/**
|
||||
* @param syslog
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
* @功能:查询日志记录
|
||||
*/
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysLog>> queryPageList(SysLog syslog, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<SysLog>> result = new Result<IPage<SysLog>>();
|
||||
QueryWrapper<SysLog> queryWrapper = QueryGenerator.initQueryWrapper(syslog, req.getParameterMap());
|
||||
queryWrapper.lambda().orderByDesc(SysLog::getCreateTime);
|
||||
Page<SysLog> page = new Page<SysLog>(pageNo, pageSize);
|
||||
//日志关键词
|
||||
String keyWord = req.getParameter("keyWord");
|
||||
if (oConvertUtils.isNotEmpty(keyWord)) {
|
||||
queryWrapper.like("log_content", keyWord);
|
||||
}
|
||||
//TODO 过滤逻辑处理
|
||||
//TODO begin、end逻辑处理
|
||||
//TODO 一个强大的功能,前端传一个字段字符串,后台只返回这些字符串对应的字段
|
||||
//创建时间/创建人的赋值
|
||||
IPage<SysLog> pageList = sysLogService.page(page, queryWrapper);
|
||||
log.info("查询当前页:" + pageList.getCurrent());
|
||||
log.info("查询当前页数量:" + pageList.getSize());
|
||||
log.info("查询结果数量:" + pageList.getRecords().size());
|
||||
log.info("数据总数:" + pageList.getTotal());
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* @功能:删除单个日志记录
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysLog> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysLog> result = new Result<SysLog>();
|
||||
SysLog sysLog = sysLogService.getById(id);
|
||||
if (sysLog == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = sysLogService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ids
|
||||
* @return
|
||||
* @功能:批量,全部清空日志记录
|
||||
*/
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
if ("allclear".equals(ids)) {
|
||||
this.sysLogService.removeAll();
|
||||
result.success("清除成功!");
|
||||
}
|
||||
this.sysLogService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+936
@@ -0,0 +1,936 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import digital.base.constant.CommonConstant;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.config.JeecgBaseConfig;
|
||||
//import digital.system.jeecg.group.base.service.BaseCommonService;
|
||||
//import digital.system.jeecg.group.util.db.RoleIndexConfigEnum;
|
||||
//import digital.system.jeecg.system.entity.SysDepartPermission;
|
||||
//import digital.system.jeecg.system.entity.SysPermission;
|
||||
//import digital.system.jeecg.system.entity.SysPermissionDataRule;
|
||||
//import digital.system.jeecg.system.entity.SysRolePermission;
|
||||
//import digital.system.jeecg.system.model.SysPermissionTree;
|
||||
//import digital.system.jeecg.system.model.TreeModel;
|
||||
//import digital.system.jeecg.system.service.*;
|
||||
//import digital.system.jeecg.system.util.PermissionDataUtil;
|
||||
//import digital.util.util.Md5Util;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//import digital.system.jeecg.system.service.*;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import java.util.*;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * <p>
|
||||
// * 菜单权限表 前端控制器
|
||||
// * </p>
|
||||
// *
|
||||
// * @Author scott
|
||||
// * @since 2018-12-21
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/permission")
|
||||
//public class SysPermissionController {
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysPermissionService sysPermissionService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysRolePermissionService sysRolePermissionService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysDepartPermissionService sysDepartPermissionService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysUserService sysUserService;
|
||||
//
|
||||
// @Autowired
|
||||
// private JeecgBaseConfig jeecgBaseConfig;
|
||||
//
|
||||
// @Autowired
|
||||
// private BaseCommonService baseCommonService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysRoleIndexService sysRoleIndexService;
|
||||
//
|
||||
// /**
|
||||
// * 加载数据节点
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
// public Result<List<SysPermissionTree>> list() {
|
||||
// long start = System.currentTimeMillis();
|
||||
// Result<List<SysPermissionTree>> result = new Result<>();
|
||||
// try {
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.orderByAsc(SysPermission::getSortNo);
|
||||
// List<SysPermission> list = sysPermissionService.list(query);
|
||||
// List<SysPermissionTree> treeList = new ArrayList<>();
|
||||
// getTreeList(treeList, list, null);
|
||||
// result.setResult(treeList);
|
||||
// result.setSuccess(true);
|
||||
// log.info("======获取全部菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /*update_begin author:wuxianquan date:20190908 for:先查询一级菜单,当用户点击展开菜单时加载子菜单 */
|
||||
//
|
||||
// /**
|
||||
// * 系统菜单列表(一级菜单)
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getSystemMenuList", method = RequestMethod.GET)
|
||||
// public Result<List<SysPermissionTree>> getSystemMenuList() {
|
||||
// long start = System.currentTimeMillis();
|
||||
// Result<List<SysPermissionTree>> result = new Result<>();
|
||||
// try {
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
// query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_0);
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.orderByAsc(SysPermission::getSortNo);
|
||||
// List<SysPermission> list = sysPermissionService.list(query);
|
||||
// List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
|
||||
// for (SysPermission sysPermission : list) {
|
||||
// SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
|
||||
// sysPermissionTreeList.add(sysPermissionTree);
|
||||
// }
|
||||
// result.setResult(sysPermissionTreeList);
|
||||
// result.setSuccess(true);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// log.info("======获取一级菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询子菜单
|
||||
// *
|
||||
// * @param parentId
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
|
||||
// public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId) {
|
||||
// Result<List<SysPermissionTree>> result = new Result<>();
|
||||
// try {
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
// query.eq(SysPermission::getParentId, parentId);
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.orderByAsc(SysPermission::getSortNo);
|
||||
// List<SysPermission> list = sysPermissionService.list(query);
|
||||
// List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
|
||||
// for (SysPermission sysPermission : list) {
|
||||
// SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
|
||||
// sysPermissionTreeList.add(sysPermissionTree);
|
||||
// }
|
||||
// result.setResult(sysPermissionTreeList);
|
||||
// result.setSuccess(true);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// /*update_end author:wuxianquan date:20190908 for:先查询一级菜单,当用户点击展开菜单时加载子菜单 */
|
||||
//
|
||||
// // update_begin author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
//
|
||||
// /**
|
||||
// * 查询子菜单
|
||||
// *
|
||||
// * @param parentIds 父ID(多个采用半角逗号分割)
|
||||
// * @return 返回 key-value 的 Map
|
||||
// */
|
||||
// @GetMapping("/getSystemSubmenuBatch")
|
||||
// public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
|
||||
// try {
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
// List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
// query.in(SysPermission::getParentId, parentIdList);
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.orderByAsc(SysPermission::getSortNo);
|
||||
// List<SysPermission> list = sysPermissionService.list(query);
|
||||
// Map<String, List<SysPermissionTree>> listMap = new HashMap(5);
|
||||
// for (SysPermission item : list) {
|
||||
// String pid = item.getParentId();
|
||||
// if (parentIdList.contains(pid)) {
|
||||
// List<SysPermissionTree> mapList = listMap.get(pid);
|
||||
// if (mapList == null) {
|
||||
// mapList = new ArrayList<>();
|
||||
// }
|
||||
// mapList.add(new SysPermissionTree(item));
|
||||
// listMap.put(pid, mapList);
|
||||
// }
|
||||
// }
|
||||
// return Result.ok(listMap);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// return Result.error("批量查询子菜单失败:" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// // update_end author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
//
|
||||
//// /**
|
||||
//// * 查询用户拥有的菜单权限和按钮权限(根据用户账号)
|
||||
//// *
|
||||
//// * @return
|
||||
//// */
|
||||
//// @RequestMapping(value = "/queryByUser", method = RequestMethod.GET)
|
||||
//// public Result<JSONArray> queryByUser(HttpServletRequest req) {
|
||||
//// Result<JSONArray> result = new Result<>();
|
||||
//// try {
|
||||
//// String username = req.getParameter("username");
|
||||
//// List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
//// JSONArray jsonArray = new JSONArray();
|
||||
//// this.getPermissionJsonArray(jsonArray, metaList, null);
|
||||
//// result.setResult(jsonArray);
|
||||
//// result.success("查询成功");
|
||||
//// } catch (Exception e) {
|
||||
//// result.error500("查询失败:" + e.getMessage());
|
||||
//// log.error(e.getMessage(), e);
|
||||
//// }
|
||||
//// return result;
|
||||
//// }
|
||||
//
|
||||
// /**
|
||||
// * 查询用户拥有的菜单权限和按钮权限
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getUserPermissionByToken", method = RequestMethod.GET)
|
||||
// public Result<?> getUserPermissionByToken(HttpServletRequest request) {
|
||||
// Result<JSONObject> result = new Result<JSONObject>();
|
||||
// try {
|
||||
// //直接获取当前用户不适用前端token
|
||||
// LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// if (oConvertUtils.isEmpty(loginUser)) {
|
||||
// return Result.error("请登录系统!");
|
||||
// }
|
||||
// List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
|
||||
// //添加首页路由
|
||||
// //update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
// if (!PermissionDataUtil.hasIndexPage(metaList)) {
|
||||
// SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName, "首页")).get(0);
|
||||
// metaList.add(0, indexMenu);
|
||||
// }
|
||||
// //update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
//
|
||||
// //update-begin--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
|
||||
// List<String> roles = sysUserService.getRole(loginUser.getUsername());
|
||||
// String compUrl = RoleIndexConfigEnum.getIndexByRoles(roles);
|
||||
// if (StringUtils.isNotBlank(compUrl)) {
|
||||
// List<SysPermission> menus = metaList.stream().filter(sysPermission -> "首页".equals(sysPermission.getName())).collect(Collectors.toList());
|
||||
// menus.get(0).setComponent(compUrl);
|
||||
// }
|
||||
// //update-end--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
|
||||
// JSONObject json = new JSONObject();
|
||||
// JSONArray menujsonArray = new JSONArray();
|
||||
// this.getPermissionJsonArray(menujsonArray, metaList, null);
|
||||
// //一级菜单下的子菜单全部是隐藏路由,则一级菜单不显示
|
||||
// this.handleFirstLevelMenuHidden(menujsonArray);
|
||||
//
|
||||
// JSONArray authjsonArray = new JSONArray();
|
||||
// this.getAuthJsonArray(authjsonArray, metaList);
|
||||
// //查询所有的权限
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
|
||||
// //query.eq(SysPermission::getStatus, "1");
|
||||
// List<SysPermission> allAuthList = sysPermissionService.list(query);
|
||||
// JSONArray allauthjsonArray = new JSONArray();
|
||||
// this.getAllAuthJsonArray(allauthjsonArray, allAuthList);
|
||||
// //路由菜单
|
||||
// json.put("menu", menujsonArray);
|
||||
// //按钮权限(用户拥有的权限集合)
|
||||
// json.put("auth", authjsonArray);
|
||||
// //全部权限配置集合(按钮权限,访问权限)
|
||||
// json.put("allAuth", allauthjsonArray);
|
||||
// json.put("sysSafeMode", jeecgBaseConfig.getSafeMode());
|
||||
// result.setResult(json);
|
||||
// } catch (Exception e) {
|
||||
// result.error500("查询失败:" + e.getMessage());
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 【vue3专用】获取
|
||||
// * 1、查询用户拥有的按钮/表单访问权限
|
||||
// * 2、所有权限 (菜单权限配置)
|
||||
// * 3、系统安全模式 (开启则online报表的数据源必填)
|
||||
// */
|
||||
// @RequestMapping(value = "/getPermCode", method = RequestMethod.GET)
|
||||
// public Result<?> getPermCode() {
|
||||
// try {
|
||||
// // 直接获取当前用户
|
||||
// LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// if (oConvertUtils.isEmpty(loginUser)) {
|
||||
// return Result.error("请登录系统!");
|
||||
// }
|
||||
// // 获取当前用户的权限集合
|
||||
// List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
|
||||
// // 按钮权限(用户拥有的权限集合)
|
||||
// List<String> codeList = metaList.stream()
|
||||
// .filter((permission) -> CommonConstant.MENU_TYPE_2.equals(permission.getMenuType()) && CommonConstant.STATUS_1.equals(permission.getStatus()))
|
||||
// .collect(ArrayList::new, (list, permission) -> list.add(permission.getPerms()), ArrayList::addAll);
|
||||
// //
|
||||
// JSONArray authArray = new JSONArray();
|
||||
// this.getAuthJsonArray(authArray, metaList);
|
||||
// // 查询所有的权限
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
|
||||
// List<SysPermission> allAuthList = sysPermissionService.list(query);
|
||||
// JSONArray allAuthArray = new JSONArray();
|
||||
// this.getAllAuthJsonArray(allAuthArray, allAuthList);
|
||||
// JSONObject result = new JSONObject();
|
||||
// // 所拥有的权限编码
|
||||
// result.put("codeList", codeList);
|
||||
// //按钮权限(用户拥有的权限集合)
|
||||
// result.put("auth", authArray);
|
||||
// //全部权限配置集合(按钮权限,访问权限)
|
||||
// result.put("allAuth", allAuthArray);
|
||||
// // 系统安全模式
|
||||
// result.put("sysSafeMode", jeecgBaseConfig.getSafeMode());
|
||||
// return Result.OK(result);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// return Result.error("查询失败:" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加菜单
|
||||
// *
|
||||
// * @param permission
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// public Result<SysPermission> add(@RequestBody SysPermission permission) {
|
||||
// Result<SysPermission> result = new Result<SysPermission>();
|
||||
// try {
|
||||
// permission = PermissionDataUtil.intelligentProcessData(permission);
|
||||
// sysPermissionService.addPermission(permission);
|
||||
// result.success("添加成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑菜单
|
||||
// *
|
||||
// * @param permission
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
||||
// Result<SysPermission> result = new Result<>();
|
||||
// try {
|
||||
// permission = PermissionDataUtil.intelligentProcessData(permission);
|
||||
// sysPermissionService.editPermission(permission);
|
||||
// result.success("修改成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除菜单
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
// public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysPermission> result = new Result<>();
|
||||
// try {
|
||||
// sysPermissionService.deletePermission(id);
|
||||
// result.success("删除成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500(e.getMessage());
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除菜单
|
||||
// *
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
// public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
// Result<SysPermission> result = new Result<>();
|
||||
// try {
|
||||
// String[] arr = ids.split(",");
|
||||
// for (String id : arr) {
|
||||
// if (oConvertUtils.isNotEmpty(id)) {
|
||||
// sysPermissionService.deletePermission(id);
|
||||
// }
|
||||
// }
|
||||
// result.success("删除成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("删除成功!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取全部的权限树
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
// public Result<Map<String, Object>> queryTreeList() {
|
||||
// Result<Map<String, Object>> result = new Result<>();
|
||||
// // 全部权限ids
|
||||
// List<String> ids = new ArrayList<>();
|
||||
// try {
|
||||
// LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
// query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
// query.orderByAsc(SysPermission::getSortNo);
|
||||
// List<SysPermission> list = sysPermissionService.list(query);
|
||||
// for (SysPermission sysPer : list) {
|
||||
// ids.add(sysPer.getId());
|
||||
// }
|
||||
// List<TreeModel> treeList = new ArrayList<>();
|
||||
// getTreeModelList(treeList, list, null);
|
||||
//
|
||||
// Map<String, Object> resMap = new HashMap<String, Object>();
|
||||
// // 全部树节点数据
|
||||
// resMap.put("treeList", treeList);
|
||||
// // 全部树ids
|
||||
// resMap.put("ids", ids);
|
||||
// result.setResult(resMap);
|
||||
// result.setSuccess(true);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 异步加载数据节点 [接口是废的,没有用到]
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryListAsync", method = RequestMethod.GET)
|
||||
// public Result<List<TreeModel>> queryAsync(@RequestParam(name = "pid", required = false) String parentId) {
|
||||
// Result<List<TreeModel>> result = new Result<>();
|
||||
// try {
|
||||
// List<TreeModel> list = sysPermissionService.queryListByParentId(parentId);
|
||||
// if (list == null || list.size() <= 0) {
|
||||
// result.error500("未找到角色信息");
|
||||
// } else {
|
||||
// result.setResult(list);
|
||||
// result.setSuccess(true);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询角色授权
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryRolePermission", method = RequestMethod.GET)
|
||||
// public Result<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
|
||||
// Result<List<String>> result = new Result<>();
|
||||
// try {
|
||||
// List<SysRolePermission> list = sysRolePermissionService.list(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId));
|
||||
// result.setResult(list.stream().map(SysRolePermission -> String.valueOf(SysRolePermission.getPermissionId())).collect(Collectors.toList()));
|
||||
// result.setSuccess(true);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存角色授权
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
// long start = System.currentTimeMillis();
|
||||
// Result<String> result = new Result<>();
|
||||
// try {
|
||||
// String roleId = json.getString("roleId");
|
||||
// String permissionIds = json.getString("permissionIds");
|
||||
// String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
// this.sysRolePermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
// //update-begin---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
// LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// baseCommonService.addLog("修改角色ID: " + roleId + " 的权限配置,操作人: " + loginUser.getUsername(), CommonConstant.LOG_TYPE_2, 2);
|
||||
// //update-end---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
// result.success("保存成功!");
|
||||
// log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
// } catch (Exception e) {
|
||||
// result.error500("授权失败!");
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private void getTreeList(List<SysPermissionTree> treeList, List<SysPermission> metaList, SysPermissionTree temp) {
|
||||
// for (SysPermission permission : metaList) {
|
||||
// String tempPid = permission.getParentId();
|
||||
// SysPermissionTree tree = new SysPermissionTree(permission);
|
||||
// if (temp == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
// treeList.add(tree);
|
||||
// if (!tree.getIsLeaf()) {
|
||||
// getTreeList(treeList, metaList, tree);
|
||||
// }
|
||||
// } else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
|
||||
// temp.getChildren().add(tree);
|
||||
// if (!tree.getIsLeaf()) {
|
||||
// getTreeList(treeList, metaList, tree);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
|
||||
// for (SysPermission permission : metaList) {
|
||||
// String tempPid = permission.getParentId();
|
||||
// TreeModel tree = new TreeModel(permission);
|
||||
// if (temp == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
// treeList.add(tree);
|
||||
// if (!tree.getIsLeaf()) {
|
||||
// getTreeModelList(treeList, metaList, tree);
|
||||
// }
|
||||
// } else if (temp != null && tempPid != null && tempPid.equals(temp.getKey())) {
|
||||
// temp.getChildren().add(tree);
|
||||
// if (!tree.getIsLeaf()) {
|
||||
// getTreeModelList(treeList, metaList, tree);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 一级菜单的子菜单全部是隐藏路由,则一级菜单不显示
|
||||
// *
|
||||
// * @param jsonArray
|
||||
// */
|
||||
// private void handleFirstLevelMenuHidden(JSONArray jsonArray) {
|
||||
// jsonArray = jsonArray.stream().map(obj -> {
|
||||
// JSONObject returnObj = new JSONObject();
|
||||
// JSONObject jsonObj = (JSONObject) obj;
|
||||
// if (jsonObj.containsKey("children")) {
|
||||
// JSONArray childrens = jsonObj.getJSONArray("children");
|
||||
// childrens = childrens.stream().filter(arrObj -> !"true".equals(((JSONObject) arrObj).getString("hidden"))).collect(Collectors.toCollection(JSONArray::new));
|
||||
// if (childrens == null || childrens.size() == 0) {
|
||||
// jsonObj.put("hidden", true);
|
||||
//
|
||||
// //vue3版本兼容代码
|
||||
// JSONObject meta = new JSONObject();
|
||||
// meta.put("hideMenu", true);
|
||||
// jsonObj.put("meta", meta);
|
||||
// }
|
||||
// }
|
||||
// return returnObj;
|
||||
// }).collect(Collectors.toCollection(JSONArray::new));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 获取权限JSON数组
|
||||
// *
|
||||
// * @param jsonArray
|
||||
// * @param allList
|
||||
// */
|
||||
// private void getAllAuthJsonArray(JSONArray jsonArray, List<SysPermission> allList) {
|
||||
// JSONObject json = null;
|
||||
// for (SysPermission permission : allList) {
|
||||
// json = new JSONObject();
|
||||
// json.put("action", permission.getPerms());
|
||||
// json.put("status", permission.getStatus());
|
||||
// //1显示2禁用
|
||||
// json.put("type", permission.getPermsType());
|
||||
// json.put("describe", permission.getName());
|
||||
// jsonArray.add(json);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取权限JSON数组
|
||||
// *
|
||||
// * @param jsonArray
|
||||
// * @param metaList
|
||||
// */
|
||||
// private void getAuthJsonArray(JSONArray jsonArray, List<SysPermission> metaList) {
|
||||
// for (SysPermission permission : metaList) {
|
||||
// if (permission.getMenuType() == null) {
|
||||
// continue;
|
||||
// }
|
||||
// JSONObject json = null;
|
||||
// if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2) && CommonConstant.STATUS_1.equals(permission.getStatus())) {
|
||||
// json = new JSONObject();
|
||||
// json.put("action", permission.getPerms());
|
||||
// json.put("type", permission.getPermsType());
|
||||
// json.put("describe", permission.getName());
|
||||
// jsonArray.add(json);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取菜单JSON数组
|
||||
// *
|
||||
// * @param jsonArray
|
||||
// * @param metaList
|
||||
// * @param parentJson
|
||||
// */
|
||||
// private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson) {
|
||||
// for (SysPermission permission : metaList) {
|
||||
// if (permission.getMenuType() == null) {
|
||||
// continue;
|
||||
// }
|
||||
// String tempPid = permission.getParentId();
|
||||
// JSONObject json = getPermissionJsonObject(permission);
|
||||
// if (json == null) {
|
||||
// continue;
|
||||
// }
|
||||
// if (parentJson == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
// jsonArray.add(json);
|
||||
// if (!permission.isLeaf()) {
|
||||
// getPermissionJsonArray(jsonArray, metaList, json);
|
||||
// }
|
||||
// } else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
|
||||
// // 类型( 0:一级菜单 1:子菜单 2:按钮 )
|
||||
// if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
|
||||
// JSONObject metaJson = parentJson.getJSONObject("meta");
|
||||
// if (metaJson.containsKey("permissionList")) {
|
||||
// metaJson.getJSONArray("permissionList").add(json);
|
||||
// } else {
|
||||
// JSONArray permissionList = new JSONArray();
|
||||
// permissionList.add(json);
|
||||
// metaJson.put("permissionList", permissionList);
|
||||
// }
|
||||
// // 类型( 0:一级菜单 1:子菜单 2:按钮 )
|
||||
// } else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_1) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_0)) {
|
||||
// if (parentJson.containsKey("children")) {
|
||||
// parentJson.getJSONArray("children").add(json);
|
||||
// } else {
|
||||
// JSONArray children = new JSONArray();
|
||||
// children.add(json);
|
||||
// parentJson.put("children", children);
|
||||
// }
|
||||
//
|
||||
// if (!permission.isLeaf()) {
|
||||
// getPermissionJsonArray(jsonArray, metaList, json);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据菜单配置生成路由json
|
||||
// *
|
||||
// * @param permission
|
||||
// * @return
|
||||
// */
|
||||
// private JSONObject getPermissionJsonObject(SysPermission permission) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// // 类型(0:一级菜单 1:子菜单 2:按钮)
|
||||
// if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
|
||||
// //json.put("action", permission.getPerms());
|
||||
// //json.put("type", permission.getPermsType());
|
||||
// //json.put("describe", permission.getName());
|
||||
// return null;
|
||||
// } else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_0) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_1)) {
|
||||
// json.put("id", permission.getId());
|
||||
// if (permission.isRoute()) {
|
||||
// //表示生成路由
|
||||
// json.put("route", "1");
|
||||
// } else {
|
||||
// //表示不生成路由
|
||||
// json.put("route", "0");
|
||||
// }
|
||||
//
|
||||
// if (isWWWHttpUrl(permission.getUrl())) {
|
||||
// json.put("path", Md5Util.md5Encode(permission.getUrl(), "utf-8"));
|
||||
// } else {
|
||||
// json.put("path", permission.getUrl());
|
||||
// }
|
||||
//
|
||||
// // 重要规则:路由name (通过URL生成路由name,路由name供前端开发,页面跳转使用)
|
||||
// if (oConvertUtils.isNotEmpty(permission.getComponentName())) {
|
||||
// json.put("name", permission.getComponentName());
|
||||
// } else {
|
||||
// json.put("name", urlToRouteName(permission.getUrl()));
|
||||
// }
|
||||
//
|
||||
// JSONObject meta = new JSONObject();
|
||||
// // 是否隐藏路由,默认都是显示的
|
||||
// if (permission.isHidden()) {
|
||||
// json.put("hidden", true);
|
||||
// //vue3版本兼容代码
|
||||
// meta.put("hideMenu", true);
|
||||
// }
|
||||
// // 聚合路由
|
||||
// if (permission.isAlwaysShow()) {
|
||||
// json.put("alwaysShow", true);
|
||||
// }
|
||||
// json.put("component", permission.getComponent());
|
||||
// // 由用户设置是否缓存页面 用布尔值
|
||||
// if (permission.isKeepAlive()) {
|
||||
// meta.put("keepAlive", true);
|
||||
// } else {
|
||||
// meta.put("keepAlive", false);
|
||||
// }
|
||||
//
|
||||
// /*update_begin author:wuxianquan date:20190908 for:往菜单信息里添加外链菜单打开方式 */
|
||||
// //外链菜单打开方式
|
||||
// if (permission.isInternalOrExternal()) {
|
||||
// meta.put("internalOrExternal", true);
|
||||
// } else {
|
||||
// meta.put("internalOrExternal", false);
|
||||
// }
|
||||
// /* update_end author:wuxianquan date:20190908 for: 往菜单信息里添加外链菜单打开方式*/
|
||||
//
|
||||
// meta.put("title", permission.getName());
|
||||
// meta.put("traditionalName", permission.getTraditionalName());
|
||||
// meta.put("englishName", permission.getEnglishName());
|
||||
//
|
||||
// //update-begin--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
|
||||
// String component = permission.getComponent();
|
||||
// if (oConvertUtils.isNotEmpty(permission.getComponentName()) || oConvertUtils.isNotEmpty(component)) {
|
||||
// meta.put("componentName", oConvertUtils.getString(permission.getComponentName(), component.substring(component.lastIndexOf("/") + 1)));
|
||||
// }
|
||||
// //update-end--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
|
||||
//
|
||||
// if (oConvertUtils.isEmpty(permission.getParentId())) {
|
||||
// // 一级菜单跳转地址
|
||||
// json.put("redirect", permission.getRedirect());
|
||||
// if (oConvertUtils.isNotEmpty(permission.getIcon())) {
|
||||
// meta.put("icon", permission.getIcon());
|
||||
// }
|
||||
// } else {
|
||||
// if (oConvertUtils.isNotEmpty(permission.getIcon())) {
|
||||
// meta.put("icon", permission.getIcon());
|
||||
// }
|
||||
// }
|
||||
// if (isWWWHttpUrl(permission.getUrl())) {
|
||||
// meta.put("url", permission.getUrl());
|
||||
// }
|
||||
// // update-begin--Author:sunjianlei Date:20210918 for:新增适配vue3项目的隐藏tab功能
|
||||
// if (permission.isHideTab()) {
|
||||
// meta.put("hideTab", true);
|
||||
// }
|
||||
// // update-end--Author:sunjianlei Date:20210918 for:新增适配vue3项目的隐藏tab功能
|
||||
// json.put("meta", meta);
|
||||
// }
|
||||
//
|
||||
// return json;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 判断是否外网URL 例如: http://localhost:8080/jeecg-boot/swagger-ui.html#/ 支持特殊格式: {{
|
||||
// * window._CONFIG['domianURL'] }}/druid/ {{ JS代码片段 }},前台解析会自动执行JS代码片段
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// private boolean isWWWHttpUrl(String url) {
|
||||
// if (url != null && (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("{{"))) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过URL生成路由name(去掉URL前缀斜杠,替换内容中的斜杠‘/’为-) 举例: URL = /isystem/role RouteName =
|
||||
// * isystem-role
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// private String urlToRouteName(String url) {
|
||||
// if (oConvertUtils.isNotEmpty(url)) {
|
||||
// if (url.startsWith("/")) {
|
||||
// url = url.substring(1);
|
||||
// }
|
||||
// url = url.replace("/", "-");
|
||||
//
|
||||
// // 特殊标记
|
||||
// url = url.replace(":", "@");
|
||||
// return url;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据菜单id来获取其对应的权限数据
|
||||
// *
|
||||
// * @param sysPermissionDataRule
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getPermRuleListByPermId", method = RequestMethod.GET)
|
||||
// public Result<List<SysPermissionDataRule>> getPermRuleListByPermId(SysPermissionDataRule sysPermissionDataRule) {
|
||||
// List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.getPermRuleListByPermId(sysPermissionDataRule.getPermissionId());
|
||||
// Result<List<SysPermissionDataRule>> result = new Result<>();
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(permRuleList);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加菜单权限数据
|
||||
// *
|
||||
// * @param sysPermissionDataRule
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/addPermissionRule", method = RequestMethod.POST)
|
||||
// public Result<SysPermissionDataRule> addPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
|
||||
// Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
// try {
|
||||
// sysPermissionDataRule.setCreateTime(new Date());
|
||||
// sysPermissionDataRuleService.savePermissionDataRule(sysPermissionDataRule);
|
||||
// result.success("添加成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/editPermissionRule", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<SysPermissionDataRule> editPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
|
||||
// Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
// try {
|
||||
// sysPermissionDataRuleService.saveOrUpdate(sysPermissionDataRule);
|
||||
// result.success("更新成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除菜单权限数据
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// @RequestMapping(value = "/deletePermissionRule", method = RequestMethod.DELETE)
|
||||
// public Result<SysPermissionDataRule> deletePermissionRule(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
// try {
|
||||
// sysPermissionDataRuleService.deletePermissionDataRule(id);
|
||||
// result.success("删除成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询菜单权限数据
|
||||
// *
|
||||
// * @param sysPermissionDataRule
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryPermissionRule", method = RequestMethod.GET)
|
||||
// public Result<List<SysPermissionDataRule>> queryPermissionRule(SysPermissionDataRule sysPermissionDataRule) {
|
||||
// Result<List<SysPermissionDataRule>> result = new Result<>();
|
||||
// try {
|
||||
// List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.queryPermissionRule(sysPermissionDataRule);
|
||||
// result.setResult(permRuleList);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 部门权限表
|
||||
// *
|
||||
// * @param departId
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryDepartPermission", method = RequestMethod.GET)
|
||||
// public Result<List<String>> queryDepartPermission(@RequestParam(name = "departId", required = true) String departId) {
|
||||
// Result<List<String>> result = new Result<>();
|
||||
// try {
|
||||
// List<SysDepartPermission> list = sysDepartPermissionService.list(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId));
|
||||
// result.setResult(list.stream().map(SysDepartPermission -> String.valueOf(SysDepartPermission.getPermissionId())).collect(Collectors.toList()));
|
||||
// result.setSuccess(true);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存部门授权
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/saveDepartPermission", method = RequestMethod.POST)
|
||||
// //@RequiresRoles({ "admin" })
|
||||
// public Result<String> saveDepartPermission(@RequestBody JSONObject json) {
|
||||
// long start = System.currentTimeMillis();
|
||||
// Result<String> result = new Result<>();
|
||||
// try {
|
||||
// String departId = json.getString("departId");
|
||||
// String permissionIds = json.getString("permissionIds");
|
||||
// String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
// this.sysDepartPermissionService.saveDepartPermission(departId, permissionIds, lastPermissionIds);
|
||||
// result.success("保存成功!");
|
||||
// log.info("======部门授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
// } catch (Exception e) {
|
||||
// result.error500("授权失败!");
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysPosition;
|
||||
import digital.system.jeecg.system.service.ISysPositionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.Result;
|
||||
import digital.util.util.ImportExcelUtil;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 职务表
|
||||
* @Author: zita
|
||||
* @Date: 2019-09-19
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "职务表")
|
||||
@RestController
|
||||
@RequestMapping("/sys/position")
|
||||
public class SysPositionController {
|
||||
|
||||
@Autowired
|
||||
private ISysPositionService sysPositionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysPosition
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-分页列表查询")
|
||||
@ApiOperation(value = "职务表-分页列表查询", notes = "职务表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SysPosition>> queryPageList(SysPosition sysPosition,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysPosition>> result = new Result<IPage<SysPosition>>();
|
||||
QueryWrapper<SysPosition> queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, req.getParameterMap());
|
||||
Page<SysPosition> page = new Page<SysPosition>(pageNo, pageSize);
|
||||
IPage<SysPosition> pageList = sysPositionService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysPosition
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-添加")
|
||||
@ApiOperation(value = "职务表-添加", notes = "职务表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SysPosition> add(@RequestBody SysPosition sysPosition) {
|
||||
Result<SysPosition> result = new Result<SysPosition>();
|
||||
try {
|
||||
sysPositionService.save(sysPosition);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysPosition
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-编辑")
|
||||
@ApiOperation(value = "职务表-编辑", notes = "职务表-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysPosition> edit(@RequestBody SysPosition sysPosition) {
|
||||
Result<SysPosition> result = new Result<SysPosition>();
|
||||
SysPosition sysPositionEntity = sysPositionService.getById(sysPosition.getId());
|
||||
if (sysPositionEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = sysPositionService.updateById(sysPosition);
|
||||
//TODO 返回false说明什么?
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-通过id删除")
|
||||
@ApiOperation(value = "职务表-通过id删除", notes = "职务表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
try {
|
||||
sysPositionService.removeById(id);
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败", e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-批量删除")
|
||||
@ApiOperation(value = "职务表-批量删除", notes = "职务表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<SysPosition> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysPosition> result = new Result<SysPosition>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.sysPositionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-通过id查询")
|
||||
@ApiOperation(value = "职务表-通过id查询", notes = "职务表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysPosition> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPosition> result = new Result<SysPosition>();
|
||||
SysPosition sysPosition = sysPositionService.getById(id);
|
||||
if (sysPosition == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(sysPosition);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SysPosition> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SysPosition> pageList = sysPositionService.list(queryWrapper);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:" + user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// 错误信息
|
||||
List<String> errorMessage = new ArrayList<>();
|
||||
int successLines = 0, errorLines = 0;
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<Object> listSysPositions = ExcelImportUtil.importExcel(file.getInputStream(), SysPosition.class, params);
|
||||
List<String> list = ImportExcelUtil.importDateSave(listSysPositions, ISysPositionService.class, errorMessage, CommonConstant.SQL_INDEX_UNIQ_CODE);
|
||||
errorLines += list.size();
|
||||
successLines += (listSysPositions.size() - errorLines);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code查询
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "职务表-通过code查询")
|
||||
@ApiOperation(value = "职务表-通过code查询", notes = "职务表-通过code查询")
|
||||
@GetMapping(value = "/queryByCode")
|
||||
public Result<SysPosition> queryByCode(@RequestParam(name = "code", required = true) String code) {
|
||||
Result<SysPosition> result = new Result<SysPosition>();
|
||||
QueryWrapper<SysPosition> queryWrapper = new QueryWrapper<SysPosition>();
|
||||
queryWrapper.eq("code", code);
|
||||
SysPosition sysPosition = sysPositionService.getOne(queryWrapper);
|
||||
if (sysPosition == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(sysPosition);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysPermission;
|
||||
import digital.system.jeecg.system.entity.SysPermissionDataRule;
|
||||
import digital.system.jeecg.system.entity.SysRole;
|
||||
import digital.system.jeecg.system.entity.SysRolePermission;
|
||||
import digital.system.jeecg.system.model.TreeModel;
|
||||
import digital.system.jeecg.system.service.ISysPermissionDataRuleService;
|
||||
import digital.system.jeecg.system.service.ISysPermissionService;
|
||||
import digital.system.jeecg.system.service.ISysRolePermissionService;
|
||||
import digital.system.jeecg.system.service.ISysRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.constant.CommonConstant;
|
||||
import digital.base.vo.LoginUser;
|
||||
import digital.base.vo.Result;
|
||||
import digital.util.util.oConvertUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @Author scott
|
||||
* @since 2018-12-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/role")
|
||||
@Slf4j
|
||||
public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
|
||||
@Autowired
|
||||
private ISysRolePermissionService sysRolePermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionService sysPermissionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param role
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysRole>> queryPageList(SysRole role,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
|
||||
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
|
||||
Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
|
||||
IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
//@RequiresRoles({"admin"})
|
||||
public Result<SysRole> add(@RequestBody SysRole role) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
try {
|
||||
role.setCreateTime(new Date());
|
||||
sysRoleService.save(role);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysRole> edit(@RequestBody SysRole role) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
SysRole sysrole = sysRoleService.getById(role.getId());
|
||||
if (sysrole == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
role.setUpdateTime(new Date());
|
||||
boolean ok = sysRoleService.updateById(role);
|
||||
//TODO 返回false说明什么?
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysRoleService.deleteRole(id);
|
||||
return Result.ok("删除角色成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
if (oConvertUtils.isEmpty(ids)) {
|
||||
result.error500("未选中角色!");
|
||||
} else {
|
||||
sysRoleService.deleteBatchRole(ids.split(","));
|
||||
result.success("删除角色成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
||||
public Result<SysRole> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
SysRole sysrole = sysRoleService.getById(id);
|
||||
if (sysrole == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(sysrole);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryall", method = RequestMethod.GET)
|
||||
public Result<List<SysRole>> queryall() {
|
||||
Result<List<SysRole>> result = new Result<>();
|
||||
List<SysRole> list = sysRoleService.list();
|
||||
if (list == null || list.size() <= 0) {
|
||||
result.error500("未找到角色信息");
|
||||
} else {
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色编码唯一
|
||||
*/
|
||||
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
|
||||
public Result<Boolean> checkUsername(String id, String roleCode) {
|
||||
Result<Boolean> result = new Result<>();
|
||||
//如果此参数为false则程序发生异常
|
||||
result.setResult(true);
|
||||
log.info("--验证角色编码是否唯一---id:" + id + "--roleCode:" + roleCode);
|
||||
try {
|
||||
SysRole role = null;
|
||||
if (oConvertUtils.isNotEmpty(id)) {
|
||||
role = sysRoleService.getById(id);
|
||||
}
|
||||
SysRole newRole = sysRoleService.getOne(new QueryWrapper<SysRole>().lambda().eq(SysRole::getRoleCode, roleCode));
|
||||
if (newRole != null) {
|
||||
//如果根据传入的roleCode查询到信息了,那么就需要做校验了。
|
||||
if (role == null) {
|
||||
//role为空=>新增模式=>只要roleCode存在则返回false
|
||||
result.setSuccess(false);
|
||||
result.setMessage("角色编码已存在");
|
||||
return result;
|
||||
} else if (!id.equals(newRole.getId())) {
|
||||
//否则=>编辑模式=>判断两者ID是否一致-
|
||||
result.setSuccess(false);
|
||||
result.setMessage("角色编码已存在");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.setSuccess(false);
|
||||
result.setResult(false);
|
||||
result.setMessage(e.getMessage());
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysRole sysRole, HttpServletRequest request) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SysRole> pageList = sysRoleService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "角色列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysRole.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("角色列表数据", "导出人:" + user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
return sysRoleService.importExcelCheckRoleCode(file, params);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("roleId") String roleId) {
|
||||
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
|
||||
if (list == null || list.size() == 0) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
} else {
|
||||
Map<String, Object> map = new HashMap(5);
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
|
||||
.eq(SysRolePermission::getPermissionId, permissionId)
|
||||
.isNotNull(SysRolePermission::getDataRuleIds)
|
||||
.eq(SysRolePermission::getRoleId, roleId);
|
||||
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
|
||||
if (sysRolePermission == null) {
|
||||
//return Result.error("未找到角色菜单配置信息");
|
||||
} else {
|
||||
String drChecked = sysRolePermission.getDataRuleIds();
|
||||
if (oConvertUtils.isNotEmpty(drChecked)) {
|
||||
map.put("drChecked", drChecked.endsWith(",") ? drChecked.substring(0, drChecked.length() - 1) : drChecked);
|
||||
}
|
||||
}
|
||||
return Result.ok(map);
|
||||
//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据规则至角色菜单关联表
|
||||
*/
|
||||
@PostMapping(value = "/datarule")
|
||||
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
String permissionId = jsonObject.getString("permissionId");
|
||||
String roleId = jsonObject.getString("roleId");
|
||||
String dataRuleIds = jsonObject.getString("dataRuleIds");
|
||||
log.info("保存数据规则>>" + "菜单ID:" + permissionId + "角色ID:" + roleId + "数据权限ID:" + dataRuleIds);
|
||||
LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
|
||||
.eq(SysRolePermission::getPermissionId, permissionId)
|
||||
.eq(SysRolePermission::getRoleId, roleId);
|
||||
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
|
||||
if (sysRolePermission == null) {
|
||||
return Result.error("请先保存角色菜单权限!");
|
||||
} else {
|
||||
sysRolePermission.setDataRuleIds(dataRuleIds);
|
||||
this.sysRolePermissionService.updateById(sysRolePermission);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(), e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
public Result<Map<String, Object>> queryTreeList(HttpServletRequest request) {
|
||||
Result<Map<String, Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
for (SysPermission sysPer : list) {
|
||||
ids.add(sysPer.getId());
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String, Object> resMap = new HashMap(5);
|
||||
//全部树节点数据
|
||||
resMap.put("treeList", treeList);
|
||||
//全部树ids
|
||||
resMap.put("ids", ids);
|
||||
result.setResult(resMap);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
|
||||
for (SysPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(), permission.getRuleFlag(), permission.isLeaf());
|
||||
if (temp == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if (!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
} else if (temp != null && tempPid != null && tempPid.equals(temp.getKey())) {
|
||||
temp.getChildren().add(tree);
|
||||
if (!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysRoleIndex;
|
||||
import digital.system.jeecg.system.service.ISysRoleIndexService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 角色首页配置
|
||||
* @Author: zita
|
||||
* @Date: 2022-03-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "角色首页配置")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysRoleIndex")
|
||||
public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRoleIndexService> {
|
||||
@Autowired
|
||||
private ISysRoleIndexService sysRoleIndexService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysRoleIndex
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-分页列表查询")
|
||||
@ApiOperation(value = "角色首页配置-分页列表查询", notes = "角色首页配置-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysRoleIndex sysRoleIndex,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysRoleIndex> queryWrapper = QueryGenerator.initQueryWrapper(sysRoleIndex, req.getParameterMap());
|
||||
Page<SysRoleIndex> page = new Page<SysRoleIndex>(pageNo, pageSize);
|
||||
IPage<SysRoleIndex> pageList = sysRoleIndexService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysRoleIndex
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-添加")
|
||||
@ApiOperation(value = "角色首页配置-添加", notes = "角色首页配置-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysRoleIndex sysRoleIndex) {
|
||||
sysRoleIndexService.save(sysRoleIndex);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysRoleIndex
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-编辑")
|
||||
@ApiOperation(value = "角色首页配置-编辑", notes = "角色首页配置-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<?> edit(@RequestBody SysRoleIndex sysRoleIndex) {
|
||||
sysRoleIndexService.updateById(sysRoleIndex);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-通过id删除")
|
||||
@ApiOperation(value = "角色首页配置-通过id删除", notes = "角色首页配置-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysRoleIndexService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-批量删除")
|
||||
@ApiOperation(value = "角色首页配置-批量删除", notes = "角色首页配置-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.sysRoleIndexService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-通过id查询")
|
||||
@ApiOperation(value = "角色首页配置-通过id查询", notes = "角色首页配置-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysRoleIndex sysRoleIndex = sysRoleIndexService.getById(id);
|
||||
return Result.OK(sysRoleIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysRoleIndex
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysRoleIndex sysRoleIndex) {
|
||||
return super.exportXls(request, sysRoleIndex, SysRoleIndex.class, "角色首页配置");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysRoleIndex.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code查询
|
||||
*
|
||||
* @param roleCode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "角色首页配置-通过code查询")
|
||||
@ApiOperation(value = "角色首页配置-通过code查询", notes = "角色首页配置-通过code查询")
|
||||
@GetMapping(value = "/queryByCode")
|
||||
public Result<?> queryByCode(@RequestParam(name = "roleCode", required = true) String roleCode) {
|
||||
SysRoleIndex sysRoleIndex = sysRoleIndexService.getOne(new LambdaQueryWrapper<SysRoleIndex>().eq(SysRoleIndex::getRoleCode, roleCode));
|
||||
return Result.OK(sysRoleIndex);
|
||||
}
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import digital.base.annotation.PermissionData;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.system.jeecg.group.query.QueryGenerator;
|
||||
//import digital.system.jeecg.system.entity.SysTenant;
|
||||
//import digital.system.jeecg.system.service.ISysTenantService;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import java.util.*;
|
||||
//
|
||||
///**
|
||||
// * 租户配置信息
|
||||
// *
|
||||
// * @author: smcp
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/tenant")
|
||||
//public class SysTenantController {
|
||||
//
|
||||
// @Autowired
|
||||
// private ISysTenantService sysTenantService;
|
||||
//
|
||||
// /**
|
||||
// * 获取列表数据
|
||||
// *
|
||||
// * @param sysTenant
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param req
|
||||
// * @return
|
||||
// */
|
||||
// @PermissionData(pageComponent = "system/TenantList")
|
||||
// @RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
// public Result<IPage<SysTenant>> queryPageList(SysTenant sysTenant, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
// Result<IPage<SysTenant>> result = new Result<IPage<SysTenant>>();
|
||||
// //---author:zhangyafei---date:20210916-----for: 租户管理添加日期范围查询---
|
||||
// Date beginDate = null;
|
||||
// Date endDate = null;
|
||||
// if (oConvertUtils.isNotEmpty(sysTenant)) {
|
||||
// beginDate = sysTenant.getBeginDate();
|
||||
// endDate = sysTenant.getEndDate();
|
||||
// sysTenant.setBeginDate(null);
|
||||
// sysTenant.setEndDate(null);
|
||||
// }
|
||||
// //---author:zhangyafei---date:20210916-----for: 租户管理添加日期范围查询---
|
||||
// QueryWrapper<SysTenant> queryWrapper = QueryGenerator.initQueryWrapper(sysTenant, req.getParameterMap());
|
||||
// //---author:zhangyafei---date:20210916-----for: 租户管理添加日期范围查询---
|
||||
// if (oConvertUtils.isNotEmpty(sysTenant)) {
|
||||
// queryWrapper.ge(oConvertUtils.isNotEmpty(beginDate), "begin_date", beginDate);
|
||||
// queryWrapper.le(oConvertUtils.isNotEmpty(endDate), "end_date", endDate);
|
||||
// }
|
||||
// //---author:zhangyafei---date:20210916-----for: 租户管理添加日期范围查询---
|
||||
// Page<SysTenant> page = new Page<SysTenant>(pageNo, pageSize);
|
||||
// IPage<SysTenant> pageList = sysTenantService.page(page, queryWrapper);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(pageList);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加
|
||||
// *
|
||||
// * @param
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// public Result<SysTenant> add(@RequestBody SysTenant sysTenant) {
|
||||
// Result<SysTenant> result = new Result();
|
||||
// if (sysTenantService.getById(sysTenant.getId()) != null) {
|
||||
// return result.error500("该编号已存在!");
|
||||
// }
|
||||
// try {
|
||||
// sysTenantService.save(sysTenant);
|
||||
// result.success("添加成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// *
|
||||
// * @param
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<SysTenant> edit(@RequestBody SysTenant tenant) {
|
||||
// Result<SysTenant> result = new Result();
|
||||
// SysTenant sysTenant = sysTenantService.getById(tenant.getId());
|
||||
// if (sysTenant == null) {
|
||||
// return result.error500("未找到对应实体");
|
||||
// }
|
||||
// boolean ok = sysTenantService.updateById(tenant);
|
||||
// if (ok) {
|
||||
// result.success("修改成功!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/delete", method = {RequestMethod.DELETE, RequestMethod.POST})
|
||||
// public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// sysTenantService.removeTenantById(id);
|
||||
// return Result.ok("删除成功");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除
|
||||
// *
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
// public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
// Result<?> result = new Result<>();
|
||||
// if (oConvertUtils.isEmpty(ids)) {
|
||||
// result.error500("未选中租户!");
|
||||
// } else {
|
||||
// String[] ls = ids.split(",");
|
||||
// // 过滤掉已被引用的租户
|
||||
// List<Integer> idList = new ArrayList<>();
|
||||
// for (String id : ls) {
|
||||
// Long userCount = sysTenantService.countUserLinkTenant(id);
|
||||
// if (userCount == 0) {
|
||||
// idList.add(Integer.parseInt(id));
|
||||
// }
|
||||
// }
|
||||
// if (idList.size() > 0) {
|
||||
// sysTenantService.removeByIds(idList);
|
||||
// if (ls.length == idList.size()) {
|
||||
// result.success("删除成功!");
|
||||
// } else {
|
||||
// result.success("部分删除成功!(被引用的租户无法删除)");
|
||||
// }
|
||||
// } else {
|
||||
// result.error500("选择的租户都已被引用,无法删除!");
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id查询
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
||||
// public Result<SysTenant> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysTenant> result = new Result<SysTenant>();
|
||||
// SysTenant sysTenant = sysTenantService.getById(id);
|
||||
// if (sysTenant == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// result.setResult(sysTenant);
|
||||
// result.setSuccess(true);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 查询有效的 租户数据
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/queryList", method = RequestMethod.GET)
|
||||
// public Result<List<SysTenant>> queryList(@RequestParam(name = "ids", required = false) String ids) {
|
||||
// Result<List<SysTenant>> result = new Result<List<SysTenant>>();
|
||||
// LambdaQueryWrapper<SysTenant> query = new LambdaQueryWrapper<>();
|
||||
// query.eq(SysTenant::getStatus, 1);
|
||||
// if (oConvertUtils.isNotEmpty(ids)) {
|
||||
// query.in(SysTenant::getId, ids.split(","));
|
||||
// }
|
||||
// //此处查询忽略时间条件
|
||||
// List<SysTenant> ls = sysTenantService.list(query);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(ls);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询当前用户的所有有效租户 【当前用于vue3版本】
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/getCurrentUserTenant", method = RequestMethod.GET)
|
||||
// public Result<Map<String, Object>> getCurrentUserTenant() {
|
||||
// Result<Map<String, Object>> result = new Result<Map<String, Object>>();
|
||||
// try {
|
||||
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//// String tenantIds = sysUser.getRelTenantIds();
|
||||
// Map<String, Object> map = new HashMap(5);
|
||||
//// if (oConvertUtils.isNotEmpty(tenantIds)) {
|
||||
//// List<Integer> tenantIdList = new ArrayList<>();
|
||||
//// for (String id : tenantIds.split(",")) {
|
||||
//// tenantIdList.add(Integer.valueOf(id));
|
||||
//// }
|
||||
//// // 该方法仅查询有效的租户,如果返回0个就说明所有的租户均无效。
|
||||
//// List<SysTenant> tenantList = sysTenantService.queryEffectiveTenant(tenantIdList);
|
||||
//// map.put("list", tenantList);
|
||||
//// }
|
||||
// result.setSuccess(true);
|
||||
//// result.setResult(map);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("查询失败!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
//package digital.system.modules.system.controller;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.util.exception.JeecgBootException;
|
||||
//import digital.system.modules.oss.entity.OSSFile;
|
||||
//import digital.system.modules.oss.service.IOSSFileService;
|
||||
//import digital.util.util.CommonUtils;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//
|
||||
///**
|
||||
// * minio文件上传示例
|
||||
// *
|
||||
// * @author: smcp
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/upload")
|
||||
//public class SysUploadController {
|
||||
// @Autowired
|
||||
// private IOSSFileService ossFileService;
|
||||
//
|
||||
// /**
|
||||
// * 上传
|
||||
// *
|
||||
// * @param request
|
||||
// */
|
||||
// @PostMapping(value = "/uploadMinio")
|
||||
// public Result<?> uploadMinio(HttpServletRequest request) {
|
||||
// Result<?> result = new Result<>();
|
||||
// String bizPath = request.getParameter("biz");
|
||||
//
|
||||
// //LOWCOD-2580 sys/common/upload接口存在任意文件上传漏洞
|
||||
// if (oConvertUtils.isNotEmpty(bizPath) && (bizPath.contains("../") || bizPath.contains("..\\"))) {
|
||||
// throw new JeecgBootException("上传目录bizPath,格式非法!");
|
||||
// }
|
||||
//
|
||||
// if (oConvertUtils.isEmpty(bizPath)) {
|
||||
// bizPath = "";
|
||||
// }
|
||||
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
// // 获取上传文件对象
|
||||
// MultipartFile file = multipartRequest.getFile("file");
|
||||
// // 获取文件名
|
||||
// String orgName = file.getOriginalFilename();
|
||||
// orgName = CommonUtils.getFileName(orgName);
|
||||
// String file_url = MinioUtil.upload(file, bizPath);
|
||||
// if (oConvertUtils.isEmpty(file_url)) {
|
||||
// return Result.error("上传失败,请检查配置信息是否正确!");
|
||||
// }
|
||||
// //保存文件信息
|
||||
// OSSFile minioFile = new OSSFile();
|
||||
// minioFile.setFileName(orgName);
|
||||
// minioFile.setUrl(file_url);
|
||||
// ossFileService.save(minioFile);
|
||||
// result.setMessage(file_url);
|
||||
// result.setSuccess(true);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import digital.system.jeecg.group.query.QueryGenerator;
|
||||
//import digital.system.jeecg.system.entity.SysUserAgent;
|
||||
//import digital.system.jeecg.system.service.ISysUserAgentService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
//import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
//import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
//import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
//import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.base.vo.Result;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.io.IOException;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * @Title: Controller
|
||||
// * @Description: 用户代理人设置
|
||||
// * @Author: zita
|
||||
// * @Date: 2019-04-17
|
||||
// * @Version: V1.0
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/sysUserAgent")
|
||||
//@Slf4j
|
||||
//public class SysUserAgentController {
|
||||
// @Autowired
|
||||
// private ISysUserAgentService sysUserAgentService;
|
||||
//
|
||||
// @Value("${jeecg.path.upload}")
|
||||
// private String upLoadPath;
|
||||
//
|
||||
// /**
|
||||
// * 分页列表查询
|
||||
// *
|
||||
// * @param sysUserAgent
|
||||
// * @param pageNo
|
||||
// * @param pageSize
|
||||
// * @param req
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping(value = "/list")
|
||||
// public Result<IPage<SysUserAgent>> queryPageList(SysUserAgent sysUserAgent,
|
||||
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
// HttpServletRequest req) {
|
||||
// Result<IPage<SysUserAgent>> result = new Result<IPage<SysUserAgent>>();
|
||||
// QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, req.getParameterMap());
|
||||
// Page<SysUserAgent> page = new Page<SysUserAgent>(pageNo, pageSize);
|
||||
// IPage<SysUserAgent> pageList = sysUserAgentService.page(page, queryWrapper);
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(pageList);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加
|
||||
// *
|
||||
// * @param sysUserAgent
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping(value = "/add")
|
||||
// public Result<SysUserAgent> add(@RequestBody SysUserAgent sysUserAgent) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// try {
|
||||
// sysUserAgentService.save(sysUserAgent);
|
||||
// result.success("代理人设置成功!");
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// result.error500("操作失败");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// *
|
||||
// * @param sysUserAgent
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
// public Result<SysUserAgent> edit(@RequestBody SysUserAgent sysUserAgent) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// SysUserAgent sysUserAgentEntity = sysUserAgentService.getById(sysUserAgent.getId());
|
||||
// if (sysUserAgentEntity == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// boolean ok = sysUserAgentService.updateById(sysUserAgent);
|
||||
// //TODO 返回false说明什么?
|
||||
// if (ok) {
|
||||
// result.success("代理人设置成功!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id删除
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @DeleteMapping(value = "/delete")
|
||||
// public Result<SysUserAgent> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// SysUserAgent sysUserAgent = sysUserAgentService.getById(id);
|
||||
// if (sysUserAgent == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// boolean ok = sysUserAgentService.removeById(id);
|
||||
// if (ok) {
|
||||
// result.success("删除成功!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 批量删除
|
||||
// *
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @DeleteMapping(value = "/deleteBatch")
|
||||
// public Result<SysUserAgent> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// if (ids == null || "".equals(ids.trim())) {
|
||||
// result.error500("参数不识别!");
|
||||
// } else {
|
||||
// this.sysUserAgentService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
// result.success("删除成功!");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过id查询
|
||||
// *
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping(value = "/queryById")
|
||||
// public Result<SysUserAgent> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// SysUserAgent sysUserAgent = sysUserAgentService.getById(id);
|
||||
// if (sysUserAgent == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// result.setResult(sysUserAgent);
|
||||
// result.setSuccess(true);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过userName查询
|
||||
// *
|
||||
// * @param userName
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping(value = "/queryByUserName")
|
||||
// public Result<SysUserAgent> queryByUserName(@RequestParam(name = "userName", required = true) String userName) {
|
||||
// Result<SysUserAgent> result = new Result<SysUserAgent>();
|
||||
// LambdaQueryWrapper<SysUserAgent> queryWrapper = new LambdaQueryWrapper<SysUserAgent>();
|
||||
// queryWrapper.eq(SysUserAgent::getUserName, userName);
|
||||
// SysUserAgent sysUserAgent = sysUserAgentService.getOne(queryWrapper);
|
||||
// if (sysUserAgent == null) {
|
||||
// result.error500("未找到对应实体");
|
||||
// } else {
|
||||
// result.setResult(sysUserAgent);
|
||||
// result.setSuccess(true);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出excel
|
||||
// *
|
||||
// * @param sysUserAgent
|
||||
// * @param request
|
||||
// */
|
||||
// @RequestMapping(value = "/exportXls")
|
||||
// public ModelAndView exportXls(SysUserAgent sysUserAgent, HttpServletRequest request) {
|
||||
// // Step.1 组装查询条件
|
||||
// QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
|
||||
// //Step.2 AutoPoi 导出Excel
|
||||
// ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
|
||||
// //导出文件名称
|
||||
// mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
|
||||
// mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
|
||||
// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// ExportParams exportParams = new ExportParams("用户代理人设置列表数据", "导出人:" + user.getRealname(), "导出信息");
|
||||
// exportParams.setImageBasePath(upLoadPath);
|
||||
// mv.addObject(NormalExcelConstants.PARAMS, exportParams);
|
||||
// mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
// return mv;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 通过excel导入数据
|
||||
// *
|
||||
// * @param request
|
||||
// * @param response
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
// public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
// Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// // 获取上传文件对象
|
||||
// MultipartFile file = entity.getValue();
|
||||
// ImportParams params = new ImportParams();
|
||||
// params.setTitleRows(2);
|
||||
// params.setHeadRows(1);
|
||||
// params.setNeedSave(true);
|
||||
// try {
|
||||
// List<SysUserAgent> listSysUserAgents = ExcelImportUtil.importExcel(file.getInputStream(), SysUserAgent.class, params);
|
||||
// for (SysUserAgent sysUserAgentExcel : listSysUserAgents) {
|
||||
// sysUserAgentService.save(sysUserAgentExcel);
|
||||
// }
|
||||
// return Result.ok("文件导入成功!数据行数:" + listSysUserAgents.size());
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// return Result.error("文件导入失败!");
|
||||
// } finally {
|
||||
// try {
|
||||
// file.getInputStream().close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return Result.error("文件导入失败!");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
//package digital.system.jeecg.system.controller;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.apache.shiro.SecurityUtils;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//import digital.base.constant.CacheConstant;
|
||||
//import digital.base.constant.CommonConstant;
|
||||
//import digital.base.constant.LanguageTypeConstants;
|
||||
//import digital.base.vo.LoginUser;
|
||||
//import digital.base.vo.Result;
|
||||
//import digital.system.jeecg.group.base.service.BaseCommonService;
|
||||
//import digital.system.jeecg.system.service.ISysUserService;
|
||||
//import digital.system.jeecg.system.service.impl.SysBaseApiImpl;
|
||||
//import digital.system.jeecg.system.vo.SysUserOnlineVO;
|
||||
//import digital.util.util.JeecgRedisUtil;
|
||||
//import digital.util.util.JwtUtil;
|
||||
//import digital.util.util.oConvertUtils;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collection;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @Description: 在线用户
|
||||
// * @Author: chenli
|
||||
// * @Date: 2020-06-07
|
||||
// * @Version: V1.0
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping("/sys/online")
|
||||
//@Slf4j
|
||||
//public class SysUserOnlineController {
|
||||
//
|
||||
// @Autowired
|
||||
// public RedisTemplate redisTemplate;
|
||||
// @Autowired
|
||||
// public ISysUserService userService;
|
||||
// @Autowired
|
||||
// private JeecgRedisUtil jeecgRedisUtil;
|
||||
// @Autowired
|
||||
// private SysBaseApiImpl sysBaseApi;
|
||||
//
|
||||
// @Resource
|
||||
// private BaseCommonService baseCommonService;
|
||||
//
|
||||
// @RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
// public Result<Page<SysUserOnlineVO>> list(@RequestParam(name = "username", required = false) String username,
|
||||
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
// Collection<String> keys = redisTemplate.keys(CommonConstant.PREFIX_USER_TOKEN + "*");
|
||||
// List<SysUserOnlineVO> onlineList = new ArrayList<SysUserOnlineVO>();
|
||||
// for (String key : keys) {
|
||||
// String token = (String) jeecgRedisUtil.get(key);
|
||||
// if (StringUtils.isNotEmpty(token)) {
|
||||
// SysUserOnlineVO online = new SysUserOnlineVO();
|
||||
// online.setToken(token);
|
||||
// //TODO 改成一次性查询
|
||||
// LoginUser loginUser = sysBaseApi.getUserByName(JwtUtil.getUsername(token));
|
||||
// if (loginUser != null) {
|
||||
// //update-begin---author:wangshuai ---date:20220104 for:[JTC-382]在线用户查询无效------------
|
||||
// //验证用户名是否与传过来的用户名相同
|
||||
// boolean isMatchUsername = true;
|
||||
// //判断用户名是否为空,并且当前循环的用户不包含传过来的用户名,那么就设成false
|
||||
// if (oConvertUtils.isNotEmpty(username) && !loginUser.getUsername().contains(username)) {
|
||||
// isMatchUsername = false;
|
||||
// }
|
||||
// if (isMatchUsername) {
|
||||
// BeanUtils.copyProperties(loginUser, online);
|
||||
// onlineList.add(online);
|
||||
// }
|
||||
// //update-end---author:wangshuai ---date:20220104 for:[JTC-382]在线用户查询无效------------
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Collections.reverse(onlineList);
|
||||
//
|
||||
// Page<SysUserOnlineVO> page = new Page<SysUserOnlineVO>(pageNo, pageSize);
|
||||
// int count = onlineList.size();
|
||||
// List<SysUserOnlineVO> pages = new ArrayList<>();
|
||||
// // 计算当前页第一条数据的下标
|
||||
// int currId = pageNo > 1 ? (pageNo - 1) * pageSize : 0;
|
||||
// for (int i = 0; i < pageSize && i < count - currId; i++) {
|
||||
// pages.add(onlineList.get(currId + i));
|
||||
// }
|
||||
// page.setSize(pageSize);
|
||||
// page.setCurrent(pageNo);
|
||||
// page.setTotal(count);
|
||||
// // 计算分页总页数
|
||||
// page.setPages(count % 10 == 0 ? count / 10 : count / 10 + 1);
|
||||
// page.setRecords(pages);
|
||||
//
|
||||
// Result<Page<SysUserOnlineVO>> result = new Result<Page<SysUserOnlineVO>>();
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(page);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
package digital.system.jeecg.system.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.base.annotation.AutoLog;
|
||||
import digital.base.vo.Result;
|
||||
import digital.system.jeecg.group.base.controller.JeecgController;
|
||||
import digital.system.jeecg.group.query.QueryGenerator;
|
||||
import digital.system.jeecg.system.entity.SysVersion;
|
||||
import digital.system.jeecg.system.service.ISysVersionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: sys_version
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-03-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="sys_version")
|
||||
@RestController
|
||||
@RequestMapping("/sysVersion/sysVersion")
|
||||
@Slf4j
|
||||
public class SysVersionController extends JeecgController<SysVersion, ISysVersionService> {
|
||||
@Autowired
|
||||
private ISysVersionService sysVersionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysVersion
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "sys_version-分页列表查询")
|
||||
@ApiOperation(value="sys_version-分页列表查询", notes="sys_version-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SysVersion>> queryPageList(SysVersion sysVersion,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysVersion> queryWrapper = QueryGenerator.initQueryWrapper(sysVersion, req.getParameterMap());
|
||||
Page<SysVersion> page = new Page<SysVersion>(pageNo, pageSize);
|
||||
IPage<SysVersion> pageList = sysVersionService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysVersion
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "sys_version-添加")
|
||||
@ApiOperation(value="sys_version-添加", notes="sys_version-添加")
|
||||
@RequiresPermissions("sysVersion:sys_version:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody SysVersion sysVersion) {
|
||||
sysVersionService.save(sysVersion);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysVersion
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "sys_version-编辑")
|
||||
@ApiOperation(value="sys_version-编辑", notes="sys_version-编辑")
|
||||
@RequiresPermissions("sysVersion:sys_version:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody SysVersion sysVersion) {
|
||||
sysVersionService.updateById(sysVersion);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "sys_version-通过id删除")
|
||||
@ApiOperation(value="sys_version-通过id删除", notes="sys_version-通过id删除")
|
||||
@RequiresPermissions("sysVersion:sys_version:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysVersionService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "sys_version-批量删除")
|
||||
@ApiOperation(value="sys_version-批量删除", notes="sys_version-批量删除")
|
||||
@RequiresPermissions("sysVersion:sys_version:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysVersionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "sys_version-通过id查询")
|
||||
@ApiOperation(value="sys_version-通过id查询", notes="sys_version-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysVersion> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysVersion sysVersion = sysVersionService.getById(id);
|
||||
if(sysVersion==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(sysVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysVersion
|
||||
*/
|
||||
@RequiresPermissions("sysVersion:sys_version:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysVersion sysVersion) {
|
||||
return super.exportXls(request, sysVersion, SysVersion.class, "sys_version");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("sysVersion:sys_version:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysVersion.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package digital.system.jeecg.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import digital.base.annotation.Dict;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 系统通告表
|
||||
* @Author: zita
|
||||
* @Date: 2019-01-02
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_announcement")
|
||||
public class SysAnnouncement implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Excel(name = "标题", width = 15)
|
||||
private java.lang.String titile;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Excel(name = "内容", width = 30)
|
||||
private java.lang.String msgContent;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Excel(name = "开始时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@Excel(name = "结束时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date endTime;
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
@Excel(name = "发布人", width = 15)
|
||||
private java.lang.String sender;
|
||||
/**
|
||||
* 优先级(L低,M中,H高)
|
||||
*/
|
||||
@Excel(name = "优先级", width = 15, dicCode = "priority")
|
||||
@Dict(dicCode = "priority")
|
||||
private java.lang.String priority;
|
||||
|
||||
/**
|
||||
* 消息类型1:通知公告2:系统消息
|
||||
*/
|
||||
@Excel(name = "消息类型", width = 15, dicCode = "msg_category")
|
||||
@Dict(dicCode = "msg_category")
|
||||
private java.lang.String msgCategory;
|
||||
/**
|
||||
* 通告对象类型(USER:指定用户,ALL:全体用户)
|
||||
*/
|
||||
@Excel(name = "通告对象类型", width = 15, dicCode = "msg_type")
|
||||
@Dict(dicCode = "msg_type")
|
||||
private java.lang.String msgType;
|
||||
/**
|
||||
* 发布状态(0未发布,1已发布,2已撤销)
|
||||
*/
|
||||
@Excel(name = "发布状态", width = 15, dicCode = "send_status")
|
||||
@Dict(dicCode = "send_status")
|
||||
private java.lang.String sendStatus;
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Excel(name = "发布时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date sendTime;
|
||||
/**
|
||||
* 撤销时间
|
||||
*/
|
||||
@Excel(name = "撤销时间", width = 15, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date cancelTime;
|
||||
/**
|
||||
* 删除状态(0,正常,1已删除)
|
||||
*/
|
||||
private java.lang.String delFlag;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 指定用户
|
||||
**/
|
||||
private java.lang.String userIds;
|
||||
/**
|
||||
* 业务类型(email:邮件 bpm:流程)
|
||||
*/
|
||||
private java.lang.String busType;
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private java.lang.String busId;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private java.lang.String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private java.lang.String openPage;
|
||||
/**
|
||||
* 摘要
|
||||
*/
|
||||
private java.lang.String msgAbstract;
|
||||
/**
|
||||
* 钉钉task_id,用于撤回消息
|
||||
*/
|
||||
private java.lang.String dtTaskId;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package digital.system.jeecg.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 用户通告阅读标记表
|
||||
* @Author: zita
|
||||
* @Date: 2019-02-21
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_announcement_send")
|
||||
public class SysAnnouncementSend implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 通告id
|
||||
*/
|
||||
private java.lang.String anntId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private java.lang.String userId;
|
||||
/**
|
||||
* 阅读状态(0未读,1已读)
|
||||
*/
|
||||
private java.lang.String readFlag;
|
||||
/**
|
||||
* 阅读时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date readTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package digital.system.jeecg.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: zita
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_category")
|
||||
public class SysCategory implements Serializable, Comparable<SysCategory> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 父级节点
|
||||
*/
|
||||
private java.lang.String pid;
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@Excel(name = "类型名称", width = 15)
|
||||
private java.lang.String name;
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
@Excel(name = "类型编码", width = 15)
|
||||
private java.lang.String code;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private java.lang.String sysOrgCode;
|
||||
/**
|
||||
* 是否有子节点
|
||||
*/
|
||||
@Excel(name = "是否有子节点(1:有)", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
// <0:当前对象比传入对象小。
|
||||
// =0:当前对象等于传入对象。
|
||||
// >0:当前对象比传入对象大。
|
||||
int s = this.code.length() - o.code.length();
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysCategory [code=" + code + ", name=" + name + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package digital.system.jeecg.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: zita
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_check_rule")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "sys_check_rule对象", description = "编码校验规则")
|
||||
public class SysCheckRule {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Excel(name = "规则名称", width = 15)
|
||||
@ApiModelProperty(value = "规则名称")
|
||||
private String ruleName;
|
||||
/**
|
||||
* 规则Code
|
||||
*/
|
||||
@Excel(name = "规则Code", width = 15)
|
||||
@ApiModelProperty(value = "规则Code")
|
||||
private String ruleCode;
|
||||
/**
|
||||
* 规则JSON
|
||||
*/
|
||||
@Excel(name = "规则JSON", width = 15)
|
||||
@ApiModelProperty(value = "规则JSON")
|
||||
private String ruleJson;
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Excel(name = "规则描述", width = 15)
|
||||
@ApiModelProperty(value = "规则描述")
|
||||
private String ruleDescription;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user