From 52ff5485cfc5996448dd71ba8254f00973efbce0 Mon Sep 17 00:00:00 2001 From: "mingxing.ai" Date: Sun, 27 Aug 2023 15:32:27 +0800 Subject: [PATCH] init --- pom.xml | 5 + ruoyi-api/pom.xml | 1 + ruoyi-api/ruoyi-api-client/pom.xml | 30 ++++ .../ruoyi/client/RemoteClientUserService.java | 13 ++ .../com/ruoyi/client/domain/ClientUser.java | 149 +++++++++++++++++ .../RemoteClientUserFallbackFactory.java | 23 +++ .../com/ruoyi/client/model/LoginUser.java | 151 +++++++++++++++++ ruoyi-auth/pom.xml | 6 +- .../controller/ClientTokenController.java | 32 ++++ ...roller.java => SystemTokenController.java} | 156 +++++++++--------- .../auth/service/ClientLoginService.java | 26 +++ ruoyi-common/ruoyi-common-security/pom.xml | 4 + .../controller/ClientUserController.java | 1 + .../controller/ClientUserController.java | 105 ++++++++++++ .../com/ruoyi/client/domain/ClientUser.java | 152 +++++++++++++++++ .../ruoyi/client/mapper/ClientUserMapper.java | 61 +++++++ .../client/service/IClientUserService.java | 61 +++++++ .../service/impl/ClientUserServiceImpl.java | 96 +++++++++++ .../mapper/client/ClientUserMapper.xml | 106 ++++++++++++ 19 files changed, 1099 insertions(+), 79 deletions(-) create mode 100644 ruoyi-api/ruoyi-api-client/pom.xml create mode 100644 ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/RemoteClientUserService.java create mode 100644 ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/domain/ClientUser.java create mode 100644 ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/factory/RemoteClientUserFallbackFactory.java create mode 100644 ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/model/LoginUser.java create mode 100644 ruoyi-auth/src/main/java/com/ruoyi/auth/controller/ClientTokenController.java rename ruoyi-auth/src/main/java/com/ruoyi/auth/controller/{TokenController.java => SystemTokenController.java} (95%) create mode 100644 ruoyi-auth/src/main/java/com/ruoyi/auth/service/ClientLoginService.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/controller/ClientUserController.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/domain/ClientUser.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/mapper/ClientUserMapper.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/IClientUserService.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/impl/ClientUserServiceImpl.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/resources/mapper/client/ClientUserMapper.xml diff --git a/pom.xml b/pom.xml index 437e2ef78..0190c5bcc 100644 --- a/pom.xml +++ b/pom.xml @@ -205,6 +205,11 @@ ruoyi-api-system ${ruoyi.version} + + com.ruoyi + ruoyi-api-client + ${ruoyi.version} + diff --git a/ruoyi-api/pom.xml b/ruoyi-api/pom.xml index 127263051..9723c11d6 100644 --- a/ruoyi-api/pom.xml +++ b/ruoyi-api/pom.xml @@ -11,6 +11,7 @@ ruoyi-api-system ruoyi-api-market + ruoyi-api-client ruoyi-api diff --git a/ruoyi-api/ruoyi-api-client/pom.xml b/ruoyi-api/ruoyi-api-client/pom.xml new file mode 100644 index 000000000..acf1b12d9 --- /dev/null +++ b/ruoyi-api/ruoyi-api-client/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.ruoyi + ruoyi-api + 3.6.3 + + + ruoyi-api-client + + + 8 + 8 + UTF-8 + + + + + + + com.ruoyi + ruoyi-common-core + + + + + \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/RemoteClientUserService.java b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/RemoteClientUserService.java new file mode 100644 index 000000000..7e9ccf2ce --- /dev/null +++ b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/RemoteClientUserService.java @@ -0,0 +1,13 @@ +package com.ruoyi.client; + +import com.ruoyi.client.factory.RemoteClientUserFallbackFactory; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import org.springframework.cloud.openfeign.FeignClient; + +@FeignClient(contextId = "remoteClientUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteClientUserFallbackFactory.class) + +public interface RemoteClientUserService { + + + +} diff --git a/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/domain/ClientUser.java b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/domain/ClientUser.java new file mode 100644 index 000000000..fe358307c --- /dev/null +++ b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/domain/ClientUser.java @@ -0,0 +1,149 @@ +package com.ruoyi.client.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 账户信息对象 client_user + * + * @author ruoyi + * @date 2023-08-13 + */ +public class ClientUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 用户id */ + private Long userId; + + /** 用户名 */ + @Excel(name = "用户名") + private String userName; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickName; + + /** 邮箱 */ + @Excel(name = "邮箱") + private String email; + + /** 电话号码 */ + @Excel(name = "电话号码") + private String phonenumber; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 密码 */ + @Excel(name = "密码") + private String password; + + /** 状态 */ + @Excel(name = "状态") + private Long status; + + /** 删除标识 */ + private Long delFlag; + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getUserName() + { + return userName; + } + public void setNickName(String nickName) + { + this.nickName = nickName; + } + + public String getNickName() + { + return nickName; + } + public void setEmail(String email) + { + this.email = email; + } + + public String getEmail() + { + return email; + } + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getPhonenumber() + { + return phonenumber; + } + public void setAvatar(String avatar) + { + this.avatar = avatar; + } + + public String getAvatar() + { + return avatar; + } + public void setPassword(String password) + { + this.password = password; + } + + public String getPassword() + { + return password; + } + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } + public void setDelFlag(Long delFlag) + { + this.delFlag = delFlag; + } + + public Long getDelFlag() + { + return delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .toString(); + } +} diff --git a/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/factory/RemoteClientUserFallbackFactory.java b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/factory/RemoteClientUserFallbackFactory.java new file mode 100644 index 000000000..427473cbd --- /dev/null +++ b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/factory/RemoteClientUserFallbackFactory.java @@ -0,0 +1,23 @@ +package com.ruoyi.client.factory; + +import com.ruoyi.client.RemoteClientUserService; +import com.ruoyi.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +@Component +public class RemoteClientUserFallbackFactory implements FallbackFactory { + + private final static Logger log = LoggerFactory.getLogger(RemoteClientUserFallbackFactory.class); + + @Override + public RemoteClientUserService create(Throwable cause) { + log.error("用户服务调用失败:{}", cause.getMessage()); + return new RemoteClientUserService() + { + }; + } + +} diff --git a/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/model/LoginUser.java b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/model/LoginUser.java new file mode 100644 index 000000000..bb89b29dc --- /dev/null +++ b/ruoyi-api/ruoyi-api-client/src/main/java/com/ruoyi/client/model/LoginUser.java @@ -0,0 +1,151 @@ +package com.ruoyi.client.model; + +import com.ruoyi.client.domain.ClientUser; + +import java.io.Serializable; +import java.util.Set; + +/** + * 用户信息 + * + * @author ruoyi + */ +public class LoginUser implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * 用户唯一标识 + */ + private String token; + + /** + * 用户名id + */ + private Long userid; + + /** + * 用户名 + */ + private String username; + + /** + * 登录时间 + */ + private Long loginTime; + + /** + * 过期时间 + */ + private Long expireTime; + + /** + * 登录IP地址 + */ + private String ipaddr; + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 角色列表 + */ + private Set roles; + + /** + * 用户信息 + */ + private ClientUser sysUser; + + public String getToken() + { + return token; + } + + public void setToken(String token) + { + this.token = token; + } + + public Long getUserid() + { + return userid; + } + + public void setUserid(Long userid) + { + this.userid = userid; + } + + public String getUsername() + { + return username; + } + + public void setUsername(String username) + { + this.username = username; + } + + public Long getLoginTime() + { + return loginTime; + } + + public void setLoginTime(Long loginTime) + { + this.loginTime = loginTime; + } + + public Long getExpireTime() + { + return expireTime; + } + + public void setExpireTime(Long expireTime) + { + this.expireTime = expireTime; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public Set getPermissions() + { + return permissions; + } + + public void setPermissions(Set permissions) + { + this.permissions = permissions; + } + + public Set getRoles() + { + return roles; + } + + public void setRoles(Set roles) + { + this.roles = roles; + } + + public ClientUser getSysUser() + { + return sysUser; + } + + public void setSysUser(ClientUser sysUser) + { + this.sysUser = sysUser; + } +} diff --git a/ruoyi-auth/pom.xml b/ruoyi-auth/pom.xml index bb5fb16fa..40280c071 100644 --- a/ruoyi-auth/pom.xml +++ b/ruoyi-auth/pom.xml @@ -51,7 +51,11 @@ com.ruoyi ruoyi-common-security - + + com.ruoyi + ruoyi-common-core + + diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/ClientTokenController.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/ClientTokenController.java new file mode 100644 index 000000000..7b959b948 --- /dev/null +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/ClientTokenController.java @@ -0,0 +1,32 @@ +package com.ruoyi.auth.controller; + +import com.ruoyi.auth.form.LoginBody; +import com.ruoyi.auth.service.ClientLoginService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.annotation.Resource; + +@RequestMapping("/client") +public class ClientTokenController { + + @Resource + private TokenService tokenService; + + @Resource + private ClientLoginService clientLoginService; + + @PostMapping("login") + public R login(@RequestBody LoginBody form) { + + // 用户登录 + LoginUser userInfo = clientLoginService.login(form.getUsername(), form.getPassword()); + // 获取登录token + return R.ok(tokenService.createToken(userInfo)); + } + +} diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/SystemTokenController.java similarity index 95% rename from ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java rename to ruoyi-auth/src/main/java/com/ruoyi/auth/controller/SystemTokenController.java index 3b93514ed..d4e3decb7 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/SystemTokenController.java @@ -1,78 +1,78 @@ -package com.ruoyi.auth.controller; - -import javax.servlet.http.HttpServletRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.auth.form.LoginBody; -import com.ruoyi.auth.form.RegisterBody; -import com.ruoyi.auth.service.SysLoginService; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.common.core.utils.JwtUtils; -import com.ruoyi.common.core.utils.StringUtils; -import com.ruoyi.common.security.auth.AuthUtil; -import com.ruoyi.common.security.service.TokenService; -import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.api.model.LoginUser; - -/** - * token 控制 - * - * @author ruoyi - */ -@RestController -public class TokenController -{ - @Autowired - private TokenService tokenService; - - @Autowired - private SysLoginService sysLoginService; - - @PostMapping("login") - public R login(@RequestBody LoginBody form) - { - // 用户登录 - LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); - // 获取登录token - return R.ok(tokenService.createToken(userInfo)); - } - - @DeleteMapping("logout") - public R logout(HttpServletRequest request) - { - String token = SecurityUtils.getToken(request); - if (StringUtils.isNotEmpty(token)) - { - String username = JwtUtils.getUserName(token); - // 删除用户缓存记录 - AuthUtil.logoutByToken(token); - // 记录用户退出日志 - sysLoginService.logout(username); - } - return R.ok(); - } - - @PostMapping("refresh") - public R refresh(HttpServletRequest request) - { - LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser)) - { - // 刷新令牌有效期 - tokenService.refreshToken(loginUser); - return R.ok(); - } - return R.ok(); - } - - @PostMapping("register") - public R register(@RequestBody RegisterBody registerBody) - { - // 用户注册 - sysLoginService.register(registerBody.getUsername(), registerBody.getPassword()); - return R.ok(); - } -} +package com.ruoyi.auth.controller; + +import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.auth.form.LoginBody; +import com.ruoyi.auth.form.RegisterBody; +import com.ruoyi.auth.service.SysLoginService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.JwtUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.security.auth.AuthUtil; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.model.LoginUser; + +/** + * token 控制 + * + * @author ruoyi + */ +@RestController +public class SystemTokenController +{ + @Autowired + private TokenService tokenService; + + @Autowired + private SysLoginService sysLoginService; + + @PostMapping("login") + public R login(@RequestBody LoginBody form) + { + // 用户登录 + LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); + // 获取登录token + return R.ok(tokenService.createToken(userInfo)); + } + + @DeleteMapping("logout") + public R logout(HttpServletRequest request) + { + String token = SecurityUtils.getToken(request); + if (StringUtils.isNotEmpty(token)) + { + String username = JwtUtils.getUserName(token); + // 删除用户缓存记录 + AuthUtil.logoutByToken(token); + // 记录用户退出日志 + sysLoginService.logout(username); + } + return R.ok(); + } + + @PostMapping("refresh") + public R refresh(HttpServletRequest request) + { + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser)) + { + // 刷新令牌有效期 + tokenService.refreshToken(loginUser); + return R.ok(); + } + return R.ok(); + } + + @PostMapping("register") + public R register(@RequestBody RegisterBody registerBody) + { + // 用户注册 + sysLoginService.register(registerBody.getUsername(), registerBody.getPassword()); + return R.ok(); + } +} diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/ClientLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/ClientLoginService.java new file mode 100644 index 000000000..89ee25bc9 --- /dev/null +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/ClientLoginService.java @@ -0,0 +1,26 @@ +package com.ruoyi.auth.service; + +import com.ruoyi.system.api.RemoteClientService; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class ClientLoginService { + + @Resource + private RemoteClientService remoteClientService; + + /** + * 用户登录 + * @param username + * @param password + * @return + */ + public LoginUser login(String username, String password) { + + return null; + } + +} diff --git a/ruoyi-common/ruoyi-common-security/pom.xml b/ruoyi-common/ruoyi-common-security/pom.xml index c78382244..008de0728 100644 --- a/ruoyi-common/ruoyi-common-security/pom.xml +++ b/ruoyi-common/ruoyi-common-security/pom.xml @@ -28,6 +28,10 @@ ruoyi-api-system + + com.ruoyi + ruoyi-api-client + com.ruoyi diff --git a/ruoyi-modules/ruoyi-client/src/main/java/com/ruoyi/client/controller/ClientUserController.java b/ruoyi-modules/ruoyi-client/src/main/java/com/ruoyi/client/controller/ClientUserController.java index 6b13fcb87..bc34c0981 100644 --- a/ruoyi-modules/ruoyi-client/src/main/java/com/ruoyi/client/controller/ClientUserController.java +++ b/ruoyi-modules/ruoyi-client/src/main/java/com/ruoyi/client/controller/ClientUserController.java @@ -102,4 +102,5 @@ public AjaxResult remove(@PathVariable Long[] userIds) { return toAjax(clientUserService.deleteClientUserByUserIds(userIds)); } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/controller/ClientUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/controller/ClientUserController.java new file mode 100644 index 000000000..acb098d84 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/controller/ClientUserController.java @@ -0,0 +1,105 @@ +package com.ruoyi.client.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.client.domain.ClientUser; +import com.ruoyi.client.service.IClientUserService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 账户信息Controller + * + * @author ruoyi + * @date 2023-08-26 + */ +@RestController +@RequestMapping("/user") +public class ClientUserController extends BaseController +{ + @Autowired + private IClientUserService clientUserService; + + /** + * 查询账户信息列表 + */ + @RequiresPermissions("client:user:list") + @GetMapping("/list") + public TableDataInfo list(ClientUser clientUser) + { + startPage(); + List list = clientUserService.selectClientUserList(clientUser); + return getDataTable(list); + } + + /** + * 导出账户信息列表 + */ + @RequiresPermissions("client:user:export") + @Log(title = "账户信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ClientUser clientUser) + { + List list = clientUserService.selectClientUserList(clientUser); + ExcelUtil util = new ExcelUtil(ClientUser.class); + util.exportExcel(response, list, "账户信息数据"); + } + + /** + * 获取账户信息详细信息 + */ + @RequiresPermissions("client:user:query") + @GetMapping(value = "/{userId}") + public AjaxResult getInfo(@PathVariable("userId") Long userId) + { + return success(clientUserService.selectClientUserByUserId(userId)); + } + + /** + * 新增账户信息 + */ + @RequiresPermissions("client:user:add") + @Log(title = "账户信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ClientUser clientUser) + { + return toAjax(clientUserService.insertClientUser(clientUser)); + } + + /** + * 修改账户信息 + */ + @RequiresPermissions("client:user:edit") + @Log(title = "账户信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ClientUser clientUser) + { + return toAjax(clientUserService.updateClientUser(clientUser)); + } + + /** + * 删除账户信息 + */ + @RequiresPermissions("client:user:remove") + @Log(title = "账户信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{userIds}") + public AjaxResult remove(@PathVariable Long[] userIds) + { + return toAjax(clientUserService.deleteClientUserByUserIds(userIds)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/domain/ClientUser.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/domain/ClientUser.java new file mode 100644 index 000000000..604b437a3 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/domain/ClientUser.java @@ -0,0 +1,152 @@ +package com.ruoyi.client.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 账户信息对象 client_user + * + * @author ruoyi + * @date 2023-08-26 + */ +public class ClientUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 用户id */ + private Long userId; + + /** 用户名 */ + @Excel(name = "用户名") + private String userName; + + /** 昵称 */ + @Excel(name = "昵称") + private String nickName; + + /** 邮箱 */ + @Excel(name = "邮箱") + private String email; + + /** 电话号码 */ + @Excel(name = "电话号码") + private String phonenumber; + + /** 头像 */ + @Excel(name = "头像") + private String avatar; + + /** 密码 */ + @Excel(name = "密码") + private String password; + + /** 状态 */ + @Excel(name = "状态") + private Long status; + + /** 删除标识 */ + private Long delFlag; + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getUserName() + { + return userName; + } + public void setNickName(String nickName) + { + this.nickName = nickName; + } + + public String getNickName() + { + return nickName; + } + public void setEmail(String email) + { + this.email = email; + } + + public String getEmail() + { + return email; + } + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getPhonenumber() + { + return phonenumber; + } + public void setAvatar(String avatar) + { + this.avatar = avatar; + } + + public String getAvatar() + { + return avatar; + } + public void setPassword(String password) + { + this.password = password; + } + + public String getPassword() + { + return password; + } + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } + public void setDelFlag(Long delFlag) + { + this.delFlag = delFlag; + } + + public Long getDelFlag() + { + return delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("userName", getUserName()) + .append("nickName", getNickName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/mapper/ClientUserMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/mapper/ClientUserMapper.java new file mode 100644 index 000000000..045fcf6f5 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/mapper/ClientUserMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.client.mapper; + +import java.util.List; +import com.ruoyi.client.domain.ClientUser; + +/** + * 账户信息Mapper接口 + * + * @author ruoyi + * @date 2023-08-26 + */ +public interface ClientUserMapper +{ + /** + * 查询账户信息 + * + * @param userId 账户信息主键 + * @return 账户信息 + */ + public ClientUser selectClientUserByUserId(Long userId); + + /** + * 查询账户信息列表 + * + * @param clientUser 账户信息 + * @return 账户信息集合 + */ + public List selectClientUserList(ClientUser clientUser); + + /** + * 新增账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + public int insertClientUser(ClientUser clientUser); + + /** + * 修改账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + public int updateClientUser(ClientUser clientUser); + + /** + * 删除账户信息 + * + * @param userId 账户信息主键 + * @return 结果 + */ + public int deleteClientUserByUserId(Long userId); + + /** + * 批量删除账户信息 + * + * @param userIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteClientUserByUserIds(Long[] userIds); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/IClientUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/IClientUserService.java new file mode 100644 index 000000000..74958e1f9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/IClientUserService.java @@ -0,0 +1,61 @@ +package com.ruoyi.client.service; + +import java.util.List; +import com.ruoyi.client.domain.ClientUser; + +/** + * 账户信息Service接口 + * + * @author ruoyi + * @date 2023-08-26 + */ +public interface IClientUserService +{ + /** + * 查询账户信息 + * + * @param userId 账户信息主键 + * @return 账户信息 + */ + public ClientUser selectClientUserByUserId(Long userId); + + /** + * 查询账户信息列表 + * + * @param clientUser 账户信息 + * @return 账户信息集合 + */ + public List selectClientUserList(ClientUser clientUser); + + /** + * 新增账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + public int insertClientUser(ClientUser clientUser); + + /** + * 修改账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + public int updateClientUser(ClientUser clientUser); + + /** + * 批量删除账户信息 + * + * @param userIds 需要删除的账户信息主键集合 + * @return 结果 + */ + public int deleteClientUserByUserIds(Long[] userIds); + + /** + * 删除账户信息信息 + * + * @param userId 账户信息主键 + * @return 结果 + */ + public int deleteClientUserByUserId(Long userId); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/impl/ClientUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/impl/ClientUserServiceImpl.java new file mode 100644 index 000000000..8284e5f6d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/client/service/impl/ClientUserServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.client.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.client.mapper.ClientUserMapper; +import com.ruoyi.client.domain.ClientUser; +import com.ruoyi.client.service.IClientUserService; + +/** + * 账户信息Service业务层处理 + * + * @author ruoyi + * @date 2023-08-26 + */ +@Service +public class ClientUserServiceImpl implements IClientUserService +{ + @Autowired + private ClientUserMapper clientUserMapper; + + /** + * 查询账户信息 + * + * @param userId 账户信息主键 + * @return 账户信息 + */ + @Override + public ClientUser selectClientUserByUserId(Long userId) + { + return clientUserMapper.selectClientUserByUserId(userId); + } + + /** + * 查询账户信息列表 + * + * @param clientUser 账户信息 + * @return 账户信息 + */ + @Override + public List selectClientUserList(ClientUser clientUser) + { + return clientUserMapper.selectClientUserList(clientUser); + } + + /** + * 新增账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + @Override + public int insertClientUser(ClientUser clientUser) + { + clientUser.setCreateTime(DateUtils.getNowDate()); + return clientUserMapper.insertClientUser(clientUser); + } + + /** + * 修改账户信息 + * + * @param clientUser 账户信息 + * @return 结果 + */ + @Override + public int updateClientUser(ClientUser clientUser) + { + clientUser.setUpdateTime(DateUtils.getNowDate()); + return clientUserMapper.updateClientUser(clientUser); + } + + /** + * 批量删除账户信息 + * + * @param userIds 需要删除的账户信息主键 + * @return 结果 + */ + @Override + public int deleteClientUserByUserIds(Long[] userIds) + { + return clientUserMapper.deleteClientUserByUserIds(userIds); + } + + /** + * 删除账户信息信息 + * + * @param userId 账户信息主键 + * @return 结果 + */ + @Override + public int deleteClientUserByUserId(Long userId) + { + return clientUserMapper.deleteClientUserByUserId(userId); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/client/ClientUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/client/ClientUserMapper.xml new file mode 100644 index 000000000..9e9d61be8 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/client/ClientUserMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + select user_id, user_name, nick_name, email, phonenumber, avatar, password, status, del_flag, create_time, create_by, update_time, update_by from client_user + + + + + + + + insert into client_user + + user_name, + nick_name, + email, + phonenumber, + avatar, + password, + status, + del_flag, + create_time, + create_by, + update_time, + update_by, + + + #{userName}, + #{nickName}, + #{email}, + #{phonenumber}, + #{avatar}, + #{password}, + #{status}, + #{delFlag}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{updateBy}, + + + + + update client_user + + user_name = #{userName}, + nick_name = #{nickName}, + email = #{email}, + phonenumber = #{phonenumber}, + avatar = #{avatar}, + password = #{password}, + status = #{status}, + del_flag = #{delFlag}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + + where user_id = #{userId} + + + + delete from client_user where user_id = #{userId} + + + + delete from client_user where user_id in + + #{userId} + + + \ No newline at end of file