Compare commits
3 Commits
master
...
4ea369b33d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ea369b33d | ||
|
|
e7f90b8d97 | ||
|
|
816dfb2304 |
@@ -12,6 +12,7 @@ public enum Code01UserErrorCode implements BaseErrorCode {
|
|||||||
USER_EXISTS("A1000102", "用户已存在"),
|
USER_EXISTS("A1000102", "用户已存在"),
|
||||||
USER_LOGIN_ERROR("A1000103", "用户登录失败!"),
|
USER_LOGIN_ERROR("A1000103", "用户登录失败!"),
|
||||||
USER_REGISTER_ERROR("1000104", "用户注册失败!"),
|
USER_REGISTER_ERROR("1000104", "用户注册失败!"),
|
||||||
|
REFRESH_TOKEN_NOT_EXISTS("1000105", "refreshToken不匹配")
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IdsRequest {
|
||||||
|
|
||||||
|
private List<Long> ids;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 13:46
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RefreshRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refresh Token
|
||||||
|
*/
|
||||||
|
private String refreshToken;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.req.user;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserUpdateStatusRequest {
|
||||||
|
@NotNull(message = "id不能为空")
|
||||||
|
private Long id;
|
||||||
|
@NotNull(message = "状态不能为空")
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -29,4 +31,6 @@ public class DeptDTO {
|
|||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
private Integer sortNo;
|
private Integer sortNo;
|
||||||
|
|
||||||
|
private List<DeptDTO> children;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ public class LoginResp {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
|
private String refreshToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MenuVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单ID
|
||||||
|
*/
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单名称
|
||||||
|
*/
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父菜单名称
|
||||||
|
*/
|
||||||
|
private String parentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父菜单ID
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示顺序
|
||||||
|
*/
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由地址
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件路径
|
||||||
|
*/
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由参数
|
||||||
|
*/
|
||||||
|
private String query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由名称,默认和路由地址相同的驼峰格式(注意:因为vue3版本的router会删除名称相同路由,为避免名字的冲突,特殊情况可以自定义)
|
||||||
|
*/
|
||||||
|
private String routeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为外链(0是 1否)
|
||||||
|
*/
|
||||||
|
private String isFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否缓存(0缓存 1不缓存)
|
||||||
|
*/
|
||||||
|
private String isCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(M目录 C菜单 F按钮)
|
||||||
|
*/
|
||||||
|
private String menuType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示状态(0显示 1隐藏)
|
||||||
|
*/
|
||||||
|
private String visible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限字符串
|
||||||
|
*/
|
||||||
|
private String perms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单图标
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子菜单
|
||||||
|
*/
|
||||||
|
private List<MenuVO> children = new ArrayList<MenuVO>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.resp;
|
||||||
|
|
||||||
|
|
||||||
|
import com.xiang.xservice.basic.utils.MyStringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由显示信息
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class MetaVo {
|
||||||
|
/**
|
||||||
|
* 设置该路由在侧边栏和面包屑中展示的名字
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置该路由的图标,对应路径src/assets/icons/svg
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置为true,则不会被 <keep-alive>缓存
|
||||||
|
*/
|
||||||
|
private boolean noCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内链地址(http(s)://开头)
|
||||||
|
*/
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
public MetaVo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon) {
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, boolean noCache) {
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, String link) {
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, boolean noCache, String link) {
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.noCache = noCache;
|
||||||
|
if (MyStringUtils.isHttp(link)) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoCache() {
|
||||||
|
return noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoCache(boolean noCache) {
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.resp;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由配置信息
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
public class RouterVo {
|
||||||
|
/**
|
||||||
|
* 路由名字
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由地址
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
|
||||||
|
*/
|
||||||
|
private boolean hidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||||
|
*/
|
||||||
|
private String redirect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件地址
|
||||||
|
*/
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路由参数:如 {"id": 1, "name": "ry"}
|
||||||
|
*/
|
||||||
|
private String query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
||||||
|
*/
|
||||||
|
private Boolean alwaysShow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他元素
|
||||||
|
*/
|
||||||
|
private MetaVo meta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子路由
|
||||||
|
*/
|
||||||
|
private List<RouterVo> children;
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.xiang.xservice.auth.api.dto.resp;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Treeselect树结构实体类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class TreeSelect implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点禁用
|
||||||
|
*/
|
||||||
|
private boolean disabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子节点
|
||||||
|
*/
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
private List<TreeSelect> children;
|
||||||
|
|
||||||
|
public TreeSelect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeSelect(DeptDTO dept) {
|
||||||
|
this.id = dept.getId();
|
||||||
|
this.label = dept.getName();
|
||||||
|
this.disabled = true;
|
||||||
|
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public TreeSelect(MenuVO menu) {
|
||||||
|
this.id = menu.getMenuId();
|
||||||
|
this.label = menu.getMenuName();
|
||||||
|
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisabled() {
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabled(boolean disabled) {
|
||||||
|
this.disabled = disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TreeSelect> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildren(List<TreeSelect> children) {
|
||||||
|
this.children = children;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -15,4 +16,5 @@ public class UserDTO {
|
|||||||
private UserResp user;
|
private UserResp user;
|
||||||
private DeptDTO dept;
|
private DeptDTO dept;
|
||||||
private List<PermissionDTO> permissionRoles;
|
private List<PermissionDTO> permissionRoles;
|
||||||
|
private Set<String> permissions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import java.time.LocalDateTime;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UserResp {
|
public class UserResp {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名(昵称)
|
* 用户名(昵称)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.xiang.xservice.auth.server.controller;
|
||||||
|
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.RouterVo;
|
||||||
|
import com.xiang.xservice.auth.service.service.XMenuService;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:19
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MenuController {
|
||||||
|
|
||||||
|
private final XMenuService menuService;
|
||||||
|
|
||||||
|
@GetMapping("/private/menu/getRouter")
|
||||||
|
public Result<List<RouterVo>> getRouter(@RequestParam("userId") Long userId) {
|
||||||
|
return Result.data(menuService.getRouter(userId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package com.xiang.xservice.auth.server.controller;
|
|||||||
|
|
||||||
import com.xiang.xservice.auth.api.api.TokenApi;
|
import com.xiang.xservice.auth.api.api.TokenApi;
|
||||||
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
||||||
|
import com.xiang.xservice.auth.api.dto.req.RefreshRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
||||||
|
import com.xiang.xservice.auth.api.dto.req.user.UserQueryRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.resp.LoginResp;
|
import com.xiang.xservice.auth.api.dto.resp.LoginResp;
|
||||||
import com.xiang.xservice.auth.api.dto.resp.RegisterResp;
|
import com.xiang.xservice.auth.api.dto.resp.RegisterResp;
|
||||||
import com.xiang.xservice.auth.api.dto.resp.UserDTO;
|
import com.xiang.xservice.auth.api.dto.resp.UserDTO;
|
||||||
@@ -11,7 +13,6 @@ import com.xiang.xservice.basic.common.resp.Result;
|
|||||||
import com.xiang.xservice.basic.exception.BusinessException;
|
import com.xiang.xservice.basic.exception.BusinessException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -41,6 +42,20 @@ public class TokenController implements TokenApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/publish/auth/refresh")
|
||||||
|
public Result<LoginResp> refresh(@RequestBody @NotNull(message = "请求参数不能为空") @Valid RefreshRequest request) {
|
||||||
|
try {
|
||||||
|
LoginResp login = userService.refresh(request);
|
||||||
|
return Result.data(login);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
log.error("【用户登录】用户登录失败,{}", e.getMessage(), e);
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【用户登录】用户登录失败,{}", e.getMessage(), e);
|
||||||
|
return Result.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/public/user/userRegister")
|
@PostMapping("/public/user/userRegister")
|
||||||
public Result<RegisterResp> register(@RequestBody @Valid @NotNull(message = "请求参数不能为空") RegisterRequest request) {
|
public Result<RegisterResp> register(@RequestBody @Valid @NotNull(message = "请求参数不能为空") RegisterRequest request) {
|
||||||
|
|
||||||
@@ -58,9 +73,8 @@ public class TokenController implements TokenApi {
|
|||||||
return Result.error("操作失败");
|
return Result.error("操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/private/auth/getInfo")
|
@PostMapping("/private/auth/getInfo")
|
||||||
public Result<UserDTO> getUserInfo() {
|
public Result<UserDTO> getUserInfo(@RequestBody @Valid @NotNull(message = "请求参数不能为空") UserQueryRequest request) {
|
||||||
// todo token的工具类,直接获取token中的userId无需传参
|
return Result.data(userService.getUserDetail(request.getUsername()));
|
||||||
return Result.data(userService.getUserDetail(1L));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.xiang.xservice.auth.api.dto.req.user.UserDeptUpdateRequest;
|
|||||||
import com.xiang.xservice.auth.api.dto.req.user.UserQueryRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserQueryRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserRoleUpdateRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserRoleUpdateRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserUpdateRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserUpdateRequest;
|
||||||
|
import com.xiang.xservice.auth.api.dto.req.user.UserUpdateStatusRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.resp.UserResp;
|
import com.xiang.xservice.auth.api.dto.resp.UserResp;
|
||||||
import com.xiang.xservice.auth.service.service.XUserService;
|
import com.xiang.xservice.auth.service.service.XUserService;
|
||||||
import com.xiang.xservice.basic.common.resp.Result;
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
@@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@@ -54,6 +54,10 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
return Result.error();
|
return Result.error();
|
||||||
}
|
}
|
||||||
|
@PostMapping("/private/user/updateStatus")
|
||||||
|
public Result<Boolean> updateStatus(@RequestBody @Valid @NotNull(message = "请求参数不能为空") UserUpdateStatusRequest request) {
|
||||||
|
return Result.data(userService.updateStatus(request.getId(), request.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/private/user/update")
|
@PostMapping("/private/user/update")
|
||||||
public Result<Boolean> updateUser(@RequestBody @Valid @NotNull(message = "请求参数不能为空") UserUpdateRequest request) {
|
public Result<Boolean> updateUser(@RequestBody @Valid @NotNull(message = "请求参数不能为空") UserUpdateRequest request) {
|
||||||
@@ -69,7 +73,7 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/private/user/del")
|
@PostMapping("/private/user/del")
|
||||||
public Result<Boolean> delUser(@RequestParam @Valid @NotEmpty(message = "请求参数不能为空") List<Long> ids) {
|
public Result<Boolean> delUser(@RequestBody @Valid @NotEmpty(message = "请求参数不能为空") List<Long> ids) {
|
||||||
try {
|
try {
|
||||||
return Result.data(userService.delUser(ids));
|
return Result.data(userService.delUser(ids));
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package com.xiang.xservice.auth.service.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户常量信息
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class UserConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台内系统用户的唯一标志
|
||||||
|
*/
|
||||||
|
public static final String SYS_USER = "SYS_USER";
|
||||||
|
|
||||||
|
/** 正常状态 */
|
||||||
|
public static final String NORMAL = "0";
|
||||||
|
|
||||||
|
/** 异常状态 */
|
||||||
|
public static final String EXCEPTION = "1";
|
||||||
|
|
||||||
|
/** 用户封禁状态 */
|
||||||
|
public static final String USER_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 角色正常状态 */
|
||||||
|
public static final String ROLE_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 角色封禁状态 */
|
||||||
|
public static final String ROLE_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 部门正常状态 */
|
||||||
|
public static final String DEPT_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 部门停用状态 */
|
||||||
|
public static final String DEPT_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 字典正常状态 */
|
||||||
|
public static final String DICT_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 是否为系统默认(是) */
|
||||||
|
public static final String YES = "Y";
|
||||||
|
|
||||||
|
/** 是否菜单外链(是) */
|
||||||
|
public static final String YES_FRAME = "0";
|
||||||
|
|
||||||
|
/** 是否菜单外链(否) */
|
||||||
|
public static final String NO_FRAME = "1";
|
||||||
|
|
||||||
|
/** 菜单类型(目录) */
|
||||||
|
public static final String TYPE_DIR = "M";
|
||||||
|
|
||||||
|
/** 菜单类型(菜单) */
|
||||||
|
public static final String TYPE_MENU = "C";
|
||||||
|
|
||||||
|
/** 菜单类型(按钮) */
|
||||||
|
public static final String TYPE_BUTTON = "F";
|
||||||
|
|
||||||
|
/** Layout组件标识 */
|
||||||
|
public final static String LAYOUT = "Layout";
|
||||||
|
|
||||||
|
/** ParentView组件标识 */
|
||||||
|
public final static String PARENT_VIEW = "ParentView";
|
||||||
|
|
||||||
|
/** InnerLink组件标识 */
|
||||||
|
public final static String INNER_LINK = "InnerLink";
|
||||||
|
|
||||||
|
/** 校验是否唯一的返回标识 */
|
||||||
|
public final static boolean UNIQUE = true;
|
||||||
|
public final static boolean NOT_UNIQUE = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名长度限制
|
||||||
|
*/
|
||||||
|
public static final int USERNAME_MIN_LENGTH = 2;
|
||||||
|
|
||||||
|
public static final int USERNAME_MAX_LENGTH = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码长度限制
|
||||||
|
*/
|
||||||
|
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||||
|
|
||||||
|
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||||
|
|
||||||
|
public static boolean isAdmin(Long userId)
|
||||||
|
{
|
||||||
|
return userId != null && 1L == userId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.xservice.auth.service.convert;
|
||||||
|
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.MenuVO;
|
||||||
|
import com.xiang.xservice.auth.service.entity.XMenuDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:39
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface XMenuConverter {
|
||||||
|
|
||||||
|
|
||||||
|
List<MenuVO> toVoList(List<XMenuDO> xMenuDOS);
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.xiang.xservice.auth.service.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("x_menu")
|
||||||
|
public class XMenuDO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 菜单ID */
|
||||||
|
private Long menuId;
|
||||||
|
|
||||||
|
/** 菜单名称 */
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
/** 父菜单ID */
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/** 显示顺序 */
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
/** 路由地址 */
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/** 组件路径 */
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/** 路由参数 */
|
||||||
|
private String query;
|
||||||
|
|
||||||
|
/** 路由名称,默认和路由地址相同的驼峰格式(注意:因为vue3版本的router会删除名称相同路由,为避免名字的冲突,特殊情况可以自定义) */
|
||||||
|
private String routeName;
|
||||||
|
|
||||||
|
/** 是否为外链(0是 1否) */
|
||||||
|
private Integer isFrame;
|
||||||
|
|
||||||
|
/** 是否缓存(0缓存 1不缓存) */
|
||||||
|
private Integer isCache;
|
||||||
|
|
||||||
|
/** 类型(M目录 C菜单 F按钮) */
|
||||||
|
private String menuType;
|
||||||
|
|
||||||
|
/** 显示状态(0显示 1隐藏) */
|
||||||
|
private String visible;
|
||||||
|
|
||||||
|
/** 菜单状态(0正常 1停用) */
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 权限字符串 */
|
||||||
|
private String perms;
|
||||||
|
|
||||||
|
/** 菜单图标 */
|
||||||
|
private String icon;
|
||||||
|
private String createBy;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private String updateBy;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -104,4 +104,9 @@ public class XUser implements Serializable {
|
|||||||
* 刷新token
|
* 刷新token
|
||||||
*/
|
*/
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
|
/**
|
||||||
|
* 1:后台用户、2:中台用户、3:前台用户
|
||||||
|
*/
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.xservice.auth.service.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiang.xservice.auth.service.entity.XMenuDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:31
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface XMenuMapper extends BaseMapper<XMenuDO> {
|
||||||
|
List<XMenuDO> selectMenuTreeByUserId(Long userId);
|
||||||
|
}
|
||||||
@@ -21,13 +21,6 @@ public interface XUserMapper extends BaseMapper<XUser> {
|
|||||||
*/
|
*/
|
||||||
XUser selectByUsername(String username);
|
XUser selectByUsername(String username);
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增用户
|
|
||||||
* @param user 用户
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int insert(XUser user);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入
|
* 批量插入
|
||||||
* @param list
|
* @param list
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiang.xservice.auth.service.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.RouterVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:30
|
||||||
|
*/
|
||||||
|
public interface XMenuService {
|
||||||
|
|
||||||
|
List<RouterVo> getRouter(Long userId);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.xiang.xservice.auth.service.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
||||||
|
import com.xiang.xservice.auth.api.dto.req.RefreshRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserAddRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserAddRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserDeptUpdateRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserDeptUpdateRequest;
|
||||||
@@ -37,5 +38,9 @@ public interface XUserService {
|
|||||||
|
|
||||||
Boolean setUserRole(UserRoleUpdateRequest request);
|
Boolean setUserRole(UserRoleUpdateRequest request);
|
||||||
|
|
||||||
UserDTO getUserDetail(Long userId);
|
UserDTO getUserDetail(String username);
|
||||||
|
|
||||||
|
LoginResp refresh(RefreshRequest request);
|
||||||
|
|
||||||
|
Boolean updateStatus(Long id, Integer status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package com.xiang.xservice.auth.service.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.MenuVO;
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.MetaVo;
|
||||||
|
import com.xiang.xservice.auth.api.dto.resp.RouterVo;
|
||||||
|
import com.xiang.xservice.auth.service.constants.UserConstants;
|
||||||
|
import com.xiang.xservice.auth.service.convert.XMenuConverter;
|
||||||
|
import com.xiang.xservice.auth.service.entity.XMenuDO;
|
||||||
|
import com.xiang.xservice.auth.service.repository.mapper.XMenuMapper;
|
||||||
|
import com.xiang.xservice.auth.service.service.XMenuService;
|
||||||
|
import com.xiang.xservice.basic.constants.Constants;
|
||||||
|
import com.xiang.xservice.basic.utils.MyStringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-03-20 15:30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class XMenuServiceImpl implements XMenuService {
|
||||||
|
|
||||||
|
private final XMenuMapper menuMapper;
|
||||||
|
private final XMenuConverter menuConverter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RouterVo> getRouter(Long userId) {
|
||||||
|
List<XMenuDO> xMenuDOS = Lists.newArrayList();
|
||||||
|
// 超级管理员 admin
|
||||||
|
if (Objects.equals(userId, 1L)) {
|
||||||
|
LambdaQueryWrapper<XMenuDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(XMenuDO::getStatus, 0);
|
||||||
|
lambdaQueryWrapper.in(XMenuDO::getMenuType, 'M', 'C');
|
||||||
|
lambdaQueryWrapper.orderByAsc(XMenuDO::getParentId, XMenuDO::getOrderNum);
|
||||||
|
xMenuDOS = menuMapper.selectList(lambdaQueryWrapper);
|
||||||
|
} else {
|
||||||
|
xMenuDOS = menuMapper.selectMenuTreeByUserId(userId);
|
||||||
|
}
|
||||||
|
return buildMenus(getChildPerms(menuConverter.toVoList(xMenuDOS), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RouterVo> buildMenus(List<MenuVO> menus) {
|
||||||
|
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||||
|
for (MenuVO menu : menus) {
|
||||||
|
RouterVo router = new RouterVo();
|
||||||
|
router.setHidden("1".equals(menu.getVisible()));
|
||||||
|
router.setName(getRouteName(menu));
|
||||||
|
router.setPath(getRouterPath(menu));
|
||||||
|
router.setComponent(getComponent(menu));
|
||||||
|
router.setQuery(menu.getQuery());
|
||||||
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||||
|
List<MenuVO> cMenus = menu.getChildren();
|
||||||
|
if (CollectionUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||||
|
router.setAlwaysShow(true);
|
||||||
|
router.setRedirect("noRedirect");
|
||||||
|
router.setChildren(buildMenus(cMenus));
|
||||||
|
} else if (isMenuFrame(menu)) {
|
||||||
|
router.setMeta(null);
|
||||||
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
|
RouterVo children = new RouterVo();
|
||||||
|
children.setPath(menu.getPath());
|
||||||
|
children.setComponent(menu.getComponent());
|
||||||
|
children.setName(getRouteName(menu.getRouteName(), menu.getPath()));
|
||||||
|
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||||
|
children.setQuery(menu.getQuery());
|
||||||
|
childrenList.add(children);
|
||||||
|
router.setChildren(childrenList);
|
||||||
|
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
|
||||||
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||||
|
router.setPath("/");
|
||||||
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
|
RouterVo children = new RouterVo();
|
||||||
|
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||||
|
children.setPath(routerPath);
|
||||||
|
children.setComponent(UserConstants.INNER_LINK);
|
||||||
|
children.setName(getRouteName(menu.getRouteName(), routerPath));
|
||||||
|
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
||||||
|
childrenList.add(children);
|
||||||
|
router.setChildren(childrenList);
|
||||||
|
}
|
||||||
|
routers.add(router);
|
||||||
|
}
|
||||||
|
return routers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRouteName(MenuVO menu) {
|
||||||
|
// 非外链并且是一级目录(类型为目录)
|
||||||
|
if (isMenuFrame(menu)) {
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
return getRouteName(menu.getRouteName(), menu.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取路由名称,如没有配置路由名称则取路由地址
|
||||||
|
*
|
||||||
|
* @param name 路由名称
|
||||||
|
* @param path 路由地址
|
||||||
|
* @return 路由名称(驼峰格式)
|
||||||
|
*/
|
||||||
|
public String getRouteName(String name, String path) {
|
||||||
|
String routerName = StringUtils.isNotEmpty(name) ? name : path;
|
||||||
|
return StringUtils.capitalize(routerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取路由地址
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
* @return 路由地址
|
||||||
|
*/
|
||||||
|
public String getRouterPath(MenuVO menu) {
|
||||||
|
String routerPath = menu.getPath();
|
||||||
|
// 内链打开外网方式
|
||||||
|
if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||||
|
routerPath = innerLinkReplaceEach(routerPath);
|
||||||
|
}
|
||||||
|
// 非外链并且是一级目录(类型为目录)
|
||||||
|
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
||||||
|
&& UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
|
||||||
|
routerPath = "/" + menu.getPath();
|
||||||
|
}
|
||||||
|
// 非外链并且是一级目录(类型为菜单)
|
||||||
|
else if (isMenuFrame(menu)) {
|
||||||
|
routerPath = "/";
|
||||||
|
}
|
||||||
|
return routerPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取组件信息
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
* @return 组件信息
|
||||||
|
*/
|
||||||
|
public String getComponent(MenuVO menu) {
|
||||||
|
String component = UserConstants.LAYOUT;
|
||||||
|
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
|
||||||
|
component = menu.getComponent();
|
||||||
|
} else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
|
||||||
|
component = UserConstants.INNER_LINK;
|
||||||
|
} else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
|
||||||
|
component = UserConstants.PARENT_VIEW;
|
||||||
|
}
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为菜单内部跳转
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isMenuFrame(MenuVO menu) {
|
||||||
|
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||||
|
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为内链组件
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isInnerLink(MenuVO menu) {
|
||||||
|
return menu.getIsFrame().equals(UserConstants.NO_FRAME) && MyStringUtils.isHttp(menu.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为parent_view组件
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isParentView(MenuVO menu) {
|
||||||
|
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父节点的ID获取所有子节点
|
||||||
|
*
|
||||||
|
* @param list 分类表
|
||||||
|
* @param parentId 传入的父节点ID
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public List<MenuVO> getChildPerms(List<MenuVO> list, int parentId) {
|
||||||
|
List<MenuVO> returnList = new ArrayList<MenuVO>();
|
||||||
|
for (Iterator<MenuVO> iterator = list.iterator(); iterator.hasNext(); ) {
|
||||||
|
MenuVO t = (MenuVO) iterator.next();
|
||||||
|
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||||
|
if (t.getParentId() == parentId) {
|
||||||
|
recursionFn(list, t);
|
||||||
|
returnList.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归列表
|
||||||
|
*
|
||||||
|
* @param list 分类表
|
||||||
|
* @param t 子节点
|
||||||
|
*/
|
||||||
|
private void recursionFn(List<MenuVO> list, MenuVO t) {
|
||||||
|
// 得到子节点列表
|
||||||
|
List<MenuVO> childList = getChildList(list, t);
|
||||||
|
t.setChildren(childList);
|
||||||
|
for (MenuVO tChild : childList) {
|
||||||
|
if (hasChild(list, tChild)) {
|
||||||
|
recursionFn(list, tChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到子节点列表
|
||||||
|
*/
|
||||||
|
private List<MenuVO> getChildList(List<MenuVO> list, MenuVO t) {
|
||||||
|
List<MenuVO> tlist = new ArrayList<MenuVO>();
|
||||||
|
Iterator<MenuVO> it = list.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
MenuVO n = (MenuVO) it.next();
|
||||||
|
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
||||||
|
tlist.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否有子节点
|
||||||
|
*/
|
||||||
|
private boolean hasChild(List<MenuVO> list, MenuVO t) {
|
||||||
|
return getChildList(list, t).size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内链域名特殊字符替换
|
||||||
|
*
|
||||||
|
* @return 替换后的内链域名
|
||||||
|
*/
|
||||||
|
public String innerLinkReplaceEach(String path) {
|
||||||
|
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"},
|
||||||
|
new String[]{"", "", "", "/", "/"});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
import com.xiang.xservice.auth.api.code.Code01UserErrorCode;
|
import com.xiang.xservice.auth.api.code.Code01UserErrorCode;
|
||||||
import com.xiang.xservice.auth.api.code.Code02RoleErrorCode;
|
import com.xiang.xservice.auth.api.code.Code02RoleErrorCode;
|
||||||
import com.xiang.xservice.auth.api.code.Code03DeptErrorCode;
|
import com.xiang.xservice.auth.api.code.Code03DeptErrorCode;
|
||||||
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
import com.xiang.xservice.auth.api.dto.req.LoginRequest;
|
||||||
|
import com.xiang.xservice.auth.api.dto.req.RefreshRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
import com.xiang.xservice.auth.api.dto.req.RegisterRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserAddRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserAddRequest;
|
||||||
import com.xiang.xservice.auth.api.dto.req.user.UserDeptUpdateRequest;
|
import com.xiang.xservice.auth.api.dto.req.user.UserDeptUpdateRequest;
|
||||||
@@ -43,10 +45,13 @@ import com.xiang.xservice.auth.service.service.XUserService;
|
|||||||
import com.xiang.xservice.basic.enums.DelStatusEnum;
|
import com.xiang.xservice.basic.enums.DelStatusEnum;
|
||||||
import com.xiang.xservice.basic.exception.BusinessException;
|
import com.xiang.xservice.basic.exception.BusinessException;
|
||||||
import com.xiang.xservice.basic.utils.PrimaryKeyUtils;
|
import com.xiang.xservice.basic.utils.PrimaryKeyUtils;
|
||||||
|
import com.xiang.xservice.basic.utils.RandomCodeUtils;
|
||||||
|
import com.xiang.xservice.basic.utils.SnowflakeIdGenerator;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.dao.DuplicateKeyException;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@@ -123,6 +128,7 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
LoginResp loginResp = new LoginResp();
|
LoginResp loginResp = new LoginResp();
|
||||||
loginResp.setToken(user.getToken());
|
loginResp.setToken(user.getToken());
|
||||||
loginResp.setUsername(request.getUsername());
|
loginResp.setUsername(request.getUsername());
|
||||||
|
loginResp.setRefreshToken(user.getRefreshToken());
|
||||||
return loginResp;
|
return loginResp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,6 +165,7 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
LoginResp loginResp = new LoginResp();
|
LoginResp loginResp = new LoginResp();
|
||||||
loginResp.setToken(token);
|
loginResp.setToken(token);
|
||||||
loginResp.setUsername(request.getUsername());
|
loginResp.setUsername(request.getUsername());
|
||||||
|
loginResp.setRefreshToken(refreshToken);
|
||||||
// 3. redis缓存token
|
// 3. redis缓存token
|
||||||
redisService.set(RedisConstant.LOGIN_TOKEN + request.getUsername(), token, 3, TimeUnit.HOURS);
|
redisService.set(RedisConstant.LOGIN_TOKEN + request.getUsername(), token, 3, TimeUnit.HOURS);
|
||||||
// 4. db 存储token
|
// 4. db 存储token
|
||||||
@@ -208,8 +215,16 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
user.setCreateTime(LocalDateTime.now());
|
user.setCreateTime(LocalDateTime.now());
|
||||||
user.setUpdateBy("admin");
|
user.setUpdateBy("admin");
|
||||||
user.setUpdateTime(LocalDateTime.now());
|
user.setUpdateTime(LocalDateTime.now());
|
||||||
|
user.setUserType(2);
|
||||||
|
user.setTenantId(8000000000000000L + SnowflakeIdGenerator.of16(RandomCodeUtils.getRandomNumber(1)).nextId());
|
||||||
|
|
||||||
if (userMapper.insert(user) > 0) {
|
int i = 0;
|
||||||
|
try {
|
||||||
|
i = userMapper.insert(user);
|
||||||
|
} catch (DuplicateKeyException e) {
|
||||||
|
throw new BusinessException(Code01UserErrorCode.USER_EXISTS);
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
RegisterResp registerResp = new RegisterResp();
|
RegisterResp registerResp = new RegisterResp();
|
||||||
registerResp.setName(user.getName());
|
registerResp.setName(user.getName());
|
||||||
registerResp.setUsername(user.getUsername());
|
registerResp.setUsername(user.getUsername());
|
||||||
@@ -224,6 +239,23 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
public Page<UserResp> getUserList(UserQueryRequest request) {
|
public Page<UserResp> getUserList(UserQueryRequest request) {
|
||||||
Page<XUser> page = new Page<>(request.getCurrent(), request.getPageSize());
|
Page<XUser> page = new Page<>(request.getCurrent(), request.getPageSize());
|
||||||
LambdaQueryWrapper<XUser> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<XUser> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(XUser::getDelFlag, DelStatusEnum.NOT_DELETED.getCode());
|
||||||
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
|
lambdaQueryWrapper.like(XUser::getName, request.getName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getUsername())) {
|
||||||
|
lambdaQueryWrapper.eq(XUser::getUsername, request.getUsername());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getEmail())) {
|
||||||
|
lambdaQueryWrapper.like(XUser::getEmail, request.getEmail());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getPhone())) {
|
||||||
|
lambdaQueryWrapper.like(XUser::getPhone, request.getPhone());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(request.getStatus())) {
|
||||||
|
lambdaQueryWrapper.eq(XUser::getStatus, request.getStatus());
|
||||||
|
}
|
||||||
|
lambdaQueryWrapper.orderByDesc(XUser::getCreateTime);
|
||||||
return userConvert.toPage(userMapper.selectPage(page, lambdaQueryWrapper));
|
return userConvert.toPage(userMapper.selectPage(page, lambdaQueryWrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,21 +319,21 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDTO getUserDetail(Long userId) {
|
public UserDTO getUserDetail(String username) {
|
||||||
UserDTO dto = new UserDTO();
|
UserDTO dto = new UserDTO();
|
||||||
XUser user = userMapper.getUserById(userId);
|
XUser user = userMapper.selectByUsername(username);
|
||||||
if (Objects.isNull(user)) {
|
if (Objects.isNull(user)) {
|
||||||
throw new BusinessException(Code01UserErrorCode.USER_NOT_EXISTS);
|
throw new BusinessException(Code01UserErrorCode.USER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
dto.setUser(userConvert.toResp(user));
|
dto.setUser(userConvert.toResp(user));
|
||||||
List<XUserRole> userRoles = userRoleMapper.getByUserId(userId);
|
List<XUserRole> userRoles = userRoleMapper.getByUserId(user.getId());
|
||||||
List<Long> roleIds = userRoles.stream().map(XUserRole::getRoleId).toList();
|
List<Long> roleIds = userRoles.stream().map(XUserRole::getRoleId).toList();
|
||||||
List<XRole> roles = roleMapper.getRoleByIds(roleIds);
|
List<XRole> roles = roleMapper.getRoleByIds(roleIds);
|
||||||
if (CollectionUtils.isEmpty(roles)) {
|
if (CollectionUtils.isEmpty(roles)) {
|
||||||
throw new BusinessException(Code02RoleErrorCode.ROLE_NOT_EXISTS);
|
throw new BusinessException(Code02RoleErrorCode.ROLE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
dto.setRoles(roleConvert.toDTOList(roles));
|
dto.setRoles(roleConvert.toDTOList(roles));
|
||||||
XUserDept userDept = userDeptMapper.getByUserId(userId);
|
XUserDept userDept = userDeptMapper.getByUserId(user.getId());
|
||||||
if (Objects.nonNull(userDept)) {
|
if (Objects.nonNull(userDept)) {
|
||||||
Long deptId = userDept.getDeptId();
|
Long deptId = userDept.getDeptId();
|
||||||
XDept dept = deptMapper.getDeptById(deptId);
|
XDept dept = deptMapper.getDeptById(deptId);
|
||||||
@@ -316,6 +348,69 @@ public class XUserServiceImpl implements XUserService {
|
|||||||
List<XPermission> permissions = permissionMapper.getPermissionByIds(permissionIds);
|
List<XPermission> permissions = permissionMapper.getPermissionByIds(permissionIds);
|
||||||
dto.setPermissionRoles(permissionConvert.toDTOList(permissions));
|
dto.setPermissionRoles(permissionConvert.toDTOList(permissions));
|
||||||
}
|
}
|
||||||
|
dto.setPermissions(Sets.newHashSet("*:*:*"));
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoginResp refresh(RefreshRequest request) {
|
||||||
|
XUser user = userMapper.selectByUsername(request.getUsername());
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
throw new BusinessException(Code01UserErrorCode.USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(user.getRefreshToken()) || !user.getRefreshToken().equals(request.getRefreshToken())) {
|
||||||
|
throw new BusinessException(Code01UserErrorCode.REFRESH_TOKEN_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
// 校验 refreshToken 是否过期
|
||||||
|
Jwt refreshJwt;
|
||||||
|
try {
|
||||||
|
refreshJwt = jwtDecoder.decode(request.getRefreshToken());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("【刷新token】refreshToken解析失败", e);
|
||||||
|
throw new BusinessException("refreshToken 无效或已过期");
|
||||||
|
}
|
||||||
|
if (Objects.isNull(refreshJwt.getExpiresAt()) || refreshJwt.getExpiresAt().isBefore(Instant.now())) {
|
||||||
|
throw new BusinessException("refreshToken 已过期,请重新登录");
|
||||||
|
}
|
||||||
|
// 查询角色
|
||||||
|
List<String> roleCodes = Lists.newArrayList();
|
||||||
|
List<XUserRole> userRoles = userRoleMapper.getByUserId(user.getId());
|
||||||
|
if (CollectionUtils.isNotEmpty(userRoles)) {
|
||||||
|
List<XRole> roles = roleMapper.getRoleByIds(userRoles.stream().map(XUserRole::getRoleId).collect(Collectors.toList()));
|
||||||
|
if (CollectionUtils.isNotEmpty(roles)) {
|
||||||
|
roleCodes.addAll(roles.stream().map(XRole::getCode).toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 生成新的 accessToken
|
||||||
|
Instant now = Instant.now();
|
||||||
|
JwtClaimsSet claims = JwtClaimsSet.builder()
|
||||||
|
.issuedAt(now)
|
||||||
|
.expiresAt(now.plus(3, ChronoUnit.HOURS))
|
||||||
|
.claim("userId", user.getId())
|
||||||
|
.claim("tenantId", user.getTenantId())
|
||||||
|
.claim("timestamp", System.currentTimeMillis())
|
||||||
|
.claim("username", request.getUsername())
|
||||||
|
.claim("authorities", roleCodes)
|
||||||
|
.build();
|
||||||
|
String newToken = jwtEncoder.encode(JwtEncoderParameters.from(claims)).getTokenValue();
|
||||||
|
// 更新 Redis 和 DB
|
||||||
|
redisService.set(RedisConstant.LOGIN_TOKEN + request.getUsername(), newToken, 3, TimeUnit.HOURS);
|
||||||
|
user.setToken(newToken);
|
||||||
|
userMapper.update(user);
|
||||||
|
LoginResp loginResp = new LoginResp();
|
||||||
|
loginResp.setToken(newToken);
|
||||||
|
loginResp.setUsername(request.getUsername());
|
||||||
|
loginResp.setRefreshToken(request.getRefreshToken());
|
||||||
|
return loginResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateStatus(Long id, Integer status) {
|
||||||
|
XUser user = userMapper.getUserById(id);
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
throw new BusinessException(Code01UserErrorCode.USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
user.setStatus(status);
|
||||||
|
return userMapper.update(user) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
xs-service/src/main/resources/mapper/user/XMenuMapper.xml
Normal file
60
xs-service/src/main/resources/mapper/user/XMenuMapper.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.xiang.xservice.auth.service.repository.mapper.XMenuMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.xiang.xservice.auth.service.entity.XMenuDO" id="SysMenuResult">
|
||||||
|
<id property="menuId" column="menu_id" />
|
||||||
|
<result property="menuName" column="menu_name" />
|
||||||
|
<result property="parentName" column="parent_name" />
|
||||||
|
<result property="parentId" column="parent_id" />
|
||||||
|
<result property="orderNum" column="order_num" />
|
||||||
|
<result property="path" column="path" />
|
||||||
|
<result property="component" column="component" />
|
||||||
|
<result property="query" column="query" />
|
||||||
|
<result property="routeName" column="route_name" />
|
||||||
|
<result property="isFrame" column="is_frame" />
|
||||||
|
<result property="isCache" column="is_cache" />
|
||||||
|
<result property="menuType" column="menu_type" />
|
||||||
|
<result property="visible" column="visible" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="perms" column="perms" />
|
||||||
|
<result property="icon" column="icon" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectMenuVo">
|
||||||
|
select menu_id, menu_name, parent_id, order_num, path, component, `query`, route_name, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||||
|
from x_menu
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||||
|
select distinct m.menu_id,
|
||||||
|
m.parent_id,
|
||||||
|
m.menu_name,
|
||||||
|
m.path,
|
||||||
|
m.component,
|
||||||
|
m.`query`,
|
||||||
|
m.route_name,
|
||||||
|
m.visible,
|
||||||
|
m.status,
|
||||||
|
ifnull(m.perms, '') as perms,
|
||||||
|
m.is_frame,
|
||||||
|
m.is_cache,
|
||||||
|
m.menu_type,
|
||||||
|
m.icon,
|
||||||
|
m.order_num,
|
||||||
|
m.create_time
|
||||||
|
from x_menu m
|
||||||
|
left join x_role_menu rm on m.menu_id = rm.menu_id
|
||||||
|
left join x_user_role ur on rm.role_id = ur.role_id
|
||||||
|
left join x_role ro on ur.role_id = ro.id
|
||||||
|
left join x_user u on ur.user_id = u.id
|
||||||
|
where u.id = #{userId}
|
||||||
|
and m.menu_type in ('M', 'C')
|
||||||
|
and m.status = 0
|
||||||
|
AND ro.status = 0
|
||||||
|
order by m.parent_id, m.order_num
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -44,116 +44,6 @@
|
|||||||
token,
|
token,
|
||||||
refresh_token
|
refresh_token
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.auth.service.entity.XUser">
|
|
||||||
INSERT INTO x_user
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="null != name and '' != name">
|
|
||||||
name,
|
|
||||||
</if>
|
|
||||||
<if test="null != username and '' != username">
|
|
||||||
username,
|
|
||||||
</if>
|
|
||||||
<if test="null != password and '' != password">
|
|
||||||
password,
|
|
||||||
</if>
|
|
||||||
<if test="null != email and '' != email">
|
|
||||||
email,
|
|
||||||
</if>
|
|
||||||
<if test="null != phone and '' != phone">
|
|
||||||
phone,
|
|
||||||
</if>
|
|
||||||
<if test="null != avatar and '' != avatar">
|
|
||||||
avatar,
|
|
||||||
</if>
|
|
||||||
<if test="null != loginIp and '' != loginIp">
|
|
||||||
login_ip,
|
|
||||||
</if>
|
|
||||||
<if test="null != loginDate ">
|
|
||||||
login_date,
|
|
||||||
</if>
|
|
||||||
<if test="null != delFlag ">
|
|
||||||
del_flag,
|
|
||||||
</if>
|
|
||||||
<if test="null != status ">
|
|
||||||
status,
|
|
||||||
</if>
|
|
||||||
<if test="null != createBy and '' != createBy">
|
|
||||||
create_by,
|
|
||||||
</if>
|
|
||||||
<if test="null != createTime ">
|
|
||||||
create_time,
|
|
||||||
</if>
|
|
||||||
<if test="null != updateBy and '' != updateBy">
|
|
||||||
update_by,
|
|
||||||
</if>
|
|
||||||
<if test="null != updateTime ">
|
|
||||||
update_time,
|
|
||||||
</if>
|
|
||||||
<if test="tenantId != null">
|
|
||||||
tenant_id,
|
|
||||||
</if>
|
|
||||||
<if test="token != null and token != ''">
|
|
||||||
token,
|
|
||||||
</if>
|
|
||||||
<if test="refreshToken != null and refreshToken != ''">
|
|
||||||
refreshToken
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="null != name and '' != name">
|
|
||||||
#{name},
|
|
||||||
</if>
|
|
||||||
<if test="null != username and '' != username">
|
|
||||||
#{username},
|
|
||||||
</if>
|
|
||||||
<if test="null != password and '' != password">
|
|
||||||
#{password},
|
|
||||||
</if>
|
|
||||||
<if test="null != email and '' != email">
|
|
||||||
#{email},
|
|
||||||
</if>
|
|
||||||
<if test="null != phone and '' != phone">
|
|
||||||
#{phone},
|
|
||||||
</if>
|
|
||||||
<if test="null != avatar and '' != avatar">
|
|
||||||
#{avatar},
|
|
||||||
</if>
|
|
||||||
<if test="null != loginIp and '' != loginIp">
|
|
||||||
#{loginIp},
|
|
||||||
</if>
|
|
||||||
<if test="null != loginDate ">
|
|
||||||
#{loginDate},
|
|
||||||
</if>
|
|
||||||
<if test="null != delFlag ">
|
|
||||||
#{delFlag},
|
|
||||||
</if>
|
|
||||||
<if test="null != status ">
|
|
||||||
#{status},
|
|
||||||
</if>
|
|
||||||
<if test="null != createBy and '' != createBy">
|
|
||||||
#{createBy},
|
|
||||||
</if>
|
|
||||||
<if test="null != createTime ">
|
|
||||||
#{createTime},
|
|
||||||
</if>
|
|
||||||
<if test="null != updateBy and '' != updateBy">
|
|
||||||
#{updateBy},
|
|
||||||
</if>
|
|
||||||
<if test="null != updateTime ">
|
|
||||||
#{updateTime},
|
|
||||||
</if>
|
|
||||||
<if test="tenantId != null">
|
|
||||||
#{tenantId},
|
|
||||||
</if>
|
|
||||||
<if test="token != null and token != ''">
|
|
||||||
#{token},
|
|
||||||
</if>
|
|
||||||
<if test="refreshToken != null and refreshToken != ''">
|
|
||||||
#{refreshToken}
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
<insert id="insertBatch">
|
<insert id="insertBatch">
|
||||||
insert into x_user(name, username, password, email, phone, status, tenant_id) VALUES
|
insert into x_user(name, username, password, email, phone, status, tenant_id) VALUES
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
@@ -183,12 +73,13 @@
|
|||||||
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
||||||
<if test="null != tenantId ">tenant_id = #{tenantId},</if>
|
<if test="null != tenantId ">tenant_id = #{tenantId},</if>
|
||||||
<if test="null != token and '' != token ">token = #{token},</if>
|
<if test="null != token and '' != token ">token = #{token},</if>
|
||||||
<if test="null != refreshToken and '' != refreshToken ">refresh_token = #{refreshToken}</if>
|
<if test="null != refreshToken and '' != refreshToken ">refresh_token = #{refreshToken},</if>
|
||||||
|
<if test="status != null">status = #{status}</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</update>
|
</update>
|
||||||
<update id="deleteBatch">
|
<update id="deleteBatch">
|
||||||
update x_user set del_flag = 0, update_time = #{time}, update_by = #{operator} where id in
|
update x_user set del_flag = 1, update_time = #{time}, update_by = #{operator} where id in
|
||||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
@@ -197,7 +88,7 @@
|
|||||||
<select id="selectByUsername" resultMap="BaseResultMap">
|
<select id="selectByUsername" resultMap="BaseResultMap">
|
||||||
select <include refid="Base_Column_List"/>
|
select <include refid="Base_Column_List"/>
|
||||||
from x_user
|
from x_user
|
||||||
where username = #{username} and del_flag = 0 and status = 1
|
where username = #{username} and del_flag = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUserList" resultMap="BaseResultMap">
|
<select id="getUserList" resultMap="BaseResultMap">
|
||||||
|
|||||||
Reference in New Issue
Block a user