Kaynağa Gözat

用户基本信息接口

wukai 1 yıl önce
ebeveyn
işleme
bb1d400504

+ 12 - 0
doc-admin/src/main/java/com/doc/web/controller/system/SysUserController.java

@@ -12,12 +12,14 @@ import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
 import com.doc.common.utils.SecurityUtils;
 import com.doc.common.utils.StringUtils;
+import com.doc.common.utils.bean.BeanUtils;
 import com.doc.common.utils.poi.ExcelUtil;
 import com.doc.system.service.ISysDeptService;
 import com.doc.system.service.ISysPostService;
 import com.doc.system.service.ISysRoleService;
 import com.doc.system.service.ISysUserService;
 import com.doc.web.vo.UserTreeVO;
+import com.doc.web.vo.UserVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.ArrayUtils;
@@ -66,6 +68,15 @@ public class SysUserController extends BaseController {
         return getDataTable(list);
     }
 
+    @ApiOperation("获取用户基本信息")
+    @GetMapping(value = {"/info/{userId}"})
+    public UserVO info(@PathVariable(value = "userId", required = false) Long userId) {
+        SysUser sysUser = userService.selectUserById(userId);
+        UserVO vo = new UserVO();
+        BeanUtils.copyProperties(sysUser, vo);
+        return vo;
+    }
+
     /**
      * 获取用户树
      */
@@ -150,6 +161,7 @@ public class SysUserController extends BaseController {
         util.importTemplateExcel(response, "用户数据");
     }
 
+
     /**
      * 根据用户编号获取详细信息
      */

+ 32 - 56
doc-admin/src/main/java/com/doc/web/controller/tool/TestController.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -24,15 +25,15 @@ import io.swagger.annotations.ApiOperation;
 
 /**
  * swagger 用户测试方法
- * 
+ *
  * @author ruoyi
  */
-//@Api(tags="用户信息管理")
+@Api(tags = "swagger测试")
 @RestController
 @RequestMapping("/test/user")
