diff --git a/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/OAuthClientFeignClient.java b/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/OAuthClientFeignClient.java index 51ec9d0f1..325e1ac50 100644 --- a/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/OAuthClientFeignClient.java +++ b/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/OAuthClientFeignClient.java @@ -1,15 +1,14 @@ package com.youlai.admin.api; -import com.youlai.admin.dto.OAuth2ClientDTO; +import com.youlai.admin.dto.AuthClientDTO; import com.youlai.common.result.Result; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; @FeignClient(value = "youlai-admin", contextId = "oauth-client") public interface OAuthClientFeignClient { @GetMapping("/api/v1/oauth-clients/getOAuth2ClientById") - Result getOAuth2ClientById(@RequestParam String clientId); + Result getOAuth2ClientById(@RequestParam String clientId); } diff --git a/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/UserFeignClient.java b/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/UserFeignClient.java index 89adc541b..95789b165 100644 --- a/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/UserFeignClient.java +++ b/youlai-admin/admin-api/src/main/java/com/youlai/admin/api/UserFeignClient.java @@ -1,7 +1,7 @@ package com.youlai.admin.api; import com.youlai.admin.api.fallback.UserFeignFallbackClient; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.common.result.Result; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -11,5 +11,5 @@ import org.springframework.web.bind.annotation.PathVariable; public interface UserFeignClient { @GetMapping("/api/v1/users/username/{username}") - Result getUserByUsername(@PathVariable String username); + Result getUserByUsername(@PathVariable String username); } diff --git a/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthClientDTO.java b/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthClientDTO.java new file mode 100644 index 000000000..6cccee28a --- /dev/null +++ b/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthClientDTO.java @@ -0,0 +1,69 @@ +package com.youlai.admin.dto; + +import lombok.Data; + +/** + * OAuth2客户端传输层对象 + * + * @author haoxr + * @date 2021/1/15 + */ +@Data +public class AuthClientDTO { + + /** + * 客户端ID + */ + private String clientId; + + /** + * 客户端密钥 + */ + private String clientSecret; + + /** + * 资源id列表 + */ + private String resourceIds; + + /** + * 域 + */ + private String scope; + + /** + * 授权方式 + */ + private String authorizedGrantTypes; + + /** + * 回调地址 + */ + private String webServerRedirectUri; + + /** + * 权限列表 + */ + private String authorities; + + /** + * 认证令牌时效 + */ + private Integer accessTokenValidity; + + /** + * 刷新令牌时效 + */ + private Integer refreshTokenValidity; + + /** + * 扩展信息 + */ + private String additionalInformation; + + /** + * 是否自动放行 + */ + private String autoapprove; + +} diff --git a/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/UserAuthDTO.java b/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthUserDTO.java similarity index 76% rename from youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/UserAuthDTO.java rename to youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthUserDTO.java index d006287f1..4318f93e1 100644 --- a/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/UserAuthDTO.java +++ b/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/AuthUserDTO.java @@ -5,13 +5,13 @@ import lombok.Data; import java.util.List; /** - * 系统用户认证信息 + * OAuth2认证用户信息传输层对象 * - * @author haoxr + * @author haoxr * @date 2021/9/27 */ @Data -public class UserAuthDTO { +public class AuthUserDTO { /** * 用户ID @@ -29,7 +29,7 @@ public class UserAuthDTO { private String password; /** - * 用户状态:1-有效;0-禁用 + * 用户状态(1:正常;0:禁用) */ private Integer status; @@ -43,6 +43,4 @@ public class UserAuthDTO { */ private Long deptId; - - } diff --git a/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/OAuth2ClientDTO.java b/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/OAuth2ClientDTO.java deleted file mode 100644 index 58a30d1ca..000000000 --- a/youlai-admin/admin-api/src/main/java/com/youlai/admin/dto/OAuth2ClientDTO.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.youlai.admin.dto; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 客户端实体 - */ -@Data -public class OAuth2ClientDTO { - - @ApiModelProperty(value = "客户端ID") - private String clientId; - - @ApiModelProperty(value = "客户端密钥") - private String clientSecret; - - @ApiModelProperty(value = "资源id列表") - private String resourceIds; - - @ApiModelProperty(value = "域") - private String scope; - - @ApiModelProperty(value = "授权方式") - private String authorizedGrantTypes; - - @ApiModelProperty("回调地址") - private String webServerRedirectUri; - - @ApiModelProperty(value = "权限列表") - private String authorities; - - @ApiModelProperty(value = "认证令牌时效") - private Integer accessTokenValidity; - - @ApiModelProperty(value = "刷新令牌时效") - private Integer refreshTokenValidity; - - @ApiModelProperty(value = "扩展信息") - private String additionalInformation; - - @ApiModelProperty(value = "是否自动放行") - private String autoapprove; - -} diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictController.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictController.java index 5f8721596..39cf744ab 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictController.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictController.java @@ -33,24 +33,23 @@ public class DictController { @ApiOperation(value = "列表分页") @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Integer"), - @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Integer"), + @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", dataType = "Integer"), + @ApiImplicitParam(name = "pageSize", value = "每页数量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "name", value = "字典名称", paramType = "query", dataType = "String"), }) @GetMapping("/page") - public Result list( Integer page,Integer limit, String name) { - Page result = iSysDictService.page(new Page<>(page, limit), new LambdaQueryWrapper() + public Result list(Long pageNum, Long pageSize, String name) { + Page result = iSysDictService.page(new Page<>(pageNum, pageSize), new LambdaQueryWrapper() .like(StrUtil.isNotBlank(name), SysDict::getName, StrUtil.trimToNull(name)) .orderByDesc(SysDict::getGmtModified) .orderByDesc(SysDict::getGmtCreate)); return Result.success(result.getRecords(), result.getTotal()); } - @ApiOperation(value = "字典列表") @GetMapping public Result list() { - List list = iSysDictService.list( new LambdaQueryWrapper() + List list = iSysDictService.list(new LambdaQueryWrapper() .orderByDesc(SysDict::getGmtModified) .orderByDesc(SysDict::getGmtCreate)); return Result.success(list); diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictItemController.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictItemController.java index 80f6d3166..8b14f2f60 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictItemController.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/DictItemController.java @@ -35,12 +35,12 @@ public class DictItemController { }) @GetMapping("/page") public Result getPageList( - Integer page, - Integer limit, + long pageNum, + long pageSize, String name, String dictCode ) { - IPage result = iSysDictItemService.list(new Page<>(page, limit), + IPage result = iSysDictItemService.list(new Page<>(pageNum, pageSize), new SysDictItem().setName(name).setDictCode(dictCode)); return Result.success(result.getRecords(), result.getTotal()); } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/OauthClientController.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/OauthClientController.java index 4e51f8e94..8463f222c 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/OauthClientController.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/OauthClientController.java @@ -6,7 +6,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.youlai.admin.dto.OAuth2ClientDTO; +import com.youlai.admin.dto.AuthClientDTO; import com.youlai.admin.pojo.entity.SysOauthClient; import com.youlai.admin.service.ISysOauthClientService; import com.youlai.common.result.Result; @@ -84,11 +84,11 @@ public class OauthClientController { @ApiOperation(hidden = true, value = "获取 OAuth2 客户端认证信息", notes = "Feign 调用") @GetMapping("/getOAuth2ClientById") - public Result getOAuth2ClientById(@RequestParam String clientId) { + public Result getOAuth2ClientById(@RequestParam String clientId) { SysOauthClient client = iSysOauthClientService.getById(clientId); Assert.isTrue(client!=null, "OAuth2 客户端不存在"); - OAuth2ClientDTO oAuth2ClientDTO = new OAuth2ClientDTO(); - BeanUtil.copyProperties(client, oAuth2ClientDTO); - return Result.success(oAuth2ClientDTO); + AuthClientDTO authClientDTO = new AuthClientDTO(); + BeanUtil.copyProperties(client, authClientDTO); + return Result.success(authClientDTO); } } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java index 412cdd679..b2b90277e 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/UserController.java @@ -3,18 +3,17 @@ package com.youlai.admin.controller; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.admin.pojo.entity.SysUser; import com.youlai.admin.pojo.query.UserPageQuery; import com.youlai.admin.pojo.vo.LoginUserVO; -import com.youlai.admin.pojo.vo.UserDetailVO; +import com.youlai.admin.pojo.vo.user.UserFormVO; +import com.youlai.admin.pojo.vo.user.UserPageVO; import com.youlai.admin.service.ISysPermissionService; -import com.youlai.admin.service.ISysUserRoleService; import com.youlai.admin.service.ISysUserService; import com.youlai.common.result.Result; import com.youlai.common.web.util.JwtUtils; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; @@ -25,30 +24,37 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -@Api(tags = "用户接口") +/** + * 用户管理控制器 + * + * @author haoxr + * @date 2022/1/15 10:25 + */ +@Api(tags = "用户管理") @RestController @RequestMapping("/api/v1/users") @RequiredArgsConstructor public class UserController { private final ISysUserService iSysUserService; - private final ISysUserRoleService iSysUserRoleService; private final PasswordEncoder passwordEncoder; private final ISysPermissionService iSysPermissionService; @ApiOperation(value = "用户分页列表") - @GetMapping - public Result list(UserPageQuery queryParam) { - IPage result = iSysUserService.list(queryParam); + @GetMapping("/page") + public Result> listUsersWithPage( + UserPageQuery queryParam + ) { + IPage result = iSysUserService.listUsersWithPage(queryParam); return Result.success(result.getRecords(), result.getTotal()); } - @ApiOperation(value = "用户详情") - @GetMapping("/{userId}") - public Result getUserDetail( + @ApiOperation(value = "获取用户表单详情") + @GetMapping("/{userId}/form") + public Result getUserDetail( @ApiParam(value = "用户ID", example = "1") @PathVariable Long userId ) { - UserDetailVO userDetail = iSysUserService.getUserDetailById(userId); + UserFormVO userDetail = iSysUserService.getUserFormById(userId); return Result.success(userDetail); } @@ -70,34 +76,38 @@ public class UserController { } @ApiOperation(value = "删除用户") - @ApiImplicitParam(name = "ids", value = "id集合", required = true, paramType = "query", dataType = "String") @DeleteMapping("/{ids}") - public Result delete(@PathVariable String ids) { + public Result deleteUsers( + @ApiParam("用户ID,多个以英文逗号(,)分割") @PathVariable String ids + ) { boolean status = iSysUserService.removeByIds(Arrays.asList(ids.split(",")).stream().collect(Collectors.toList())); return Result.judge(status); } @ApiOperation(value = "选择性更新用户") - @ApiImplicitParam(name = "id", value = "用户ID", required = true, paramType = "path", dataType = "Long") - @PatchMapping(value = "/{id}") - public Result patch(@PathVariable Long id, @RequestBody SysUser user) { - System.out.println(user.getPassword() != null); - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(SysUser::getId, id); + @PatchMapping(value = "/{userId}") + public Result updateUserPart( + @ApiParam("用户ID") @PathVariable Long userId, + @RequestBody SysUser user + ) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper() + .eq(SysUser::getId, userId); updateWrapper.set(user.getStatus() != null, SysUser::getStatus, user.getStatus()); - updateWrapper.set(user.getPassword() != null, SysUser::getPassword, user.getPassword() != null ? passwordEncoder.encode(user.getPassword()) : null); + updateWrapper.set(user.getPassword() != null, SysUser::getPassword, + user.getPassword() != null ? passwordEncoder.encode(user.getPassword()) + : null); boolean status = iSysUserService.update(updateWrapper); return Result.judge(status); } - /** * 提供用于用户登录认证信息 */ - @ApiOperation(value = "根据用户名获取用户信息") - @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "path", dataType = "String") + @ApiOperation(value = "根据用户名获取认证信息") @GetMapping("/username/{username}") - public Result getUserByUsername(@PathVariable String username) { - UserAuthDTO user = iSysUserService.getByUsername(username); + public Result getAuthInfoByUsername( + @ApiParam("用户名") @PathVariable String username) { + AuthUserDTO user = iSysUserService.getAuthInfoByUsername(username); return Result.success(user); } @@ -117,4 +127,5 @@ public class UserController { loginUserVO.setPerms(perms); return Result.success(loginUserVO); } + } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/DictV2Controller.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/DictV2Controller.java index 3ebbd5d55..90339a672 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/DictV2Controller.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/DictV2Controller.java @@ -9,16 +9,13 @@ import com.youlai.admin.pojo.entity.SysDictItem; import com.youlai.admin.service.ISysDictItemService; import com.youlai.admin.service.ISysDictService; import com.youlai.common.result.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.*; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; -@Api(tags = "字典接口") +@Api(tags = "字典管理") @RestController @RequestMapping("/api/v2/dict") @RequiredArgsConstructor @@ -28,13 +25,12 @@ public class DictV2Controller { private final ISysDictItemService iSysDictItemService; @ApiOperation(value = "字典分页列表") - @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "pageSize", value = "每页数量", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "name", value = "字典名称", paramType = "query", dataType = "String"), - }) @GetMapping("/page") - public Result listDictByPage(long pageNum, long pageSize, String name) { + public Result listDictByPage( + @ApiParam("页码") long pageNum, + @ApiParam("每页数量") long pageSize, + @ApiParam("字典名称") String name + ) { Page result = iSysDictService.page(new Page<>(pageNum, pageSize), new LambdaQueryWrapper() .like(StrUtil.isNotBlank(name), SysDict::getName, StrUtil.trimToNull(name)) @@ -45,7 +41,9 @@ public class DictV2Controller { @ApiOperation(value = "字典详情") @GetMapping("/{id}") - public Result getDictDetail(@PathVariable Long id) { + public Result getDictDetail( + @ApiParam("字典ID") @PathVariable Long id + ) { SysDict dict = iSysDictService.getById(id); return Result.success(dict); } @@ -65,9 +63,10 @@ public class DictV2Controller { } @ApiOperation(value = "删除字典") - @ApiImplicitParam(name = "ids", value = "以,分割拼接字符串", required = true, paramType = "query", dataType = "String") @DeleteMapping("/{ids}") - public Result deleteDict(@PathVariable String ids) { + public Result deleteDict( + @ApiParam("字典ID,多个以英文逗号(,)分割") @PathVariable String ids + ) { boolean result = iSysDictService.deleteDictByIds(ids); return Result.judge(result); } @@ -80,7 +79,12 @@ public class DictV2Controller { @ApiImplicitParam(name = "dictCode", value = "字典编码", paramType = "query", dataType = "String") }) @GetMapping("/items/page") - public Result getPageList(long pageNum, long pageSize, String name, String dictCode) { + public Result getPageList( + long pageNum, + long pageSize, + String name, + String dictCode + ) { IPage result = iSysDictItemService.list( new Page<>(pageNum, pageSize), new SysDictItem().setName(name).setDictCode(dictCode) diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/UserV2Controller.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/UserV2Controller.java deleted file mode 100644 index 86458c40f..000000000 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/controller/v2/UserV2Controller.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.youlai.admin.controller.v2; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.youlai.admin.pojo.entity.SysUser; -import com.youlai.admin.service.ISysPermissionService; -import com.youlai.admin.service.ISysUserRoleService; -import com.youlai.admin.service.ISysUserService; -import com.youlai.common.result.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Api(tags = "用户接口") -@RestController -@RequestMapping("/api/v2/users") -@Slf4j -@RequiredArgsConstructor -public class UserV2Controller { - - private final ISysUserService iSysUserService; - - @ApiOperation(value = "列表分页") - @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "mobile", value = "手机号码", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "Long"), - @ApiImplicitParam(name = "deptId", value = "部门ID", paramType = "query", dataType = "Long"), - }) - @GetMapping("pageList") - public Result list(Integer page, Integer limit, String keywords, String mobile, Integer status, Long deptId) { - SysUser user = new SysUser(); - user.setKeywords(keywords); - user.setMobile(mobile); - user.setStatus(status); - user.setDeptId(deptId); - - IPage result = iSysUserService.list(new Page<>(page, limit), user); - return Result.success(result.getRecords(), result.getTotal()); - } - - -} diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java index 1c57c7135..d749c4b12 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java @@ -2,10 +2,11 @@ package com.youlai.admin.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.admin.pojo.entity.SysUser; import com.youlai.admin.pojo.query.UserPageQuery; -import com.youlai.admin.pojo.vo.UserDetailVO; +import com.youlai.admin.pojo.vo.user.UserFormVO; +import com.youlai.admin.pojo.vo.user.UserPageVO; import com.youlai.common.mybatis.handler.InterceptorIgnore; import org.apache.ibatis.annotations.Mapper; @@ -23,14 +24,12 @@ public interface SysUserMapper extends BaseMapper { /** * 获取用户分页列表 * - * @param page + * @param pageParam * @param queryParam * @return */ @InterceptorIgnore(deptAlias = "d") - List list(Page page, UserPageQuery queryParam); - - UserAuthDTO getByUsername(String username); + List listUsersWithPage(Page pageParam, UserPageQuery queryParam); /** * 根据用户ID获取用户详情 @@ -38,5 +37,15 @@ public interface SysUserMapper extends BaseMapper { * @param userId * @return */ - UserDetailVO getUserDetailById(Long userId); + UserFormVO getUserFormById(Long userId); + + /** + * 根据用户名获取认证信息 + * + * @param username + * @return + */ + AuthUserDTO getAuthInfoByUsername(String username); + + } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserRoleMapper.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserRoleMapper.java index bb13e2938..2015583aa 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserRoleMapper.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserRoleMapper.java @@ -4,6 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.youlai.admin.pojo.entity.SysUserRole; import org.apache.ibatis.annotations.Mapper; +/** + * 用户角色持久层 + * + * @author haoxr + * @date 2022/1/15 + */ @Mapper public interface SysUserRoleMapper extends BaseMapper { diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java index a0319f1b8..f60b0dae1 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/entity/SysUser.java @@ -51,9 +51,4 @@ public class SysUser extends BaseEntity { @TableField(exist = false) private List roles; - - @TableField(exist = false) - private String keywords; - - } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/UserDetailVO.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserFormVO.java similarity index 86% rename from youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/UserDetailVO.java rename to youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserFormVO.java index f06b5cd36..0ef32a809 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/UserDetailVO.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserFormVO.java @@ -1,4 +1,4 @@ -package com.youlai.admin.pojo.vo; +package com.youlai.admin.pojo.vo.user; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -7,14 +7,14 @@ import lombok.Data; import java.util.List; /** - * 用户详情视图对象 + * 用户表单视图对象 * * @author haoxr * @date 2022/1/14 */ -@ApiModel("用户详情视图对象") +@ApiModel("用户表单视图对象") @Data -public class UserDetailVO { +public class UserFormVO { @ApiModelProperty("用户ID") private Long id; diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserPageVO.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserPageVO.java new file mode 100644 index 000000000..98c5a3530 --- /dev/null +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/pojo/vo/user/UserPageVO.java @@ -0,0 +1,54 @@ +package com.youlai.admin.pojo.vo.user; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 用户分页视图对象 + * + * @author haoxr + * @date 2022/1/15 9:41 + */ +@ApiModel("用户分页视图对象") +@Data +public class UserPageVO { + + @ApiModelProperty("用户ID") + private Long id; + + @ApiModelProperty("用户名") + private String username; + + @ApiModelProperty("用户昵称") + private String nickname; + + @ApiModelProperty("手机号") + private String mobile; + + @ApiModelProperty("性别(1:男;2:女)") + private Integer gender; + + @ApiModelProperty("用户头像地址") + private String avatar; + + @ApiModelProperty("用户邮箱") + private String email; + + @ApiModelProperty("用户状态(1:启用;0:禁用)") + private Integer status; + + @ApiModelProperty("部门名称") + private String deptName; + + @ApiModelProperty("角色名称,多个使用英文逗号(,)分割") + private String roleNames; + + @ApiModelProperty("创建时间") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date gmtCreate; + +} diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/ISysUserService.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/ISysUserService.java index c3398b532..756bfb3c0 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/ISysUserService.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/ISysUserService.java @@ -3,10 +3,11 @@ package com.youlai.admin.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.admin.pojo.entity.SysUser; import com.youlai.admin.pojo.query.UserPageQuery; -import com.youlai.admin.pojo.vo.UserDetailVO; +import com.youlai.admin.pojo.vo.user.UserFormVO; +import com.youlai.admin.pojo.vo.user.UserPageVO; /** * 用户业务接口 @@ -21,7 +22,7 @@ public interface ISysUserService extends IService { * * @return */ - IPage list(UserPageQuery userPageQuery); + IPage listUsersWithPage(UserPageQuery userPageQuery); /** * 新增用户 @@ -40,12 +41,12 @@ public interface ISysUserService extends IService { boolean updateUser(SysUser user); /** - * 根据用户名获取认证用户信息,携带角色和密码 + * 根据用户名获取认证信息 * * @param username * @return */ - UserAuthDTO getByUsername(String username); + AuthUserDTO getAuthInfoByUsername(String username); /** * 根据用户ID获取用户详情 @@ -53,5 +54,5 @@ public interface ISysUserService extends IService { * @param userId * @return */ - UserDetailVO getUserDetailById(Long userId); + UserFormVO getUserFormById(Long userId); } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysUserServiceImpl.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysUserServiceImpl.java index ee19beb6a..075ea5f0a 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysUserServiceImpl.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysUserServiceImpl.java @@ -6,12 +6,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.admin.constant.SystemConstants; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.admin.pojo.entity.SysUser; import com.youlai.admin.mapper.SysUserMapper; import com.youlai.admin.pojo.entity.SysUserRole; import com.youlai.admin.pojo.query.UserPageQuery; -import com.youlai.admin.pojo.vo.UserDetailVO; +import com.youlai.admin.pojo.vo.user.UserFormVO; +import com.youlai.admin.pojo.vo.user.UserPageVO; import com.youlai.admin.service.ISysUserRoleService; import com.youlai.admin.service.ISysUserService; import lombok.RequiredArgsConstructor; @@ -38,12 +39,13 @@ public class SysUserServiceImpl extends ServiceImpl impl /** * 获取用户分页列表 * + * @param queryParam * @return */ @Override - public IPage list(UserPageQuery queryParam) { - Page page = new Page<>(queryParam.getPageNum(), queryParam.getPageSize()); - List list = this.baseMapper.list(page, queryParam); + public IPage listUsersWithPage(UserPageQuery queryParam) { + Page page = new Page<>(queryParam.getPageNum(), queryParam.getPageSize()); + List list = this.baseMapper.listUsersWithPage(page, queryParam); page.setRecords(list); return page; } @@ -109,9 +111,15 @@ public class SysUserServiceImpl extends ServiceImpl impl return this.updateById(user); } + /** + * 根据用户名获取认证信息 + * + * @param username + * @return + */ @Override - public UserAuthDTO getByUsername(String username) { - UserAuthDTO userAuthInfo = this.baseMapper.getByUsername(username); + public AuthUserDTO getAuthInfoByUsername(String username) { + AuthUserDTO userAuthInfo = this.baseMapper.getAuthInfoByUsername(username); return userAuthInfo; } @@ -122,8 +130,8 @@ public class SysUserServiceImpl extends ServiceImpl impl * @return */ @Override - public UserDetailVO getUserDetailById(Long userId) { - UserDetailVO userDetail = this.baseMapper.getUserDetailById(userId); + public UserFormVO getUserFormById(Long userId) { + UserFormVO userDetail = this.baseMapper.getUserFormById(userId); return userDetail; } diff --git a/youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml b/youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml index e66fea00d..f664aa221 100644 --- a/youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml +++ b/youlai-admin/admin-boot/src/main/resources/mapper/SysUserMapper.xml @@ -4,43 +4,19 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - SELECT - t1.id userId, - t1.username, - t1.nickname, - t1.PASSWORD, - t1.STATUS, - t1.dept_id deptId, - t3.CODE roleCode - FROM - sys_user t1, - sys_user_role t2, - sys_role t3 - WHERE - t1.username = #{username} - AND t1.deleted = 0 - AND t1.id = t2.user_id - AND t2.role_id = t3.id - - - - + + + + + + + + + + + + + + + - - + + + + + + @@ -74,23 +85,21 @@ - - - SELECT - id, - username, - nickname, - mobile, - gender, - avatar, - email, - STATUS, - dept_id + t1.id userId, + t1.username, + t1.nickname, + t1.PASSWORD, + t1.STATUS, + t1.dept_id deptId, + t3.CODE roleCode FROM - sys_user + sys_user t1 + LEFT JOIN sys_user_role t2 ON t2.user_id = t1.id + LEFT JOIN sys_role t3 ON t3.id = t2.role_id WHERE - id = #{userId} - AND deleted =0 + t1.username = #{username} and t1.deleted=0 diff --git a/youlai-admin/admin-boot/src/main/resources/mapper/SysUserRoleMapper.xml b/youlai-admin/admin-boot/src/main/resources/mapper/SysUserRoleMapper.xml new file mode 100644 index 000000000..f07755adc --- /dev/null +++ b/youlai-admin/admin-boot/src/main/resources/mapper/SysUserRoleMapper.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/youlai-auth/src/main/java/com/youlai/auth/security/core/clientdetails/ClientDetailsServiceImpl.java b/youlai-auth/src/main/java/com/youlai/auth/security/core/clientdetails/ClientDetailsServiceImpl.java index 3cc9e51c8..f4ad52393 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/security/core/clientdetails/ClientDetailsServiceImpl.java +++ b/youlai-auth/src/main/java/com/youlai/auth/security/core/clientdetails/ClientDetailsServiceImpl.java @@ -1,7 +1,7 @@ package com.youlai.auth.security.core.clientdetails; import com.youlai.admin.api.OAuthClientFeignClient; -import com.youlai.admin.dto.OAuth2ClientDTO; +import com.youlai.admin.dto.AuthClientDTO; import com.youlai.auth.common.enums.PasswordEncoderTypeEnum; import com.youlai.common.result.Result; import lombok.RequiredArgsConstructor; @@ -26,9 +26,9 @@ public class ClientDetailsServiceImpl implements ClientDetailsService { @Cacheable(cacheNames = "auth", key = "'oauth-client:'+#clientId") public ClientDetails loadClientByClientId(String clientId) { try { - Result result = oAuthClientFeignClient.getOAuth2ClientById(clientId); + Result result = oAuthClientFeignClient.getOAuth2ClientById(clientId); if (Result.success().getCode().equals(result.getCode())) { - OAuth2ClientDTO client = result.getData(); + AuthClientDTO client = result.getData(); BaseClientDetails clientDetails = new BaseClientDetails( client.getClientId(), client.getResourceIds(), diff --git a/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetails.java b/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetails.java index e0563e2d6..adf0abfdf 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetails.java +++ b/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetails.java @@ -1,7 +1,7 @@ package com.youlai.auth.security.core.userdetails.user; import cn.hutool.core.collection.CollectionUtil; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.auth.common.enums.PasswordEncoderTypeEnum; import com.youlai.common.constant.GlobalConstants; import lombok.Data; @@ -40,7 +40,7 @@ public class SysUserDetails implements UserDetails { /** * 系统管理用户 */ - public SysUserDetails(UserAuthDTO user) { + public SysUserDetails(AuthUserDTO user) { this.setUserId(user.getUserId()); this.setUsername(user.getUsername()); this.setDeptId(user.getDeptId()); diff --git a/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetailsServiceImpl.java b/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetailsServiceImpl.java index 8c9e81c36..0f18b2c95 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetailsServiceImpl.java +++ b/youlai-auth/src/main/java/com/youlai/auth/security/core/userdetails/user/SysUserDetailsServiceImpl.java @@ -1,7 +1,7 @@ package com.youlai.auth.security.core.userdetails.user; import com.youlai.admin.api.UserFeignClient; -import com.youlai.admin.dto.UserAuthDTO; +import com.youlai.admin.dto.AuthUserDTO; import com.youlai.common.result.Result; import com.youlai.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -29,9 +29,9 @@ public class SysUserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { SysUserDetails userDetails = null; - Result result = userFeignClient.getUserByUsername(username); + Result result = userFeignClient.getUserByUsername(username); if (Result.isSuccess(result)) { - UserAuthDTO user = result.getData(); + AuthUserDTO user = result.getData(); if (null != user) { userDetails = new SysUserDetails(user); }