💥 Introducing breaking changes.使用mybatis plus的雪花算法主键策略作为默认策略

This commit is contained in:
lishangbu 2021-12-24 20:26:25 +08:00
parent 289d5c1595
commit 7580baafef
54 changed files with 198 additions and 131 deletions

View File

@ -0,0 +1,47 @@
SET FOREIGN_KEY_CHECKS=0;
-- 核心库
USE `pig`;
ALTER TABLE `sys_dept` MODIFY COLUMN `dept_id` bigint NOT NULL FIRST;
ALTER TABLE `sys_dept` MODIFY COLUMN `parent_id` bigint NULL DEFAULT NULL COMMENT '父节点' AFTER `del_flag`;
ALTER TABLE `sys_dept_relation` MODIFY COLUMN `ancestor` bigint NOT NULL COMMENT '祖先节点' FIRST;
ALTER TABLE `sys_dept_relation` MODIFY COLUMN `descendant` bigint NOT NULL COMMENT '后代节点' AFTER `ancestor`;
ALTER TABLE `sys_dict` MODIFY COLUMN `id` bigint NOT NULL COMMENT '编号' FIRST;
ALTER TABLE `sys_dict_item` MODIFY COLUMN `id` bigint NOT NULL COMMENT '编号' FIRST;
ALTER TABLE `sys_dict_item` MODIFY COLUMN `dict_id` bigint NOT NULL COMMENT '字典ID' AFTER `id`;
ALTER TABLE `sys_file` MODIFY COLUMN `id` bigint NOT NULL COMMENT '编号' FIRST;
ALTER TABLE `sys_log` MODIFY COLUMN `id` bigint NOT NULL COMMENT '编号' FIRST;
ALTER TABLE `sys_menu` MODIFY COLUMN `menu_id` bigint NOT NULL COMMENT '菜单ID' FIRST;
ALTER TABLE `sys_role` MODIFY COLUMN `role_id` bigint NOT NULL FIRST;
ALTER TABLE `sys_role_menu` MODIFY COLUMN `role_id` bigint NOT NULL COMMENT '角色ID' FIRST;
ALTER TABLE `sys_role_menu` MODIFY COLUMN `menu_id` bigint NOT NULL COMMENT '菜单ID' AFTER `role_id`;
ALTER TABLE `sys_user` MODIFY COLUMN `user_id` bigint NOT NULL COMMENT '主键ID' FIRST;
ALTER TABLE `sys_user` MODIFY COLUMN `dept_id` bigint NULL DEFAULT NULL COMMENT '部门ID' AFTER `avatar`;
ALTER TABLE `sys_user_role` MODIFY COLUMN `user_id` bigint NOT NULL COMMENT '用户ID' FIRST;
ALTER TABLE `sys_user_role` MODIFY COLUMN `role_id` bigint NOT NULL COMMENT '角色ID' AFTER `user_id`;
-- 代码生成器
USE `pig_codegen`;
ALTER TABLE `pig_codegen_backup`.`gen_datasource_conf` MODIFY COLUMN `id` bigint NOT NULL COMMENT '主键' FIRST;
ALTER TABLE `pig_codegen_backup`.`gen_form_conf` MODIFY COLUMN `id` bigint NOT NULL COMMENT 'ID' FIRST;
SET FOREIGN_KEY_CHECKS=1;

View File