-public class TestController extends BaseController
-{
+public class TestController extends BaseController {
     private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
+
     {
         users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
         users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
@@ -40,8 +41,7 @@ public class TestController extends BaseController
 
     @ApiOperation("获取用户列表")
     @GetMapping("/list")
-    public R<List<UserEntity>> userList()
-    {
+    public R<List<UserEntity>> userList() {
         List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
         return R.ok(userList);
     }
@@ -49,30 +49,24 @@ public class TestController extends BaseController
     @ApiOperation("获取用户详细")
     @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
     @GetMapping("/{userId}")
-    public R<UserEntity> getUser(@PathVariable Integer userId)
-    {
-        if (!users.isEmpty() && users.containsKey(userId))
-        {
+    public R<UserEntity> getUser(@PathVariable Integer userId) {
+        if (!users.isEmpty() && users.containsKey(userId)) {
             return R.ok(users.get(userId));
-        }
-        else
-        {
+        } else {
             return R.fail("用户不存在");
         }
     }
 
     @ApiOperation("新增用户")
     @ApiImplicitParams({
-        @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
-        @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
-        @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
-        @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
+            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
+            @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
+            @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
+            @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
     })
     @PostMapping("/save")
-    public R<String> save(UserEntity user)
-    {
-        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
-        {
+    public R<String> save(UserEntity user) {
+        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
             return R.fail("用户ID不能为空");
         }
         users.put(user.getUserId(), user);
@@ -81,14 +75,11 @@ public class TestController extends BaseController
 
     @ApiOperation("更新用户")
     @PutMapping("/update")
-    public R<String> update(@RequestBody UserEntity user)
-    {
-        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
-        {
+    public R<String> update(@RequestBody UserEntity user) {
+        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
             return R.fail("用户ID不能为空");
         }
-        if (users.isEmpty() || !users.containsKey(user.getUserId()))
-        {
+        if (users.isEmpty() || !users.containsKey(user.getUserId())) {
             return R.fail("用户不存在");
         }
         users.remove(user.getUserId());
@@ -99,23 +90,18 @@ public class TestController extends BaseController
     @ApiOperation("删除用户信息")
     @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
     @DeleteMapping("/{userId}")
-    public R<String> delete(@PathVariable Integer userId)
-    {
-        if (!users.isEmpty() && users.containsKey(userId))
-        {
+    public R<String> delete(@PathVariable Integer userId) {
+        if (!users.isEmpty() && users.containsKey(userId)) {
             users.remove(userId);
             return R.ok();
-        }
-        else
-        {
+        } else {
             return R.fail("用户不存在");
         }
     }
 }
 
 @ApiModel(value = "UserEntity", description = "用户实体")
-class UserEntity
-{
+class UserEntity {
     @ApiModelProperty("用户ID")
     private Integer userId;
 
@@ -128,56 +114,46 @@ class UserEntity
     @ApiModelProperty("用户手机")
     private String mobile;
 
-    public UserEntity()
-    {
+    public UserEntity() {
 
     }
 
-    public UserEntity(Integer userId, String username, String password, String mobile)
-    {
+    public UserEntity(Integer userId, String username, String password, String mobile) {
         this.userId = userId;
         this.username = username;
         this.password = password;
         this.mobile = mobile;
     }
 
-    public Integer getUserId()
-    {
+    public Integer getUserId() {
         return userId;
     }
 
-    public void setUserId(Integer userId)
-    {
+    public void setUserId(Integer userId) {
         this.userId = userId;
     }
 
-    public String getUsername()
-    {
+    public String getUsername() {
         return username;
     }
 
-    public void setUsername(String username)
-    {
+    public void setUsername(String username) {
         this.username = username;
     }
 
-    public String getPassword()
-    {
+    public String getPassword() {
         return password;
     }
 
-    public void setPassword(String password)
-    {
+    public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getMobile()
-    {
+    public String getMobile() {
         return mobile;
     }
 
-    public void setMobile(String mobile)
-    {
+    public void setMobile(String mobile) {
         this.mobile = mobile;
     }
 }

+ 64 - 0
doc-admin/src/main/java/com/doc/web/vo/UserVO.java

@@ -0,0 +1,64 @@
+package com.doc.web.vo;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.doc.common.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 用户树
+ *
+ * @author wukai
+ * @date 2023/8/30 17:00
+ */
+@Data
+@ApiModel(value = "UserVO", description = "用户信息")
+public class UserVO {
+    private static final long serialVersionUID = 1L;
+
+    /** 用户ID */
+    @ApiModelProperty("用户ID")
+    @TableId
+    private Long userId;
+
+    /** 部门ID */
+    @ApiModelProperty("部门ID")
+    private Long deptId;
+
+    /** 用户账号 */
+    @ApiModelProperty("用户账号")
+    private String userName;
+
+    /** 用户昵称 */
+    @ApiModelProperty("用户昵称")
+    private String nickName;
+
+    /** 用户邮箱 */
+    @ApiModelProperty("用户邮箱")
+    @Excel(name = "用户邮箱")
+    private String email;
+
+    /** 手机号码 */
+    @ApiModelProperty("手机号码")
+    @Excel(name = "手机号码")
+    private String phonenumber;
+
+    /** 用户性别(0男 1女 2未知) */
+    @ApiModelProperty("用户性别(0男 1女 2未知)")
+    private String sex;
+
+    /** 头像地址 */
+    @ApiModelProperty("头像地址")
+    private String avatar;
+
+    /** 最后登录时间 */
+    @ApiModelProperty("最后登录时间")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date loginDate;
+
+}

+ 109 - 0
doc-admin/src/main/resources/application-aliyun.yml

@@ -0,0 +1,109 @@
+# 开发环境配置
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 8080
+# 项目相关配置
+ruoyi:
+  # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
+  profile: D:/ruoyi/uploadPath
+# Spring配置
+spring:
+  #es配置
+  elasticsearch:
+    rest:
+      uris: http://8.142.173.95:19200
+  #mongodb配置
+  data:
+    mongodb:
+      host: 8.142.173.95
+      port: 27017
+      database: document
+
+  # redis 配置
+  redis:
+    # 地址
+    host: 192.168.188.88
+    # 端口,默认为6379
+    port: 6379
+    # 数据库索引
+    database: 0
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+  #数据源配置
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://8.142.173.95:3306/doc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: 2096094ba37529f2
+      # 从库数据源
+      slave:
+        # 从数据源开关/默认关闭
+        enabled: false
+        url:
+        username:
+        password:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置连接超时时间
+      connectTimeout: 30000
+      # 配置网络超时时间
+      socketTimeout: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: admin
+        login-password: admin
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+
+# 日志配置
+logging:
+  level:
+    com.doc: debug
+    org.springframework: warn

+ 3 - 3
doc-admin/src/main/resources/application-dev.yml

@@ -11,7 +11,7 @@ spring:
   #es配置
   elasticsearch:
     rest:
-      uris: http://192.168.188.188:19200
+      uris: http://192.168.188.88:19200
   #mongodb配置
   data:
     mongodb:
@@ -48,9 +48,9 @@ spring:
     druid:
       # 主库数据源
       master:
-        url: jdbc:mysql://8.142.173.95:3306/doc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://192.168.188.88:3306/doc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
-        password: 2096094ba37529f2
+        password: 123456
       # 从库数据源
       slave:
         # 从数据源开关/默认关闭

+ 1 - 1
doc-admin/src/main/resources/application.yml

@@ -36,7 +36,7 @@ spring:
     # 国际化资源文件路径
     basename: i18n/messages
   profiles:
-    active: dev
+    active: aliyun
   # 文件上传
   servlet:
     multipart: