♻️ Refactoring code. close #3430 主键策略调整为 ASSIGN_ID , 增加审计字段自动填充

This commit is contained in:
lbw authored and lbw committed 2021-12-08 17:58:58 +08:00
1 parent 4fc541e2f4
commit 5d318f994c
110 files changed
+408 -269

No files matched your search

@@ -17,9 +17,6 @@
package com.pig4cloud.pigx.auth.handler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.pig4cloud.pigx.admin.api.dto.SysLogDTO;
import com.pig4cloud.pigx.admin.api.feign.RemoteLogService;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
@@ -31,13 +28,15 @@ import com.pig4cloud.pigx.common.security.handler.AuthenticationFailureHandler;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author lengleng
* @date 2018/10/8
@@ -72,7 +71,7 @@ public class PigxAuthenticationFailureEventHandler implements AuthenticationFail
sysLog.setException(authenticationException.getLocalizedMessage());
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
sysLog.setServiceId(WebUtils.extractClientId(header).orElse("N/A"));
sysLog.setTenantId(Integer.parseInt(tenantKeyStrResolver.key()));
sysLog.setTenantId(Long.parseLong(tenantKeyStrResolver.key()));
logService.saveLog(sysLog, SecurityConstants.FROM_IN);
@@ -68,7 +68,7 @@ public class PigxAuthenticationLogoutEventHandler implements AuthenticationLogou
// 获取clientId 信息
OAuth2Authentication auth2Authentication = (OAuth2Authentication) authentication;
sysLog.setServiceId(auth2Authentication.getOAuth2Request().getClientId());
sysLog.setTenantId(Integer.parseInt(tenantKeyStrResolver.key()));
sysLog.setTenantId(Long.parseLong(tenantKeyStrResolver.key()));
// 保存退出的token
String token = request.getHeader(HttpHeaders.AUTHORIZATION);
sysLog.setParams(token);
@@ -64,7 +64,7 @@ public class PigxAuthenticationSuccessEventHandler implements AuthenticationSucc
sysLog.setParams(username);
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
sysLog.setServiceId(WebUtils.extractClientId(header).orElse("N/A"));
sysLog.setTenantId(Integer.parseInt(tenantKeyStrResolver.key()));
sysLog.setTenantId(Long.parseLong(tenantKeyStrResolver.key()));
logService.saveLog(sysLog, SecurityConstants.FROM_IN);
log.info("用户:{} 登录成功", username);
@@ -38,7 +38,7 @@ public interface CommonConstants {
/**
* 租户ID
*/
Integer TENANT_ID_1 = 1;
Long TENANT_ID_1 = 1L;
/**
* 删除
@@ -58,7 +58,7 @@ public interface CommonConstants {
/**
* 菜单树根节点
*/
Integer MENU_TREE_ROOT_ID = -1;
Long MENU_TREE_ROOT_ID = -1L;
/**
* 编码
@@ -118,7 +118,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils {
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
return ((ServletRequestAttributes) requestAttributes).getRequest();
}
catch (IllegalStateException e) {
catch (Exception e) {
return null;
}
}
@@ -40,7 +40,7 @@ public class DataScope extends HashMap {
/**
* 具体的数据范围
*/
private List<Integer> deptIds = new ArrayList<>();
private List<Long> deptIds = new ArrayList<>();
/**
* 是否只查询本部门
@@ -32,6 +32,6 @@ public interface DataScopeHandle {
* @param deptList 部门ID,如果为空表示没有任何数据权限。
* @return 返回true表示无需进行数据过滤处理,返回false表示需要进行数据过滤
*/
Boolean calcScope(List<Integer> deptList);
Boolean calcScope(List<Long> deptList);
}
@@ -38,7 +38,7 @@ public class DataScopeInnerInterceptor implements InnerInterceptor {
}
String scopeName = dataScope.getScopeName();
List<Integer> deptIds = dataScope.getDeptIds();
List<Long> deptIds = dataScope.getDeptIds();
// 优先获取赋值数据
if (CollUtil.isEmpty(deptIds) && dataScopeHandle.calcScope(deptIds)) {
originalSql = String.format("SELECT %s FROM (%s) temp_data_scope", dataScope.getFunc().getType(),
@@ -50,7 +50,7 @@ public class PigxDefaultDatascopeHandle implements DataScopeHandle {
* @return
*/
@Override
public Boolean calcScope(List<Integer> deptList) {
public Boolean calcScope(List<Long> deptList) {
PigxUser user = SecurityUtils.getUser();
List<String> roleIdList = user.getAuthorities().stream().map(GrantedAuthority::getAuthority)
.filter(authority -> authority.startsWith(SecurityConstants.ROLE))
@@ -74,11 +74,11 @@ public class PigxDefaultDatascopeHandle implements DataScopeHandle {
if (DataScopeTypeEnum.CUSTOM.getType() == dsType && StrUtil.isNotBlank(role.getDsScope())) {
String dsScope = role.getDsScope();
deptList.addAll(
Arrays.stream(dsScope.split(StrUtil.COMMA)).map(Integer::parseInt).collect(Collectors.toList()));
Arrays.stream(dsScope.split(StrUtil.COMMA)).map(Long::parseLong).collect(Collectors.toList()));
}
// 查询本级及其下级
if (DataScopeTypeEnum.OWN_CHILD_LEVEL.getType() == dsType) {
List<Integer> deptIdList = dataScopeService.getDescendantList(user.getDeptId()).getData().stream()
List<Long> deptIdList = dataScopeService.getDescendantList(user.getDeptId()).getData().stream()
.map(SysDeptRelation::getDescendant).collect(Collectors.toList());
deptList.addAll(deptIdList);
}
@@ -0,0 +1,45 @@
package com.pig4cloud.pigx.common.data.mybatis;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 抽象实体
*
* @author lengleng
* @date 2021/8/9
*/
@Getter
@Setter
public class BaseEntity implements Serializable {
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.common.data.mybatis;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
@@ -123,4 +124,13 @@ public class MybatisPlusConfiguration implements WebMvcConfigurer {
return new DruidSqlLogFilter(properties);
}
/**
* 审计字段自动填充
* @return {@link MetaObjectHandler}
*/
@Bean
public MybatisPlusMetaObjectHandler mybatisPlusMetaObjectHandler() {
return new MybatisPlusMetaObjectHandler();
}
}
@@ -0,0 +1,78 @@
package com.pig4cloud.pigx.common.data.mybatis;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.ClassUtils;
import java.nio.charset.Charset;
import java.time.LocalDateTime;
import java.util.Optional;
/**
* MybatisPlus 自动填充配置
*
* @author L.cm
*/
@Slf4j
public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
log.debug("mybatis plus start insert fill ....");
LocalDateTime now = LocalDateTime.now();
fillValIfNullByName("createTime", now, metaObject, false);
fillValIfNullByName("updateTime", now, metaObject, false);
fillValIfNullByName("createBy", getUserName(), metaObject, false);
fillValIfNullByName("updateBy", getUserName(), metaObject, false);
}
@Override
public void updateFill(MetaObject metaObject) {
log.debug("mybatis plus start update fill ....");
fillValIfNullByName("updateTime", LocalDateTime.now(), metaObject, true);
fillValIfNullByName("updateBy", getUserName(), metaObject, true);
}
/**
* 填充值,先判断是否有手动设置,优先手动设置的值,例如:job必须手动设置
* @param fieldName 属性名
* @param fieldVal 属性值
* @param metaObject MetaObject
* @param isCover 是否覆盖原有值,避免更新操作手动入参
*/
private static void fillValIfNullByName(String fieldName, Object fieldVal, MetaObject metaObject, boolean isCover) {
// 1. 没有 get 方法
if (!metaObject.hasSetter(fieldName)) {
return;
}
// 2. 如果用户有手动设置的值
Object userSetValue = metaObject.getValue(fieldName);
String setValueStr = StrUtil.str(userSetValue, Charset.defaultCharset());
if (StrUtil.isNotBlank(setValueStr) && !isCover) {
return;
}
// 3. field 类型相同时设置
Class<?> getterType = metaObject.getGetterType(fieldName);
if (ClassUtils.isAssignableValue(getterType, fieldVal)) {
metaObject.setValue(fieldName, fieldVal);
}
}
/**
* 获取 spring security 当前的用户名
* @return 当前用户名
*/
private String getUserName() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (Optional.ofNullable(authentication).isPresent()) {
return authentication.getName();
}
return null;
}
}
@@ -22,8 +22,8 @@ public class ParamResolver {
* @param defaultVal 默认值
* @return value
*/
public Integer getInt(String key, Integer... defaultVal) {
return checkAndGet(key, Integer.class, defaultVal);
public Long getLong(String key, Long... defaultVal) {
return checkAndGet(key, Long.class, defaultVal);
}
/**
@@ -43,7 +43,7 @@ public class PigxTenantHandler implements TenantLineHandler {
*/
@Override
public Expression getTenantId() {
Integer tenantId = TenantContextHolder.getTenantId();
Long tenantId = TenantContextHolder.getTenantId();
log.debug("当前租户为 >> {}", tenantId);
if (tenantId == null) {
@@ -70,7 +70,7 @@ public class PigxTenantHandler implements TenantLineHandler {
*/
@Override
public boolean ignoreTable(String tableName) {
Integer tenantId = TenantContextHolder.getTenantId();
Long tenantId = TenantContextHolder.getTenantId();
// 租户中ID 为空,查询全部,不进行过滤
if (tenantId == null) {
return Boolean.TRUE;
@@ -73,8 +73,8 @@ public class TenantBroker {
* @param tenant 租户ID
* @param func
*/
public void runAs(Integer tenant, RunAs<Integer> func) {
final Integer pre = TenantContextHolder.getTenantId();
public void runAs(Long tenant, RunAs<Long> func) {
final Long pre = TenantContextHolder.getTenantId();
try {
log.trace("TenantBroker 切换租户{} -> {}", pre, tenant);
TenantContextHolder.setTenantId(tenant);
@@ -96,8 +96,8 @@ public class TenantBroker {
* @param <T> 返回数据类型
* @return
*/
public <T> T applyAs(Integer tenant, ApplyAs<Integer, T> func) {
final Integer pre = TenantContextHolder.getTenantId();
public <T> T applyAs(Long tenant, ApplyAs<Long, T> func) {
final Long pre = TenantContextHolder.getTenantId();
try {
log.trace("TenantBroker 切换租户{} -> {}", pre, tenant);
TenantContextHolder.setTenantId(tenant);
@@ -117,7 +117,7 @@ public class TenantBroker {
* @param supplier
* @param func
*/
public void runAs(Supplier<Integer> supplier, RunAs<Integer> func) {
public void runAs(Supplier<Long> supplier, RunAs<Long> func) {
runAs(supplier.get(), func);
}
@@ -128,7 +128,7 @@ public class TenantBroker {
* @param <T> 返回数据类型
* @return
*/
public <T> T applyAs(Supplier<Integer> supplier, ApplyAs<Integer, T> func) {
public <T> T applyAs(Supplier<Long> supplier, ApplyAs<Long, T> func) {
return applyAs(supplier.get(), func);
}
@@ -27,7 +27,7 @@ import lombok.experimental.UtilityClass;
@UtilityClass
public class TenantContextHolder {
private final ThreadLocal<Integer> THREAD_LOCAL_TENANT = new TransmittableThreadLocal<>();
private final ThreadLocal<Long> THREAD_LOCAL_TENANT = new TransmittableThreadLocal<>();
/**
* TTL 设置租户ID<br/>
@@ -35,7 +35,7 @@ public class TenantContextHolder {
* @param tenantId
* @see TenantBroker
*/
public void setTenantId(Integer tenantId) {
public void setTenantId(Long tenantId) {
THREAD_LOCAL_TENANT.set(tenantId);
}
@@ -43,7 +43,7 @@ public class TenantContextHolder {
* 获取TTL中的租户ID
* @return
*/
public Integer getTenantId() {
public Long getTenantId() {
return THREAD_LOCAL_TENANT.get();
}
@@ -53,10 +53,10 @@ public class TenantContextHolderFilter extends GenericFilterBean {
log.debug("获取header中的租户ID为:{}", headerTenantId);
if (StrUtil.isNotBlank(headerTenantId)) {
TenantContextHolder.setTenantId(Integer.parseInt(headerTenantId));
TenantContextHolder.setTenantId(Long.parseLong(headerTenantId));
}
else if (StrUtil.isNotBlank(paramTenantId)) {
TenantContextHolder.setTenantId(Integer.parseInt(paramTenantId));
TenantContextHolder.setTenantId(Long.parseLong(paramTenantId));
}
else {
TenantContextHolder.setTenantId(CommonConstants.TENANT_ID_1);
@@ -31,7 +31,6 @@ import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.ApplicationEventPublisher;
/**
@@ -71,7 +70,7 @@ public class SysLogAspect {
finally {
Long endTime = System.currentTimeMillis();
logDTO.setTime(endTime - startTime);
logDTO.setTenantId(Integer.parseInt(tenantKeyStrResolver.key()));
logDTO.setTenantId(Long.parseLong(tenantKeyStrResolver.key()));
publisher.publishEvent(new SysLogEvent(logDTO));
}
return obj;
@@ -91,9 +91,9 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver
String email = MapUtil.getStr(map, SecurityConstants.EMAIL);
String nickname = MapUtil.getStr(map, SecurityConstants.NICKNAME);
String username = MapUtil.getStr(map, SecurityConstants.DETAILS_USERNAME);
Integer id = MapUtil.getInt(map, SecurityConstants.DETAILS_USER_ID);
Integer deptId = MapUtil.getInt(map, SecurityConstants.DETAILS_DEPT_ID);
Integer tenantId = MapUtil.getInt(map, SecurityConstants.DETAILS_TENANT_ID);
Long id = MapUtil.getLong(map, SecurityConstants.DETAILS_USER_ID);
Long deptId = MapUtil.getLong(map, SecurityConstants.DETAILS_DEPT_ID);
Long tenantId = MapUtil.getLong(map, SecurityConstants.DETAILS_TENANT_ID);
String phone = MapUtil.getStr(map, SecurityConstants.DETAILS_PHONE);
String avatar = MapUtil.getStr(map, SecurityConstants.DETAILS_AVATAR);
PigxUser user = new PigxUser(id, username, deptId, phone, avatar, nickname, name, email, tenantId, N_A,
@@ -39,13 +39,13 @@ public class PigxUser extends User {
* 用户ID
*/
@Getter
private Integer id;
private Long id;
/**
* 部门ID
*/
@Getter
private Integer deptId;
private Long deptId;
/**
* 手机号
@@ -63,7 +63,7 @@ public class PigxUser extends User {
* 租户ID
*/
@Getter
private Integer tenantId;
private Long tenantId;
/**
* 拓展字段:昵称
@@ -106,11 +106,11 @@ public class PigxUser extends User {
* a parameter or as an element in the <code>GrantedAuthority</code> collection
*/
@JsonCreator
public PigxUser(@JsonProperty("id") Integer id, @JsonProperty("username") String username,
@JsonProperty("deptId") Integer deptId, @JsonProperty("phone") String phone,
public PigxUser(@JsonProperty("id") Long id, @JsonProperty("username") String username,
@JsonProperty("deptId") Long deptId, @JsonProperty("phone") String phone,
@JsonProperty("avatar") String avatar, @JsonProperty("nickname") String nickname,
@JsonProperty("name") String name, @JsonProperty("email") String email,
@JsonProperty("tenantId") Integer tenantId, @JsonProperty("password") String password,
@JsonProperty("tenantId") Long tenantId, @JsonProperty("password") String password,
@JsonProperty("enabled") boolean enabled, @JsonProperty("accountNonExpired") boolean accountNonExpired,
@JsonProperty("credentialsNonExpired") boolean credentialsNonExpired,
@JsonProperty("accountNonLocked") boolean accountNonLocked,
@@ -70,15 +70,15 @@ public class SecurityUtils {
* 获取用户角色信息
* @return 角色集合
*/
public List<Integer> getRoles() {
public List<Long> getRoles() {
Authentication authentication = getAuthentication();
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
List<Integer> roleIds = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
authorities.stream().filter(granted -> StrUtil.startWith(granted.getAuthority(), SecurityConstants.ROLE))
.forEach(granted -> {
String id = StrUtil.removePrefix(granted.getAuthority(), SecurityConstants.ROLE);
roleIds.add(Integer.parseInt(id));
roleIds.add(Long.parseLong(id));
});
return roleIds;
}
@@ -1,5 +1,6 @@
package com.pig4cloud.pigx.common.sequence.range.impl.db;
import cn.hutool.core.util.RandomUtil;
import com.pig4cloud.pigx.common.sequence.exception.SeqException;
import javax.sql.DataSource;
@@ -19,8 +20,8 @@ abstract class BaseDbHelper {
+ "gmt_create DATETIME NOT NULL," + "gmt_modified DATETIME NOT NULL,"
+ "PRIMARY KEY (`id`),UNIQUE uk_name (`name`)" + ")";
private final static String SQL_INSERT_RANGE = "INSERT IGNORE INTO #tableName(name,value,gmt_create,gmt_modified)"
+ " VALUE(?,?,?,?)";
private final static String SQL_INSERT_RANGE = "INSERT IGNORE INTO #tableName(id,name,value,gmt_create,gmt_modified)"
+ " VALUE(?,?,?,?,?)";
private final static String SQL_UPDATE_RANGE = "UPDATE #tableName SET value=?,gmt_modified=? WHERE name=? AND "
+ "value=?";
@@ -66,10 +67,11 @@ abstract class BaseDbHelper {
try {
conn = dataSource.getConnection();
stmt = conn.prepareStatement(SQL_INSERT_RANGE.replace("#tableName", tableName));
stmt.setString(1, name);
stmt.setLong(2, stepStart);
stmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
stmt.setLong(1, RandomUtil.randomLong());
stmt.setString(2, name);
stmt.setLong(3, stepStart);
stmt.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
stmt.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
stmt.executeUpdate();
}
catch (SQLException e) {
@@ -1,12 +1,11 @@
package com.pig4cloud.pigx.test.annotation;
import com.pig4cloud.pigx.test.WithMockSecurityContextFactory;
import org.springframework.security.test.context.support.WithSecurityContext;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import com.pig4cloud.pigx.test.WithMockSecurityContextFactory;
import org.springframework.security.test.context.support.WithSecurityContext;
/**
* @author lengleng
* @date 2020/9/22
@@ -30,6 +29,6 @@ public @interface WithMockOAuth2User {
/**
* 租户编号 默认租户编号1
*/
int tenant() default 1;
long tenant() default 1L;
}
}
@@ -91,6 +91,6 @@ public class SysLogDTO {
/**
* 租户编号
*/
private Integer tenantId;
private Long tenantId;
}
@@ -40,13 +40,13 @@ public class UserDTO extends SysUser {
* 角色ID
*/
@ApiModelProperty(value = "角色id集合")
private List<Integer> role;
private List<Long> role;
/**
* 部门id
*/
@ApiModelProperty(value = "部门id")
private Integer deptId;
private Long deptId;
/**
* 新密码
@@ -50,6 +50,6 @@ public class UserInfo implements Serializable {
* 角色集合
*/
@ApiModelProperty(value = "角色标识集合")
private Integer[] roles;
private Long[] roles;
}
@@ -47,9 +47,9 @@ public class SysDept extends Model<SysDept> {
private static final long serialVersionUID = 1L;
@TableId(value = "dept_id", type = IdType.AUTO)
@TableId(value = "dept_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "部门id")
private Integer deptId;
private Long deptId;
/**
* 部门名称
@@ -81,7 +81,7 @@ public class SysDept extends Model<SysDept> {
* 父级部门id
*/
@ApiModelProperty(value = "父级部门id")
private Integer parentId;
private Long parentId;
/**
* 是否删除 1:已删除 0:正常
@@ -44,12 +44,12 @@ public class SysDeptRelation extends Model<SysDeptRelation> {
* 祖先节点
*/
@ApiModelProperty(value = "祖先节点")
private Integer ancestor;
private Long ancestor;
/**
* 后代节点
*/
@ApiModelProperty(value = "后代节点")
private Integer descendant;
private Long descendant;
}
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -43,9 +44,9 @@ public class SysDict extends Model<SysDict> {
/**
* 编号
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "字典编号")
private Integer id;
private Long id;
/**
* 类型
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -42,15 +43,15 @@ public class SysDictItem extends Model<SysDictItem> {
/**
* 编号
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "字典项id")
private Integer id;
private Long id;
/**
* 所属字典类id
*/
@ApiModelProperty(value = "所属字典类id")
private Integer dictId;
private Long dictId;
/**
* 数据值
@@ -44,7 +44,7 @@ public class SysFile extends Model<SysFile> {
/**
* 编号
*/
@TableId(type = IdType.AUTO)
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "文件编号")
private Long id;
@@ -49,7 +49,7 @@ public class SysLog implements Serializable {
/**
* 编号
*/
@TableId(type = IdType.AUTO)
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("日志编号")
@ApiModelProperty(value = "日志编号")
private Long id;
@@ -50,9 +50,9 @@ public class SysMenu extends Model<SysMenu> {
/**
* 菜单ID
*/
@TableId(value = "menu_id", type = IdType.AUTO)
@TableId(value = "menu_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "菜单id")
private Integer menuId;
private Long menuId;
/**
* 菜单名称
@@ -72,7 +72,7 @@ public class SysMenu extends Model<SysMenu> {
*/
@NotNull(message = "菜单父ID不能为空")
@ApiModelProperty(value = "菜单父id")
private Integer parentId;
private Long parentId;
/**
* 图标
@@ -45,9 +45,9 @@ public class SysOauthClientDetails extends Model<SysOauthClientDetails> {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
@TableId(value = "id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private Integer id;
private Long id;
/**
* 客户端ID
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -44,7 +45,7 @@ public class SysPublicParam extends Model<SysPublicParam> {
/**
* 编号
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "公共参数编号")
private Long publicId;
@@ -47,9 +47,9 @@ public class SysRole extends Model<SysRole> {
private static final long serialVersionUID = 1L;
@TableId(value = "role_id", type = IdType.AUTO)
@TableId(value = "role_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "角色编号")
private Integer roleId;
private Long roleId;
@NotBlank(message = "角色名称不能为空")
@ApiModelProperty(value = "角色名称")
@@ -44,12 +44,12 @@ public class SysRoleMenu extends Model<SysRoleMenu> {
* 角色ID
*/
@ApiModelProperty(value = "角色id")
private Integer roleId;
private Long roleId;
/**
* 菜单ID
*/
@ApiModelProperty(value = "菜单id")
private Integer menuId;
private Long menuId;
}
@@ -44,9 +44,9 @@ public class SysRouteConf extends Model<SysRouteConf> {
private static final long serialVersionUID = 1L;
@JsonIgnore
@TableId(type = IdType.AUTO)
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private Integer id;
private Long id;
/**
* 路由ID
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -44,9 +45,9 @@ public class SysSocialDetails extends Model<SysSocialDetails> {
/**
* 主鍵
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private Integer id;
private Long id;
/**
* 类型
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -43,9 +44,9 @@ public class SysTenant extends Model<SysTenant> {
/**
* 租户id
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "租户id")
private Integer id;
private Long id;
/**
* 租户名称
@@ -49,7 +49,7 @@ public class SysUser implements Serializable {
*/
@TableId(value = "user_id", type = IdType.AUTO)
@ApiModelProperty(value = "主键id")
private Integer userId;
private Long userId;
/**
* 用户名
@@ -111,13 +111,13 @@ public class SysUser implements Serializable {
* 部门ID
*/
@ApiModelProperty(value = "用户所属部门id")
private Integer deptId;
private Long deptId;
/**
* 租户ID
*/
@ApiModelProperty(value = "用户所属租户id")
private Integer tenantId;
private Long tenantId;
/**
* 微信openid
@@ -44,12 +44,12 @@ public class SysUserRole extends Model<SysUserRole> {
* 用户ID
*/
@ApiModelProperty(value = "用户id")
private Integer userId;
private Long userId;
/**
* 角色ID
*/
@ApiModelProperty(value = "角色id")
private Integer roleId;
private Long roleId;
}
@@ -52,6 +52,6 @@ public interface RemoteDataScopeService {
* @return
*/
@GetMapping("/dept/getDescendantList/{deptId}")
R<List<SysDeptRelation>> getDescendantList(@PathVariable("deptId") Integer deptId);
R<List<SysDeptRelation>> getDescendantList(@PathVariable("deptId") Long deptId);
}
@@ -31,7 +31,7 @@ public class RoleVO {
/**
* 角色id
*/
private Integer roleId;
private Long roleId;
/**
* 菜单列表
@@ -44,7 +44,7 @@ public class UserVO implements Serializable {
* 主键ID
*/
@ApiModelProperty(value = "主键")
private Integer userId;
private Long userId;
/**
* 用户名
@@ -117,13 +117,13 @@ public class UserVO implements Serializable {
* 部门ID
*/
@ApiModelProperty(value = "所属部门")
private Integer deptId;
private Long deptId;
/**
* 租户ID
*/
@ApiModelProperty(value = "所属租户")
private Integer tenantId;
private Long tenantId;
/**
* 部门名称
@@ -58,7 +58,7 @@ public class SysDeptController {
* @return SysDept
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysDeptService.getById(id));
}
@@ -91,7 +91,7 @@ public class SysDeptController {
@SysLog("删除部门")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_dept_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysDeptService.removeDeptById(id));
}
@@ -113,7 +113,7 @@ public class SysDeptController {
* @return 返回子级
*/
@GetMapping(value = "/getDescendantList/{deptId}")
public R getDescendantList(@PathVariable Integer deptId) {
public R getDescendantList(@PathVariable Long deptId) {
return R.ok(
relationService.list(Wrappers.<SysDeptRelation>lambdaQuery().eq(SysDeptRelation::getAncestor, deptId)));
}
@@ -62,7 +62,7 @@ public class SysDictController {
* @return 字典信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysDictService.getById(id));
}
@@ -107,7 +107,7 @@ public class SysDictController {
@SysLog("删除字典")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return sysDictService.removeDict(id);
}
@@ -140,7 +140,7 @@ public class SysDictController {
* @return R
*/
@GetMapping("/item/{id}")
public R getDictItemById(@PathVariable("id") Integer id) {
public R getDictItemById(@PathVariable("id") Long id) {
return R.ok(sysDictItemService.getById(id));
}
@@ -174,7 +174,7 @@ public class SysDictController {
*/
@SysLog("删除字典项")
@DeleteMapping("/item/{id}")
public R removeDictItemById(@PathVariable Integer id) {
public R removeDictItemById(@PathVariable Long id) {
return sysDictItemService.removeDictItem(id);
}
@@ -53,7 +53,7 @@ public class SysMenuController {
* @return 当前用户的树形菜单
*/
@GetMapping
public R getUserMenu(String type, Integer parentId) {
public R getUserMenu(String type, Long parentId) {
// 获取符合条件的菜单
Set<SysMenu> all = new HashSet<>();
@@ -68,7 +68,7 @@ public class SysMenuController {
* @return 树形菜单
*/
@GetMapping(value = "/tree")
public R getTree(boolean lazy, Integer parentId) {
public R getTree(boolean lazy, Long parentId) {
return R.ok(sysMenuService.treeMenu(lazy, parentId));
}
@@ -78,7 +78,7 @@ public class SysMenuController {
* @return 属性集合
*/
@GetMapping("/tree/{roleId}")
public R getRoleTree(@PathVariable Integer roleId) {
public R getRoleTree(@PathVariable Long roleId) {
return R.ok(
sysMenuService.findMenuByRoleId(roleId).stream().map(SysMenu::getMenuId).collect(Collectors.toList()));
}
@@ -89,7 +89,7 @@ public class SysMenuController {
* @return 菜单详细信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysMenuService.getById(id));
}
@@ -114,7 +114,7 @@ public class SysMenuController {
@SysLog("删除菜单")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_menu_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return sysMenuService.removeMenuById(id);
}
@@ -56,7 +56,7 @@ public class SysRoleController {
* @return 角色信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysRoleService.getById(id));
}
@@ -95,7 +95,7 @@ public class SysRoleController {
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_role_del')")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysRoleService.removeRoleById(id));
}
@@ -137,7 +137,7 @@ public class SysRoleController {
* @return
*/
@PostMapping("/getRoleList")
public R getRoleList(@RequestBody List<Integer> roleIdList) {
public R getRoleList(@RequestBody List<Long> roleIdList) {
return R.ok(sysRoleService.findRolesByRoleIds(roleIdList, CollUtil.join(roleIdList, StrUtil.UNDERLINE)));
}
@@ -100,7 +100,7 @@ public class SysSocialDetailsController {
@SysLog("删除三方信息")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_social_details_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysSocialDetailsService.removeById(id));
}
@@ -66,7 +66,7 @@ public class SysTenantController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(sysTenantService.getById(id));
}
@@ -105,7 +105,7 @@ public class SysTenantController {
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_systenant_del')")
@CacheEvict(value = CacheConstants.TENANT_DETAILS, allEntries = true)
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysTenantService.removeById(id));
}
@@ -19,7 +19,6 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -29,8 +28,6 @@ import com.pig4cloud.pigx.admin.api.vo.UserExcelVO;
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
import com.pig4cloud.pigx.admin.service.SysUserService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.data.datascope.DataScope;
import com.pig4cloud.pigx.common.data.datascope.DataScopeFuncEnum;
import com.pig4cloud.pigx.common.excel.annotation.RequestExcel;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
@@ -95,7 +92,7 @@ public class SysUserController {
* @return 用户信息
*/
@GetMapping("/{id}")
public R user(@PathVariable Integer id) {
public R user(@PathVariable Long id) {
return R.ok(userService.selectUserVoById(id));
}
@@ -121,7 +118,7 @@ public class SysUserController {
@PreAuthorize("@pms.hasPermission('sys_user_del')")
@ApiOperation(value = "删除用户", notes = "根据ID删除用户")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "int", paramType = "path")
public R userDel(@PathVariable Integer id) {
public R userDel(@PathVariable Long id) {
SysUser sysUser = userService.getById(id);
return R.ok(userService.deleteUserById(sysUser));
}
@@ -205,13 +202,4 @@ public class SysUserController {
return userService.importUser(excelVOList, bindingResult);
}
@Inner(value = false)
@GetMapping("/count")
public R get() {
DataScope dataScope = new DataScope();
dataScope.setFunc(DataScopeFuncEnum.COUNT);
dataScope.setDeptIds(CollUtil.newArrayList(14, 15, 16));
return R.ok(userMapper.selectCountByScope(Wrappers.emptyWrapper(), dataScope));
}
}
@@ -38,7 +38,7 @@ public interface SysDeptRelationMapper extends PigxBaseMapper<SysDeptRelation> {
* 删除部门关系表数据
* @param id 部门ID
*/
void deleteDeptRelationsById(Integer id);
void deleteDeptRelationsById(Long id);
/**
* 更改部分关系表数据
@@ -41,7 +41,7 @@ public interface SysMenuMapper extends PigxBaseMapper<SysMenu> {
* @param roleId 角色ID
* @return
*/
List<SysMenu> listMenusByRoleId(Integer roleId);
List<SysMenu> listMenusByRoleId(Long roleId);
/**
* 通过角色ID查询权限
@@ -41,6 +41,6 @@ public interface SysRoleMapper extends PigxBaseMapper<SysRole> {
* @param userId
* @return
*/
List<SysRole> listRolesByUserId(Integer userId);
List<SysRole> listRolesByUserId(Long userId);
}
@@ -63,7 +63,7 @@ public interface SysUserMapper extends PigxBaseMapper<SysUser> {
* @param id 用户ID
* @return userVo
*/
UserVO getUserVoById(Integer id);
UserVO getUserVoById(Long id);
/**
* 查询用户列表
@@ -42,6 +42,6 @@ public interface SysUserRoleMapper extends PigxBaseMapper<SysUserRole> {
* @author 寻欢·李
* @date 2017年12月7日 16:31:38
*/
Boolean deleteByUserId(@Param("userId") Integer userId);
Boolean deleteByUserId(@Param("userId") Long userId);
}
@@ -43,7 +43,7 @@ public interface SysDeptRelationService extends IService<SysDeptRelation> {
* 通过ID删除部门关系
* @param id
*/
void deleteAllDeptRealtion(Integer id);
void deleteAllDeptRealtion(Long id);
/**
* 更新部门关系
@@ -39,7 +39,7 @@ public interface SysDeptService extends IService<SysDept> {
* 查询部门树菜单
* @return 树
*/
List<Tree<Integer>> selectTree();
List<Tree<Long>> selectTree();
/**
* 添加信息部门
@@ -53,7 +53,7 @@ public interface SysDeptService extends IService<SysDept> {
* @param id 部门 ID
* @return 成功、失败
*/
Boolean removeDeptById(Integer id);
Boolean removeDeptById(Long id);
/**
* 更新部门
@@ -33,7 +33,7 @@ public interface SysDictItemService extends IService<SysDictItem> {
* @param id 字典项ID
* @return
*/
R removeDictItem(Integer id);
R removeDictItem(Long id);
/**
* 更新字典项
@@ -33,7 +33,7 @@ public interface SysDictService extends IService<SysDict> {
* @param id
* @return
*/
R removeDict(Integer id);
R removeDict(Long id);
/**
* 更新字典
@@ -42,14 +42,14 @@ public interface SysMenuService extends IService<SysMenu> {
* @param roleId 角色ID
* @return 菜单列表
*/
List<SysMenu> findMenuByRoleId(Integer roleId);
List<SysMenu> findMenuByRoleId(Long roleId);
/**
* 级联删除菜单
* @param id 菜单ID
* @return 成功、失败
*/
R removeMenuById(Integer id);
R removeMenuById(Long id);
/**
* 更新菜单信息
@@ -64,7 +64,7 @@ public interface SysMenuService extends IService<SysMenu> {
* @param parentId 父节点ID
* @return
*/
List<Tree<Integer>> treeMenu(boolean lazy, Integer parentId);
List<Tree<Long>> treeMenu(boolean lazy, Long parentId);
/**
* 查询菜单
@@ -72,6 +72,6 @@ public interface SysMenuService extends IService<SysMenu> {
* @param parentId
* @return
*/
List<Tree<Integer>> filterMenu(Set<SysMenu> voSet, String type, Integer parentId);
List<Tree<Long>> filterMenu(Set<SysMenu> voSet, String type, Long parentId);
}
@@ -39,6 +39,6 @@ public interface SysRoleMenuService extends IService<SysRoleMenu> {
* @param menuIds 菜单ID拼成的字符串,每个id之间根据逗号分隔
* @return
*/
Boolean saveRoleMenus(String role, Integer roleId, String menuIds);
Boolean saveRoleMenus(String role, Long roleId, String menuIds);
}
@@ -40,7 +40,7 @@ public interface SysRoleService extends IService<SysRole> {
* @param userId
* @return
*/
List<SysRole> findRolesByUserId(Integer userId);
List<SysRole> findRolesByUserId(Long userId);
/**
* 根据角色ID 查询角色列表
@@ -48,14 +48,14 @@ public interface SysRoleService extends IService<SysRole> {
* @param key 缓存key
* @return
*/
List<SysRole> findRolesByRoleIds(List<Integer> roleIdList, String key);
List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key);
/**
* 通过角色ID,删除角色
* @param id
* @return
*/
Boolean removeRoleById(Integer id);
Boolean removeRoleById(Long id);
/**
* 根据角色菜单列表
@@ -39,6 +39,6 @@ public interface SysUserRoleService extends IService<SysUserRole> {
* @author 寻欢·李
* @date 2017年12月7日 16:31:38
*/
Boolean deleteByUserId(Integer userId);
Boolean deleteByUserId(Long userId);
}
@@ -79,7 +79,7 @@ public interface SysUserService extends IService<SysUser> {
* @param id 用户ID
* @return 用户信息
*/
UserVO selectUserVoById(Integer id);
UserVO selectUserVoById(Long id);
/**
* 查询上级部门的用户信息
@@ -78,7 +78,7 @@ public class SysDeptRelationServiceImpl extends ServiceImpl<SysDeptRelationMappe
* @param id
*/
@Override
public void deleteAllDeptRealtion(Integer id) {
public void deleteAllDeptRealtion(Long id) {
baseMapper.deleteDeptRelationsById(id);
}
@@ -80,9 +80,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeDeptById(Integer id) {
public Boolean removeDeptById(Long id) {
// 级联删除部门
List<Integer> idList = sysDeptRelationService
List<Long> idList = sysDeptRelationService
.list(Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getAncestor, id)).stream()
.map(SysDeptRelation::getDescendant).collect(Collectors.toList());
@@ -118,18 +118,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @return 树
*/
@Override
public List<Tree<Integer>> selectTree() {
public List<Tree<Long>> selectTree() {
// 查询全部部门
List<SysDept> deptAllList = deptMapper.selectList(Wrappers.emptyWrapper());
// 查询数据权限内部门
List<Integer> deptOwnIdList = deptMapper.selectListByScope(Wrappers.emptyWrapper(), new DataScope()).stream()
List<Long> deptOwnIdList = deptMapper.selectListByScope(Wrappers.emptyWrapper(), new DataScope()).stream()
.map(SysDept::getDeptId).collect(Collectors.toList());
// 权限内部门
List<TreeNode<Integer>> collect = deptAllList.stream()
List<TreeNode<Long>> collect = deptAllList.stream()
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
.sorted(Comparator.comparingInt(SysDept::getSort)).map(dept -> {
TreeNode<Integer> treeNode = new TreeNode();
TreeNode<Long> treeNode = new TreeNode();
treeNode.setId(dept.getDeptId());
treeNode.setParentId(dept.getParentId());
treeNode.setName(dept.getName());
@@ -142,7 +142,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
return treeNode;
}).collect(Collectors.toList());
return TreeUtil.build(collect, 0);
return TreeUtil.build(collect, 0L);
}
}
@@ -48,7 +48,7 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
*/
@Override
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R removeDictItem(Integer id) {
public R removeDictItem(Long id) {
// 根据ID查询字典ID
SysDictItem dictItem = this.getById(id);
SysDict dict = dictService.getById(dictItem.getDictId());
@@ -51,7 +51,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public R removeDict(Integer id) {
public R removeDict(Long id) {
SysDict dict = this.getById(id);
// 系统内置
if (DictTypeEnum.SYSTEM.getType().equals(dict.getSystem())) {
@@ -65,14 +65,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId", unless = "#result.isEmpty()")
public List<SysMenu> findMenuByRoleId(Integer roleId) {
public List<SysMenu> findMenuByRoleId(Long roleId) {
return baseMapper.listMenusByRoleId(roleId);
}
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
public R removeMenuById(Integer id) {
public R removeMenuById(Long id) {
// 查询父节点为当前节点的节点
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query().lambda().eq(SysMenu::getParentId, id));
if (CollUtil.isNotEmpty(menuList)) {
@@ -97,18 +97,18 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @return
*/
@Override
public List<Tree<Integer>> treeMenu(boolean lazy, Integer parentId) {
public List<Tree<Long>> treeMenu(boolean lazy, Long parentId) {
if (!lazy) {
List<TreeNode<Integer>> collect = baseMapper
List<TreeNode<Long>> collect = baseMapper
.selectList(Wrappers.<SysMenu>lambdaQuery().orderByAsc(SysMenu::getSort)).stream()
.map(getNodeFunction()).collect(Collectors.toList());
return TreeUtil.build(collect, CommonConstants.MENU_TREE_ROOT_ID);
}
Integer parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
List<TreeNode<Integer>> collect = baseMapper
List<TreeNode<Long>> collect = baseMapper
.selectList(
Wrappers.<SysMenu>lambdaQuery().eq(SysMenu::getParentId, parent).orderByAsc(SysMenu::getSort))
.stream().map(getNodeFunction()).collect(Collectors.toList());
@@ -124,17 +124,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @return
*/
@Override
public List<Tree<Integer>> filterMenu(Set<SysMenu> all, String type, Integer parentId) {
List<TreeNode<Integer>> collect = all.stream().filter(menuTypePredicate(type)).map(getNodeFunction())
public List<Tree<Long>> filterMenu(Set<SysMenu> all, String type, Long parentId) {
List<TreeNode<Long>> collect = all.stream().filter(menuTypePredicate(type)).map(getNodeFunction())
.collect(Collectors.toList());
Integer parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
Long parent = parentId == null ? CommonConstants.MENU_TREE_ROOT_ID : parentId;
return TreeUtil.build(collect, parent);
}
@NotNull
private Function<SysMenu, TreeNode<Integer>> getNodeFunction() {
private Function<SysMenu, TreeNode<Long>> getNodeFunction() {
return menu -> {
TreeNode<Integer> node = new TreeNode<>();
TreeNode<Long> node = new TreeNode<>();
node.setId(menu.getMenuId());
node.setName(menu.getName());
node.setParentId(menu.getParentId());
@@ -59,7 +59,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.MENU_DETAILS, key = "#roleId")
public Boolean saveRoleMenus(String role, Integer roleId, String menuIds) {
public Boolean saveRoleMenus(String role, Long roleId, String menuIds) {
this.remove(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getRoleId, roleId));
if (StrUtil.isBlank(menuIds)) {
@@ -68,7 +68,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
List<SysRoleMenu> roleMenuList = Arrays.stream(menuIds.split(",")).map(menuId -> {
SysRoleMenu roleMenu = new SysRoleMenu();
roleMenu.setRoleId(roleId);
roleMenu.setMenuId(Integer.valueOf(menuId));
roleMenu.setMenuId(Long.valueOf(menuId));
return roleMenu;
}).collect(Collectors.toList());
@@ -55,7 +55,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
* @return
*/
@Override
public List findRolesByUserId(Integer userId) {
public List findRolesByUserId(Long userId) {
return baseMapper.listRolesByUserId(userId);
}
@@ -67,7 +67,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
*/
@Override
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key")
public List<SysRole> findRolesByRoleIds(List<Integer> roleIdList, String key) {
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
return baseMapper.selectBatchIds(roleIdList);
}
@@ -78,7 +78,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean removeRoleById(Integer id) {
public Boolean removeRoleById(Long id) {
roleMenuService.remove(Wrappers.<SysRoleMenu>update().lambda().eq(SysRoleMenu::getRoleId, id));
return this.removeById(id);
}
@@ -101,7 +101,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
public Boolean saveTenant(SysTenant sysTenant) {
this.save(sysTenant);
// 查询系统默认租户配置参数
Integer defaultId = ParamResolver.getInt("TENANT_DEFAULT_ID", 1);
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
String defaultDeptName = ParamResolver.getStr("TENANT_DEFAULT_DEPTNAME", "租户默认部门");
String defaultUsername = ParamResolver.getStr("TENANT_DEFAULT_USERNAME", "admin");
String defaultPassword = ParamResolver.getStr("TENANT_DEFAULT_PASSWORD", "123456");
@@ -109,7 +109,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
String defaultRoleName = ParamResolver.getStr("TENANT_DEFAULT_ROLENAME", "租户默认角色");
List<SysDict> dictList = new ArrayList<>(32);
List<Integer> dictIdList = new ArrayList<>(32);
List<Long> dictIdList = new ArrayList<>(32);
List<SysDictItem> dictItemList = new ArrayList<>(64);
List<SysMenu> menuList = new ArrayList<>(128);
List<SysOauthClientDetails> clientDetailsList = new ArrayList<>(16);
@@ -136,7 +136,7 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
// 插入部门
SysDept dept = new SysDept();
dept.setName(defaultDeptName);
dept.setParentId(0);
dept.setParentId(0L);
deptService.save(dept);
// 维护部门关系
deptRelationService.insertDeptRelation(dept);
@@ -193,10 +193,10 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
* @param originParentId 原始上级
* @param targetParentId 目标上级
*/
private void saveTenantMenu(List<SysMenu> menuList, Integer originParentId, Integer targetParentId) {
private void saveTenantMenu(List<SysMenu> menuList, Long originParentId, Long targetParentId) {
menuList.stream().filter(menu -> menu.getParentId().equals(originParentId)).forEach(menu -> {
// 保存菜单原始menuId, 方便查询子节点使用
Integer originMenuId = menu.getMenuId();
Long originMenuId = menu.getMenuId();
menu.setMenuId(null);
menu.setParentId(targetParentId);
menuService.save(menu);
@@ -44,7 +44,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
* @date 2017年12月7日 16:31:38
*/
@Override
public Boolean deleteByUserId(Integer userId) {
public Boolean deleteByUserId(Long userId) {
return baseMapper.deleteByUserId(userId);
}
@@ -106,9 +106,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
UserInfo userInfo = new UserInfo();
userInfo.setSysUser(sysUser);
// 设置角色列表 (ID)
List<Integer> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId()).stream().map(SysRole::getRoleId)
List<Long> roleIds = sysRoleService.findRolesByUserId(sysUser.getUserId()).stream().map(SysRole::getRoleId)
.collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Integer.class));
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置权限列表(menu.permission)
Set<String> permissions = new HashSet<>();
@@ -139,7 +139,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return 用户信息
*/
@Override
public UserVO selectUserVoById(Integer id) {
public UserVO selectUserVoById(Long id) {
return baseMapper.getUserVoById(id);
}
@@ -216,7 +216,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return null;
}
Integer parentId = sysDept.getParentId();
Long parentId = sysDept.getParentId();
return this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDeptId, parentId));
}
@@ -318,7 +318,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 根据部门名称查询部门ID
userDTO.setDeptId(deptOptional.get().getDeptId());
// 根据角色名称查询角色ID
List<Integer> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
userDTO.setRole(roleIdList);
// 插入用户
this.saveUser(userDTO);
@@ -65,7 +65,7 @@ public class GenDsConfController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(datasourceConfService.getById(id));
}
@@ -100,7 +100,7 @@ public class GenDsConfController {
*/
@SysLog("删除数据源表")
@DeleteMapping("/{id}")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(datasourceConfService.removeByDsId(id));
}
@@ -62,7 +62,7 @@ public class GenFormConfController {
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(genRecordService.getById(id));
}
@@ -113,7 +113,7 @@ public class GenFormConfController {
@SysLog("通过id删除生成记录")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('gen_form_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(genRecordService.removeById(id));
}
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.codegen.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -41,8 +42,8 @@ public class GenDatasourceConf extends Model<GenDatasourceConf> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 名称
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.codegen.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -44,9 +45,9 @@ public class GenFormConf extends Model<GenFormConf> {
/**
* ID
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID")
private Integer id;
private Long id;
/**
* 表名称
@@ -82,6 +83,6 @@ public class GenFormConf extends Model<GenFormConf> {
* 所属租户
*/
@ApiModelProperty(value = "所属租户", hidden = true)
private Integer tenantId;
private Long tenantId;
}
@@ -60,6 +60,6 @@ public interface GenDatasourceConfService extends IService<GenDatasourceConf> {
* @param dsId 数据源ID
* @return
*/
Boolean removeByDsId(Integer dsId);
Boolean removeByDsId(Long dsId);
}
@@ -105,7 +105,7 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
* @return
*/
@Override
public Boolean removeByDsId(Integer dsId) {
public Boolean removeByDsId(Long dsId) {
DynamicRoutingDataSource dynamicRoutingDataSource = SpringContextHolder.getBean(DynamicRoutingDataSource.class);
dynamicRoutingDataSource.removeDataSource(baseMapper.selectById(dsId).getName());
this.baseMapper.deleteById(dsId);
@@ -212,7 +212,7 @@ public class SysJobController {
@PostMapping("/start-job/{id}")
@PreAuthorize("@pms.hasPermission('job_sys_job_start_job')")
@ApiOperation(value = "启动定时任务")
public R startJob(@PathVariable("id") Integer jobId) {
public R startJob(@PathVariable("id") Long jobId) {
SysJob querySysJob = this.sysJobService.getById(jobId);
if (querySysJob != null && JOB_LOG_STATUS_FAIL.getType().equals(querySysJob.getJobStatus())) {
taskUtil.addOrUpateJob(querySysJob, scheduler);
@@ -45,8 +45,8 @@ public class SysJob extends Model<SysJob> {
/**
* 任务id
*/
@TableId(value = "job_id", type = IdType.AUTO)
private Integer jobId;
@TableId(value = "job_id", type = IdType.ASSIGN_ID)
private Long jobId;
/**
* 任务名称
@@ -151,7 +151,7 @@ public class SysJob extends Model<SysJob> {
/**
* 租户id
*/
private Integer tenantId;
private Long tenantId;
/**
* 备注信息
@@ -46,13 +46,13 @@ public class SysJobLog extends Model<SysJobLog> {
/**
* 任务日志ID
*/
@TableId(value = "job_log_id", type = IdType.AUTO)
private Integer jobLogId;
@TableId(value = "job_log_id", type = IdType.ASSIGN_ID)
private Long jobLogId;
/**
* 任务id
*/
private Integer jobId;
private Long jobId;
/**
* 任务名称
@@ -127,6 +127,6 @@ public class SysJobLog extends Model<SysJobLog> {
/**
* 租户id
*/
private Integer tenantId;
private Long tenantId;
}
@@ -53,7 +53,7 @@ public class WxMpInitConfigRunner {
/**
* 保存 appid-tenantId 的对应关系
*/
private static Map<String, Integer> tenants = Maps.newHashMap();
private static final Map<String, Long> tenants = Maps.newHashMap();
private final RemoteTenantService tenantService;
@@ -169,7 +169,7 @@ public class WxMpInitConfigRunner {
return container;
}
public static Map<String, Integer> getTenants() {
public static Map<String, Long> getTenants() {
return tenants;
}
@@ -60,7 +60,7 @@ public class WxAccountController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(wxAccountService.getById(id));
}
@@ -100,7 +100,7 @@ public class WxAccountController {
@SysLog("删除公众号账户")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('mp_wxaccount_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
wxAccountService.removeById(id);
redisTemplate.convertAndSend(CacheConstants.MP_REDIS_RELOAD_TOPIC, "重新加载公众号配置");
return R.ok();
@@ -56,7 +56,7 @@ public class WxAccountFansController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(wxAccountFansService.getById(id));
}
@@ -92,7 +92,7 @@ public class WxAccountFansController {
@SysLog("删除微信公众号粉丝")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('mp_wxaccountfans_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(wxAccountFansService.removeById(id));
}
@@ -43,7 +43,7 @@ public class WxAutoReplyController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") String id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(wxAutoReplyService.getById(id));
}
@@ -56,7 +56,7 @@ public class WxFansMsgController {
* @return R
*/
@GetMapping("/{id}")
public R getById(@PathVariable("id") Integer id) {
public R getById(@PathVariable("id") Long id) {
return R.ok(wxMsgService.getById(id));
}
@@ -16,8 +16,7 @@
*/
package com.pig4cloud.pigx.mp.entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -26,6 +25,8 @@ import com.pig4cloud.pigx.common.core.sensitive.SensitiveTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 公众号账户
*
@@ -41,8 +42,8 @@ public class WxAccount extends Model<WxAccount> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 公众号名称
@@ -104,6 +105,6 @@ public class WxAccount extends Model<WxAccount> {
/**
* 租户
*/
private Integer tenantId;
private Long tenantId;
}
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.mp.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -39,8 +40,8 @@ public class WxAccountFans extends Model<WxAccountFans> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 用户标识
@@ -100,7 +101,7 @@ public class WxAccountFans extends Model<WxAccountFans> {
/**
* 微信公众号ID
*/
private Integer wxAccountId;
private Long wxAccountId;
/**
* 微信公众号appid
@@ -1,5 +1,6 @@
package com.pig4cloud.pigx.mp.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -25,8 +26,8 @@ public class WxAutoReply extends Model<WxAutoReply> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 公众号ID
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.mp.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
@@ -38,13 +39,13 @@ public class WxFansMsgRes extends Model<WxFansMsgRes> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 粉丝消息ID
*/
private Integer fansMsgId;
private Long fansMsgId;
/**
* 回复内容
@@ -54,7 +55,7 @@ public class WxFansMsgRes extends Model<WxFansMsgRes> {
/**
* 用户ID
*/
private Integer userId;
private Long userId;
/**
* 用户名
@@ -16,6 +16,7 @@
*/
package com.pig4cloud.pigx.mp.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -39,8 +40,8 @@ public class WxMpMenu extends Model<WxMpMenu> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 菜单
@@ -50,7 +51,7 @@ public class WxMpMenu extends Model<WxMpMenu> {
/**
* 微信公众号ID
*/
private Integer wxAccountId;
private Long wxAccountId;
/**
* 微信公众号appid
@@ -1,5 +1,6 @@
package com.pig4cloud.pigx.mp.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@@ -26,8 +27,8 @@ public class WxMsg extends Model<WxMsg> {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 创建时间
@@ -67,7 +68,7 @@ public class WxMsg extends Model<WxMsg> {
/**
* 微信用户ID
*/
private Integer wxUserId;
private Long wxUserId;
/**
* 昵称
@@ -61,7 +61,7 @@ public class LeaveBillController {
* @return R
*/
@GetMapping("/{leaveId}")
public R getById(@PathVariable("leaveId") Integer leaveId) {
public R getById(@PathVariable("leaveId") Long leaveId) {
return R.ok(leaveBillService.getById(leaveId));
}
@@ -95,7 +95,7 @@ public class LeaveBillController {
* @return R
*/
@DeleteMapping("/{leaveId}")
public R removeById(@PathVariable Integer leaveId) {
public R removeById(@PathVariable Long leaveId) {
return R.ok(leaveBillService.removeById(leaveId));
}
@@ -105,7 +105,7 @@ public class LeaveBillController {
* @return R
*/
@GetMapping("/submit/{leaveId}")
public R submit(@PathVariable("leaveId") Integer leaveId) {
public R submit(@PathVariable("leaveId") Long leaveId) {
return R.ok(processService.saveStartProcess(leaveId));
}
@@ -44,8 +44,8 @@ public class LeaveBill extends Model<LeaveBill> {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Integer leaveId;
@TableId(type = IdType.ASSIGN_ID)
private Long leaveId;
/**
* 申请人
@@ -59,7 +59,7 @@ public class LeaveProcessTaskListener implements TaskListener {
}
else {
List<String> userList = result.getData().stream().map(SysUser::getUsername).collect(Collectors.toList());
List<Integer> userIdList = result.getData().stream().map(SysUser::getUserId).collect(Collectors.toList());
List<Long> userIdList = result.getData().stream().map(SysUser::getUserId).collect(Collectors.toList());
log.info("当前任务 {},由 {}处理", delegateTask.getId(), userList);
delegateTask.addCandidateUsers(userList);
remindUserList.addAll(userIdList);
@@ -65,6 +65,6 @@ public interface ProcessService {
* @param leaveId
* @return
*/
Boolean saveStartProcess(Integer leaveId);
Boolean saveStartProcess(Long leaveId);
}
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff. Show more