@ -40,7 +40,7 @@ public interface CommonConstants {
/**
* 菜单树根节点
*/
Integer MENU_TREE_ROOT_ID = -1;
Long MENU_TREE_ROOT_ID = -1L;
/**
* 菜单

View File

@ -32,13 +32,13 @@ public class PigUser extends User {
* 用户ID
*/
@Getter
private final Integer id;
private final Long id;
/**
* 部门ID
*/
@Getter
private final Integer deptId;
private final Long deptId;
/**
* 手机号
@ -46,7 +46,7 @@ public class PigUser extends User {
@Getter
private final String phone;
public PigUser(Integer id, Integer deptId, String username, String password, String phone, boolean enabled,
public PigUser(Long id, Long deptId, String username, String password, String phone, boolean enabled,
boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked,
Collection<? extends GrantedAuthority> authorities) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);

View File

@ -69,15 +69,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;
}

View File

@ -31,7 +31,7 @@ public class RoleDTO extends SysRole {
/**
* 角色部门Id
*/
private Integer roleDeptId;
private Long roleDeptId;
/**
* 部门名称

View File

@ -33,9 +33,9 @@ public class UserDTO extends SysUser {
/**
* 角色ID
*/
private List<Integer> role;
private List<Long> role;
private Integer deptId;
private Long deptId;
/**
* 新密码

View File

@ -46,7 +46,7 @@ public class UserInfo implements Serializable {
/**
* 角色集合
*/
private Integer[] roles;
private Long[] roles;
/**
* 角色集合

View File

@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -34,15 +35,16 @@ import javax.validation.constraints.NotBlank;
* @author lengleng
* @since 2019/2/1
*/
@ApiModel(value = "部门")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysDept extends BaseEntity {
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;
/**
* 部门名称
@ -61,7 +63,7 @@ public class SysDept extends BaseEntity {
* 父级部门id
*/
@ApiModelProperty(value = "父级部门id")
private Integer parentId;
private Long parentId;
/**
* 是否删除 -1已删除 0正常

View File

@ -17,6 +17,7 @@
package com.pig4cloud.pig.admin.api.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -29,6 +30,7 @@ import lombok.EqualsAndHashCode;
* @author lengleng
* @since 2019/2/1
*/
@ApiModel(value = "部门关系")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysDeptRelation extends Model<SysDeptRelation> {
@ -39,12 +41,12 @@ public class SysDeptRelation extends Model<SysDeptRelation> {
* 祖先节点
*/
@ApiModelProperty(value = "祖先节点")
private Integer ancestor;
private Long ancestor;
/**
* 后代节点
*/
@ApiModelProperty(value = "后代节点")
private Integer descendant;
private Long descendant;
}

View File

@ -15,6 +15,7 @@
*/
package com.pig4cloud.pig.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;
@ -40,9 +41,9 @@ public class SysDict extends BaseEntity {
/**
* 编号
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "字典编号")
private Integer id;
private Long id;
/**
* 类型

View File

@ -15,6 +15,7 @@
*/
package com.pig4cloud.pig.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
@ -39,15 +40,15 @@ public class SysDictItem extends BaseEntity {
/**
* 编号
*/
@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;
/**
* 数据值

View File

@ -39,7 +39,7 @@ public class SysFile extends BaseEntity {
/**
* 编号
*/
@TableId(type = IdType.AUTO)
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**

View File

@ -47,7 +47,7 @@ public class SysLog extends BaseEntity {
/**
* 编号
*/
@TableId(value = "id", type = IdType.AUTO)
@TableId(value = "id", type = IdType.ASSIGN_ID)
@ExcelProperty("日志编号")
@ApiModelProperty(value = "日志编号")
@JsonSerialize(using = ToStringSerializer.class)

View File

@ -44,9 +44,9 @@ public class SysMenu extends BaseEntity {
/**
* 菜单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;
/**
* 菜单名称
@ -66,7 +66,7 @@ public class SysMenu extends BaseEntity {
*/
@NotNull(message = "菜单父ID不能为空")
@ApiModelProperty(value = "菜单父id")
private Integer parentId;
private Long parentId;
/**
* 图标

View File

@ -40,9 +40,9 @@ public class SysRole extends BaseEntity {
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 = "角色名称")

View File

@ -39,12 +39,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;
}

View File

@ -42,9 +42,9 @@ public class SysUser extends BaseEntity {
/**
* 主键ID
*/
@TableId(value = "user_id", type = IdType.AUTO)
@TableId(value = "user_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键id")
private Integer userId;
private Long userId;
/**
* 用户名
@ -87,7 +87,7 @@ public class SysUser extends BaseEntity {
* 部门ID
*/
@ApiModelProperty(value = "用户所属部门id")
private Integer deptId;
private Long deptId;
/**
* 0-正常1-删除

View File

@ -39,12 +39,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;
}

View File

@ -37,7 +37,7 @@ public interface RemoteDeptService {
* @return 返回子级id列表
*/
@GetMapping("/dept/child-id/{deptId}")
R<List<Integer>> listChildDeptId(@PathVariable("deptId") Integer deptId,
R<List<Long>> listChildDeptId(@PathVariable("deptId") Long deptId,
@RequestHeader(SecurityConstants.FROM) String from);
}

View File

@ -61,7 +61,7 @@ public interface RemoteUserService {
* @return 用户 id 集合
*/
@GetMapping("/user/ids")
R<List<Integer>> listUserIdByDeptIds(@RequestParam("deptIds") Set<Integer> deptIds,
R<List<Long>> listUserIdByDeptIds(@RequestParam("deptIds") Set<Long> deptIds,
@RequestHeader(SecurityConstants.FROM) String from);
}

View File

@ -30,7 +30,7 @@ public class RoleVo {
/**
* 角色id
*/
private Integer roleId;
private Long roleId;
/**
* 菜单列表

View File

@ -24,7 +24,7 @@ public class UserExcelVO implements Serializable {
* 主键ID
*/
@ExcelProperty("用户编号")
private Integer userId;
private Long userId;
/**
* 用户名

View File

@ -44,6 +44,6 @@ public class UserInfoVO implements Serializable {
/**
* 角色集合
*/
private Integer[] roles;
private Long[] roles;
}

View File

@ -35,7 +35,7 @@ public class UserVO implements Serializable {
/**
* 主键ID
*/
private Integer userId;
private Long userId;
/**
* 用户名
@ -85,7 +85,7 @@ public class UserVO implements Serializable {
/**
* 部门ID
*/
private Integer deptId;
private Long deptId;
/**
* 部门名称

View File

@ -51,8 +51,8 @@ public class DeptController {
* @param id ID
* @return SysDept
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
@GetMapping("/{id:\\d+}")
public R getById(@PathVariable Long id) {
return R.ok(sysDeptService.getById(id));
}
@ -94,7 +94,7 @@ public class DeptController {
@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));
}
@ -107,7 +107,6 @@ public class DeptController {
@PutMapping
@PreAuthorize("@pms.hasPermission('sys_dept_edit')")
public R update(@Valid @RequestBody SysDept sysDept) {
sysDept.setUpdateTime(LocalDateTime.now());
return R.ok(sysDeptService.updateDeptById(sysDept));
}
@ -129,7 +128,7 @@ public class DeptController {
*/
@Inner
@GetMapping(value = "/child-id/{deptId}")
public R<List<Integer>> listChildDeptId(@PathVariable Integer deptId) {
public R<List<Long>> listChildDeptId(@PathVariable Long deptId) {
return R.ok(sysDeptService.listChildDeptId(deptId));
}

View File

@ -59,7 +59,7 @@ public class DictController {
* @return 字典信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysDictService.getById(id));
}
@ -104,7 +104,7 @@ public class DictController {
@SysLog("删除字典")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
sysDictService.removeDict(id);
return R.ok();
}
@ -139,7 +139,7 @@ public class DictController {
* @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 DictController {
*/
@SysLog("删除字典项")
@DeleteMapping("/item/{id}")
public R removeDictItemById(@PathVariable Integer id) {
public R removeDictItemById(@PathVariable Long id) {
sysDictItemService.removeDictItem(id);
return R.ok();
}

View File

@ -49,7 +49,7 @@ public class MenuController {
* @return 当前用户的树形菜单
*/
@GetMapping
public R getUserMenu(Integer parentId) {
public R getUserMenu(Long parentId) {
// 获取符合条件的菜单
Set<SysMenu> menuSet = SecurityUtils.getRoles().stream().map(sysMenuService::findMenuByRoleId)
.flatMap(Collection::stream).collect(Collectors.toSet());
@ -63,7 +63,7 @@ public class MenuController {
* @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));
}
@ -73,7 +73,7 @@ public class MenuController {
* @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()));
}
@ -83,8 +83,8 @@ public class MenuController {
* @param id 菜单ID
* @return 菜单详细信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
@GetMapping("/{id:\\d+}")
public R getById(@PathVariable Long id) {
return R.ok(sysMenuService.getById(id));
}
@ -107,9 +107,9 @@ public class MenuController {
* @return success/false
*/
@SysLog("删除菜单")
@DeleteMapping("/{id}")
@DeleteMapping("/{id:\\d+}")
@PreAuthorize("@pms.hasPermission('sys_menu_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysMenuService.removeMenuById(id));
}

View File

@ -51,7 +51,7 @@ public class RoleController {
* @return 角色信息
*/
@GetMapping("/{id}")
public R getById(@PathVariable Integer id) {
public R getById(@PathVariable Long id) {
return R.ok(sysRoleService.getById(id));
}
@ -87,7 +87,7 @@ public class RoleController {
@SysLog("删除角色")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_role_del')")
public R removeById(@PathVariable Integer id) {
public R removeById(@PathVariable Long id) {
return R.ok(sysRoleService.removeRoleById(id));
}

View File

@ -93,7 +93,7 @@ public class UserController {
*/
@Inner
@GetMapping("/ids")
public R<List<Integer>> listUserIdByDeptIds(@RequestParam("deptIds") Set<Integer> deptIds) {
public R<List<Long>> listUserIdByDeptIds(@RequestParam("deptIds") Set<Long> deptIds) {
return R.ok(userService.listUserIdByDeptIds(deptIds));
}
@ -103,7 +103,7 @@ public class UserController {
* @return 用户信息
*/
@GetMapping("/{id}")
public R user(@PathVariable Integer id) {
public R user(@PathVariable Long id) {
return R.ok(userService.getUserVoById(id));
}
@ -127,7 +127,7 @@ public class UserController {
@SysLog("删除用户信息")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_user_del')")
public R userDel(@PathVariable Integer id) {
public R userDel(@PathVariable Long id) {
SysUser sysUser = userService.getById(id);
return R.ok(userService.removeUserById(sysUser));
}

View File

@ -41,7 +41,7 @@ public interface SysDeptRelationMapper extends BaseMapper<SysDeptRelation> {
* 删除部门节点关系,同时删除所有关联此部门子节点的部门关系
* @param id 待删除的部门节点ID
*/
void deleteDeptRelationsById(Integer id);
void deleteDeptRelationsById(Long id);
/**
* 新增部门节点关系

View File

@ -38,6 +38,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
* @param roleId 角色ID
* @return
*/
Set<SysMenu> listMenusByRoleId(Integer roleIds);
Set<SysMenu> listMenusByRoleId(Long roleIds);
}

View File

@ -38,6 +38,6 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
* @param userId
* @return
*/
List<SysRole> listRolesByUserId(Integer userId);
List<SysRole> listRolesByUserId(Long userId);
}

View File

@ -58,7 +58,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param id 用户ID
* @return userVo
*/
UserVO getUserVoById(Integer id);
UserVO getUserVoById(Long id);
/**
* 查询用户列表

View File

@ -39,6 +39,6 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
* @author 寻欢·
* @date 2017年12月7日 16:31:38
*/
Boolean deleteByUserId(@Param("userId") Integer userId);
Boolean deleteByUserId(@Param("userId") Long userId);
}

View File

@ -40,7 +40,7 @@ public interface SysDeptRelationService extends IService<SysDeptRelation> {
* 通过ID删除部门关系
* @param id
*/
void removeDeptRelationById(Integer id);
void removeDeptRelationById(Long id);
/**
* 更新部门关系

View File

@ -36,13 +36,13 @@ public interface SysDeptService extends IService<SysDept> {
* 查询部门树菜单
* @return
*/
List<Tree<Integer>> listDeptTrees();
List<Tree<Long>> listDeptTrees();
/**
* 查询用户部门树
* @return
*/
List<Tree<Integer>> listCurrentUserDeptTrees();
List<Tree<Long>> listCurrentUserDeptTrees();
/**
* 添加信息部门
@ -56,7 +56,7 @@ public interface SysDeptService extends IService<SysDept> {
* @param id 部门 ID
* @return 成功失败
*/
Boolean removeDeptById(Integer id);
Boolean removeDeptById(Long id);
/**
* 更新部门
@ -68,8 +68,8 @@ public interface SysDeptService extends IService<SysDept> {
/**
* 查找指定部门的子部门id列表
* @param deptId 部门id
* @return List<Integer>
* @return List<Long>
*/
List<Integer> listChildDeptId(Integer deptId);
List<Long> listChildDeptId(Long deptId);
}

View File

@ -31,7 +31,7 @@ public interface SysDictItemService extends IService<SysDictItem> {
* @param id 字典项ID
* @return
*/
void removeDictItem(Integer id);
void removeDictItem(Long id);
/**
* 更新字典项

View File

@ -31,7 +31,7 @@ public interface SysDictService extends IService<SysDict> {
* @param id
* @return
*/
void removeDict(Integer id);
void removeDict(Long id);
/**
* 更新字典

View File

@ -38,14 +38,14 @@ public interface SysMenuService extends IService<SysMenu> {
* @param roleId 角色ID
* @return 菜单列表
*/
Set<SysMenu> findMenuByRoleId(Integer roleId);
Set<SysMenu> findMenuByRoleId(Long roleId);
/**
* 级联删除菜单
* @param id 菜单ID
* @return true成功, false失败
*/
Boolean removeMenuById(Integer id);
Boolean removeMenuById(Long id);
/**
* 更新菜单信息
@ -60,7 +60,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);
/**
* 查询菜单
@ -68,6 +68,6 @@ public interface SysMenuService extends IService<SysMenu> {
* @param parentId
* @return
*/
List<Tree<Integer>> filterMenu(Set<SysMenu> menuSet, Integer parentId);
List<Tree<Long>> filterMenu(Set<SysMenu> menuSet, Long parentId);
}

View File

@ -36,6 +36,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);
}

View File

@ -34,6 +34,6 @@ public interface SysRoleService extends IService<SysRole> {
* @param id
* @return
*/
Boolean removeRoleById(Integer id);
Boolean removeRoleById(Long id);
}

View File

@ -77,7 +77,7 @@ public interface SysUserService extends IService<SysUser> {
* @param id 用户ID
* @return 用户信息
*/
UserVO getUserVoById(Integer id);
UserVO getUserVoById(Long id);
/**
* 查询上级部门的用户信息
@ -113,6 +113,6 @@ public interface SysUserService extends IService<SysUser> {
* @param deptIds 部门 id 列表
* @return userIdList
*/
List<Integer> listUserIdByDeptIds(Set<Integer> deptIds);
List<Long> listUserIdByDeptIds(Set<Long> deptIds);
}

View File

@ -75,7 +75,7 @@ public class SysDeptRelationServiceImpl extends ServiceImpl<SysDeptRelationMappe
* @param id
*/
@Override
public void removeDeptRelationById(Integer id) {
public void removeDeptRelationById(Long id) {
baseMapper.deleteDeptRelationsById(id);
}

View File

@ -72,9 +72,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());
@ -106,7 +106,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
}
@Override
public List<Integer> listChildDeptId(Integer deptId) {
public List<Long> listChildDeptId(Long deptId) {
List<SysDeptRelation> deptRelations = sysDeptRelationService.list(Wrappers.<SysDeptRelation>lambdaQuery()
.eq(SysDeptRelation::getAncestor, deptId).ne(SysDeptRelation::getDescendant, deptId));
if (CollUtil.isNotEmpty(deptRelations)) {
@ -120,7 +120,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @return
*/
@Override
public List<Tree<Integer>> listDeptTrees() {
public List<Tree<Long>> listDeptTrees() {
return getDeptTree(this.list(Wrappers.emptyWrapper()));
}
@ -129,9 +129,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @return
*/
@Override
public List<Tree<Integer>> listCurrentUserDeptTrees() {
Integer deptId = SecurityUtils.getUser().getDeptId();
List<Integer> descendantIdList = sysDeptRelationService
public List<Tree<Long>> listCurrentUserDeptTrees() {
Long deptId = SecurityUtils.getUser().getDeptId();
List<Long> descendantIdList = sysDeptRelationService
.list(Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getAncestor, deptId)).stream()
.map(SysDeptRelation::getDescendant).collect(Collectors.toList());
@ -144,11 +144,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
* @param depts 部门
* @return
*/
private List<Tree<Integer>> getDeptTree(List<SysDept> depts) {
List<TreeNode<Integer>> collect = depts.stream()
.filter(dept -> dept.getDeptId().intValue() != dept.getParentId())
private List<Tree<Long>> getDeptTree(List<SysDept> depts) {
List<TreeNode<Long>> collect = depts.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());
@ -160,7 +159,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
return treeNode;
}).collect(Collectors.toList());
return TreeUtil.build(collect, 0);
return TreeUtil.build(collect, 0L);
}
}

View File

@ -47,7 +47,7 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
*/
@Override
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public void removeDictItem(Integer id) {
public void removeDictItem(Long id) {
// 根据ID查询字典ID
SysDictItem dictItem = this.getById(id);
SysDict dict = dictService.getById(dictItem.getDictId());

View File

@ -50,7 +50,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
public void removeDict(Integer id) {
public void removeDict(Long id) {
SysDict dict = this.getById(id);
// 系统内置
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystem()), "系统内置字典项目不能删除");

View File

@ -62,7 +62,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")
public Set<SysMenu> findMenuByRoleId(Integer roleId) {
public Set<SysMenu> findMenuByRoleId(Long roleId) {
return baseMapper.listMenusByRoleId(roleId);
}
@ -74,7 +74,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
public Boolean removeMenuById(Integer id) {
public Boolean removeMenuById(Long id) {
// 查询父节点为当前节点的节点
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query().lambda().eq(SysMenu::getParentId, id));
@ -98,18 +98,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,18 +124,18 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
* @return
*/
@Override
public List<Tree<Integer>> filterMenu(Set<SysMenu> all, Integer parentId) {
List<TreeNode<Integer>> collect = all.stream()
public List<Tree<Long>> filterMenu(Set<SysMenu> all, Long parentId) {
List<TreeNode<Long>> collect = all.stream()
.filter(menu -> MenuTypeEnum.LEFT_MENU.getType().equals(menu.getType()))
.filter(menu -> StrUtil.isNotBlank(menu.getPath())).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());

View File

@ -55,7 +55,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
*/
@Override
@Transactional(rollbackFor = Exception.class)
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)) {
@ -64,7 +64,7 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRo
List<SysRoleMenu> roleMenuList = Arrays.stream(menuIds.split(StrUtil.COMMA)).map(menuId -> {
SysRoleMenu roleMenu = new SysRoleMenu();
roleMenu.setRoleId(roleId);
roleMenu.setMenuId(Integer.valueOf(menuId));
roleMenu.setMenuId(Long.valueOf(menuId));
return roleMenu;
}).collect(Collectors.toList());

View File

@ -51,7 +51,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
public Boolean removeRoleById(Integer id) {
public Boolean removeRoleById(Long id) {
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>update().lambda().eq(SysRoleMenu::getRoleId, id));
return this.removeById(id);
}

View File

@ -108,8 +108,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
List<SysRole> roleList = sysRoleMapper.listRolesByUserId(sysUser.getUserId());
userInfo.setRoleList(roleList);
// 设置角色列表 ID
List<Integer> roleIds = roleList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Integer.class));
List<Long> roleIds = roleList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
userInfo.setRoles(ArrayUtil.toArray(roleIds, Long.class));
// 设置权限列表menu.permission
Set<String> permissions = roleIds.stream().map(sysMenuService::findMenuByRoleId).flatMap(Collection::stream)
.filter(m -> MenuTypeEnum.BUTTON.getType().equals(m.getType())).map(SysMenu::getPermission)
@ -136,7 +136,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return 用户信息
*/
@Override
public UserVO getUserVoById(Integer id) {
public UserVO getUserVoById(Long id) {
return baseMapper.getUserVoById(id);
}
@ -208,7 +208,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));
}
@ -295,10 +295,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
@Override
public List<Integer> listUserIdByDeptIds(Set<Integer> deptIds) {
public List<Long> listUserIdByDeptIds(Set<Long> deptIds) {
return this.listObjs(
Wrappers.lambdaQuery(SysUser.class).select(SysUser::getUserId).in(SysUser::getDeptId, deptIds),
Integer.class::cast);
Long.class::cast);
}
/**
@ -313,7 +313,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);

View File

@ -17,7 +17,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pig.admin.mapper.SysRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.pig4cloud.pig.admin.api.entity.SysRole">
<id column="role_id" property="roleId"/>
@ -27,13 +26,27 @@
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="del_flag" property="delFlag"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="create_by" property="createBy"/>
<result column="update_by" property="updateBy"/>
</resultMap>
<!-- 通过用户ID查询角色信息-->
<select id="listRolesByUserId" resultMap="BaseResultMap">
SELECT
r.*
FROM
sys_role r, sys_user_role ur WHERE r.role_id = ur.role_id AND r.del_flag = 0 and ur.user_id IN (#{userId})
</select>
SELECT r.role_id,
r.role_name,
r.role_code,
r.role_desc,
r.del_flag,
r.create_time,
r.update_time,
r.update_by,
r.create_by
FROM sys_role r,
sys_user_role ur
WHERE r.role_id = ur.role_id
AND r.del_flag = 0
and ur.user_id = #{userId}
</select>
</mapper>

View File

@ -15,6 +15,7 @@
*/
package com.pig4cloud.pig.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;
@ -36,8 +37,8 @@ public class GenDatasourceConf extends BaseEntity {
/**
* 主键
*/
@TableId
private Integer id;
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 名称

View File

@ -16,6 +16,7 @@
package com.pig4cloud.pig.codegen.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
@ -39,9 +40,9 @@ public class GenFormConf extends BaseEntity {
/**
* ID
*/
@TableId
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID")
private Integer id;
private Long id;
/**
* 表名称

View File

@ -17,6 +17,7 @@
#set($excludeColumns = ["create_time","update_time","create_by","update_by"])
package ${package}.${moduleName}.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
@ -47,7 +48,7 @@ public class ${className} extends BaseEntity {
* $column.comments
*/
#if($column.columnName == $pk.columnName)
@TableId
@TableId(type = IdType.ASSIGN_ID)
#end
@ApiModelProperty(value="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
private $column.attrType $column.lowerAttrName;