新建
This commit is contained in:
109
jxy-modules/jxy-system/pom.xml
Normal file
109
jxy-modules/jxy-system/pom.xml
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jxy-modules</artifactId>
|
||||
<groupId>com.jxy</groupId>
|
||||
<version>3.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jxy-system</artifactId>
|
||||
|
||||
<description>
|
||||
jxy-system系统模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JXY Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.jxy</groupId>
|
||||
<artifactId>common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JXY Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.jxy</groupId>
|
||||
<artifactId>common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- JXY Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.jxy</groupId>
|
||||
<artifactId>common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JXY Common swagger -->
|
||||
<dependency>
|
||||
<groupId>com.jxy</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.jxy.system;
|
||||
|
||||
import com.jxy.common.security.annotation.EnableCustomConfig;
|
||||
import com.jxy.common.security.annotation.EnableJXYFeignClients;
|
||||
import com.jxy.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Description 系统模块启动类
|
||||
* @Date 2022/5/17 13:13
|
||||
* @Author 杜懿
|
||||
*/
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableJXYFeignClients
|
||||
@SpringBootApplication
|
||||
public class JXYSystemApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplication.run(JXYSystemApplication.class);
|
||||
System.out.println("jxy-system启动成功");
|
||||
}catch (Exception e){
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.jxy.system.controller;
|
||||
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.core.web.controller.BaseController;
|
||||
import com.jxy.system.entity.StrategyLoginBody;
|
||||
import com.jxy.system.entity.StrategyResetPwdBody;
|
||||
import com.jxy.system.service.StrategyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:29
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/strategy")
|
||||
public class StrategyController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private StrategyService strategyService;
|
||||
|
||||
@PostMapping("login")
|
||||
public AjaxResult login(@RequestBody StrategyLoginBody loginBody, @RequestHeader("User-Agent") String userAgent)
|
||||
{
|
||||
return strategyService.login(loginBody);
|
||||
}
|
||||
|
||||
@PostMapping("resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody @Valid StrategyResetPwdBody resetPwdBody)
|
||||
{
|
||||
return strategyService.resetPwd(resetPwdBody);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jxy.system.controller;
|
||||
|
||||
import com.jxy.common.core.utils.poi.ExcelUtil;
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.core.web.controller.BaseController;
|
||||
import com.jxy.common.core.web.page.TableDataInfo;
|
||||
import com.jxy.common.log.annotation.Log;
|
||||
import com.jxy.common.log.enums.BusinessType;
|
||||
import com.jxy.common.security.annotation.InnerAuth;
|
||||
import com.jxy.common.security.annotation.RequiresPermissions;
|
||||
import com.jxy.system.api.entity.SysLogininfor;
|
||||
import com.jxy.system.service.SysLogininforService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/logininfor")
|
||||
public class SysLogininforController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private SysLogininforService logininforService;
|
||||
|
||||
@RequiresPermissions("system:logininfor:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLogininfor logininfor)
|
||||
{
|
||||
startPage();
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:logininfor:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysLogininfor logininfor)
|
||||
{
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
util.exportExcel(response, list, "登录日志");
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||
{
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
logininforService.cleanLogininfor();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysLogininfor logininfor)
|
||||
{
|
||||
return toAjax(logininforService.insertLogininfor(logininfor));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jxy.system.controller;
|
||||
|
||||
|
||||
import com.jxy.common.core.utils.poi.ExcelUtil;
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.core.web.controller.BaseController;
|
||||
import com.jxy.common.core.web.page.TableDataInfo;
|
||||
import com.jxy.common.log.annotation.Log;
|
||||
import com.jxy.common.log.enums.BusinessType;
|
||||
import com.jxy.common.security.annotation.InnerAuth;
|
||||
import com.jxy.common.security.annotation.RequiresPermissions;
|
||||
import com.jxy.system.api.entity.SysOperLog;
|
||||
import com.jxy.system.service.SysOperLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/operlog")
|
||||
public class SysOperlogController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private SysOperLogService operLogService;
|
||||
|
||||
@RequiresPermissions("system:operlog:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog)
|
||||
{
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:operlog:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysOperLog operLog)
|
||||
{
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
util.exportExcel(response, list, "操作日志");
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@RequiresPermissions("system:operlog:remove")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||
{
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:operlog:remove")
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
operLogService.cleanOperLog();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysOperLog operLog)
|
||||
{
|
||||
return toAjax(operLogService.insertOperlog(operLog));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.jxy.system.controller;
|
||||
|
||||
import com.jxy.common.core.Result.R;
|
||||
import com.jxy.common.core.constant.UserConstants;
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.core.web.controller.BaseController;
|
||||
|
||||
import com.jxy.common.security.annotation.InnerAuth;
|
||||
import com.jxy.common.security.annotation.RequiresLogin;
|
||||
import com.jxy.common.security.service.TokenService;
|
||||
import com.jxy.common.security.utils.SecurityUtils;
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import com.jxy.system.api.entity.SysUserLeveDate;
|
||||
import com.jxy.system.api.model.LoginUser;
|
||||
import com.jxy.system.entity.SysRoleDto;
|
||||
import com.jxy.system.entity.SysUserDto;
|
||||
import com.jxy.system.mapper.SysUserLevelMapper;
|
||||
import com.jxy.system.mapper.SysUserRoleMapper;
|
||||
import com.jxy.system.service.SysRoleService;
|
||||
import com.jxy.system.service.SysUserService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/profile")
|
||||
public class SysProfileController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserLevelMapper userLevelMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public AjaxResult profile()
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
|
||||
//隐藏不需要返回前端的信息
|
||||
SysUserDto userDto = new SysUserDto();
|
||||
SysRoleDto roleDto = new SysRoleDto();
|
||||
|
||||
BeanUtils.copyProperties(user,userDto);
|
||||
|
||||
if (StringUtils.isNull(user.getRoles()) || user.getRoles().size() < 1)
|
||||
{
|
||||
//todo 动态获取注册用户信息
|
||||
roleDto.setRoleId(2L);
|
||||
roleDto.setRoleKey("registered");
|
||||
roleDto.setRoleName("L2");
|
||||
roleDto.setLevel("L2");
|
||||
}else {
|
||||
SysRole sysRole = user.getRoles().get(0);
|
||||
BeanUtils.copyProperties(sysRole,roleDto);
|
||||
if (sysRole.getRoleId() == 1L) {
|
||||
roleDto.setLevel("admin");
|
||||
} else if (sysRole.getRoleId() == 2L) {
|
||||
roleDto.setLevel("L2");
|
||||
} else if (sysRole.getRoleId() == 3L) {
|
||||
roleDto.setLevel("L3");
|
||||
|
||||
//此时角色是L3 说明应该在会员有效期
|
||||
SysUserLeveDate userLevelInfo = userLevelMapper.getUserLevelInfo(SecurityUtils.getUserId());
|
||||
if(StringUtils.isNotNull(userLevelInfo)){
|
||||
if(userLevelInfo.getLevelType() == 0){
|
||||
roleDto.setRoleName("月度"+roleDto.getRoleName());
|
||||
}else if(userLevelInfo.getLevelType() == 1){
|
||||
roleDto.setRoleName("年度"+roleDto.getRoleName());
|
||||
}
|
||||
}else {
|
||||
//如果查询不到userLevelInfo 说明用户已过期 修改profit返回的用户等级为L2
|
||||
roleDto.setRoleId(2L);
|
||||
roleDto.setRoleKey("registered");
|
||||
roleDto.setRoleName("L2");
|
||||
roleDto.setLevel("L2");
|
||||
}
|
||||
} else if (sysRole.getRoleId() == 4L) {
|
||||
roleDto.setLevel("L4");
|
||||
}else {
|
||||
roleDto.setLevel(roleDto.getRoleKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userDto.setRole(roleDto);
|
||||
|
||||
//AjaxResult ajax = AjaxResult.success(userDto);
|
||||
|
||||
//ajax.put("roleGroup", userService.selectUserRoleGroup(username));
|
||||
return AjaxResult.success(userDto);
|
||||
}
|
||||
|
||||
@PostMapping("userLevel")
|
||||
public R<SysUserLeveDate> userLevel(@RequestBody() Long userId)
|
||||
{
|
||||
//先看用户是否有会员记录 有才查询
|
||||
System.out.println("调用system接口查询userLevel");
|
||||
System.out.println("用户id:"+userId);
|
||||
SysUserLeveDate info = userLevelMapper.getUserLevelInfo(userId);
|
||||
return R.success(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@PutMapping
|
||||
@ApiOperation(value = "个人信息")
|
||||
@RequiresLogin
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
user.setUserName(sysUser.getUserName());
|
||||
if (StringUtils.isNotEmpty(user.getPhone())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUserId(sysUser.getUserId());
|
||||
user.setPassword(null);
|
||||
if (userService.updateUserProfile(user) > 0)
|
||||
{
|
||||
// 更新缓存用户信息
|
||||
loginUser.getSysUser().setNickName(user.getNickName());
|
||||
loginUser.getSysUser().setPhone(user.getPhone());
|
||||
loginUser.getSysUser().setEmail(user.getEmail());
|
||||
loginUser.getSysUser().setSex(user.getSex());
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码(已知原密码修改为新密码)
|
||||
*/
|
||||
@ApiOperation(value = "重置密码")
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||
{
|
||||
String username = SecurityUtils.getUsername();
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
String password = user.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||
{
|
||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||
{
|
||||
return AjaxResult.error("新密码不能与旧密码相同");
|
||||
}
|
||||
if (userService. resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0)
|
||||
{
|
||||
// 更新缓存用户密码
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码(忘记原密码通过邮箱验证修改为新密码)
|
||||
*/
|
||||
@ApiOperation(value = "重置密码")
|
||||
@PostMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user){
|
||||
if(userService.resetPwdByEmail(user.getEmail(),user.getPassword()) > 0){
|
||||
//
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户升级
|
||||
*/
|
||||
@PostMapping("/Levelup")
|
||||
@ApiOperation(value = "用户升级")
|
||||
@InnerAuth
|
||||
public AjaxResult LevelUp(@RequestBody SysUserLeveDate user)
|
||||
{
|
||||
Long roleId = user.getRoleId();
|
||||
if(roleId == 1 || roleId > 4){
|
||||
return AjaxResult.success("流程最后一步修改用户等级,admin等内部账户不会更改等级");
|
||||
}
|
||||
|
||||
if (userService.userLevelUp(user) > 0)
|
||||
{
|
||||
return AjaxResult.success("用户已升级");
|
||||
}
|
||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package com.jxy.system.controller;
|
||||
|
||||
import com.jxy.common.core.Result.R;
|
||||
import com.jxy.common.core.constant.UserConstants;
|
||||
import com.jxy.common.core.utils.DateUtils;
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.core.web.controller.BaseController;
|
||||
import com.jxy.common.log.annotation.Log;
|
||||
import com.jxy.common.log.enums.BusinessType;
|
||||
import com.jxy.common.security.annotation.InnerAuth;
|
||||
import com.jxy.common.security.annotation.RequiresPermissions;
|
||||
import com.jxy.common.security.utils.SecurityUtils;
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import com.jxy.system.api.model.LoginUser;
|
||||
import com.jxy.system.service.SysPermissionService;
|
||||
import com.jxy.system.service.SysRoleService;
|
||||
import com.jxy.system.service.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2022/6/14 17:33
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Api(tags = "用户相关接口")
|
||||
public class SysUserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 根据用户名获取当前用户信息
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{account}")
|
||||
@ApiOperation(value = "",response = List.class)
|
||||
public R<LoginUser> info(@PathVariable("account") String account)
|
||||
{
|
||||
String em = "^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
|
||||
|
||||
SysUser user = new SysUser();
|
||||
if(account.matches(em)){
|
||||
user = userService.selectUserByEmail(account);
|
||||
if (StringUtils.isNull(user))
|
||||
{
|
||||
return R.fail("邮箱未被注册");
|
||||
}
|
||||
}else {
|
||||
user = userService.selectUserByUserName(account);
|
||||
if (StringUtils.isNull(user))
|
||||
{
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
}
|
||||
|
||||
List<Long> roleIdList = roleService.selectRoleListByUserId(user.getUserId());
|
||||
Long[] roleIds = roleIdList.toArray(new Long[roleIdList.size()]);
|
||||
user.setRoleIds(roleIds);
|
||||
//if(roleIds.length > 0){
|
||||
// user.setRoleId(roleIds[0]);
|
||||
//}
|
||||
|
||||
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user.getUserId());
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user.getUserId());
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setUserid(user.getUserId());
|
||||
sysUserVo.setUsername(user.getNickName());
|
||||
sysUserVo.setIpaddr(user.getLoginIp());
|
||||
sysUserVo.setSysUser(user);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setPermissions(permissions);
|
||||
return R.success(sysUserVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*/
|
||||
//@InnerAuth
|
||||
@PostMapping("/register")
|
||||
public R<Boolean> register(@RequestBody SysUser sysUser)
|
||||
{
|
||||
String username = sysUser.getUserName();
|
||||
String email = sysUser.getEmail();
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
|
||||
{
|
||||
return R.fail("用户'" + username + "'注册失败,注册账号已存在");
|
||||
}
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(sysUser)))
|
||||
{
|
||||
return R.fail("用户'" + username + "'注册失败,邮箱"+email+"已被其他用户注册");
|
||||
}
|
||||
|
||||
return R.success(userService.registerUser(sysUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户登录次数和最后一次登录的ip
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public AjaxResult update(@RequestBody SysUser user)
|
||||
{
|
||||
//user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (StringUtils.isNotEmpty(user.getPhone())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
List<Long> roleIdList = roleService.selectRoleListByUserId(user.getUserId());
|
||||
Long[] roleIds = roleIdList.toArray(new Long[roleIdList.size()]);
|
||||
user.setRoleIds(roleIds);
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取授权角色
|
||||
*/
|
||||
@RequiresPermissions("system:user:query")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo()
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(userId);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", userService.selectUserById(userId));
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@GetMapping("/checkMail/{email}")
|
||||
public AjaxResult checkMail(@PathVariable("email") String email)
|
||||
{
|
||||
|
||||
String em = "^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
|
||||
if(!email.matches(em)){
|
||||
return AjaxResult.error(300,"邮箱格式错误");
|
||||
}
|
||||
|
||||
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailExist(email)))
|
||||
{
|
||||
return AjaxResult.error(301,"邮箱已被注册");
|
||||
}
|
||||
return AjaxResult.success("邮箱未被注册");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class StrategyLoginBody {
|
||||
|
||||
/** 用户名或邮箱 */
|
||||
private String userName;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class StrategyResetPwdBody {
|
||||
|
||||
/** 用户名或邮箱 */
|
||||
@NotNull
|
||||
private String userName;
|
||||
|
||||
/** 密码 */
|
||||
@NotNull
|
||||
@Length(min = 5,max = 16 ,message = "原密码格式有误,密码位数5-16")
|
||||
private String oldPassword;
|
||||
|
||||
@NotNull
|
||||
@Length(min = 5,max = 16 ,message = "新密码格式有误,密码位数5-16")
|
||||
private String newPassword;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class StrategyUser {
|
||||
|
||||
/** 用户名或邮箱 */
|
||||
private String userName;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 权限 */
|
||||
private String privilege;
|
||||
|
||||
private Date lastLanding;
|
||||
|
||||
private String ownStrategy;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class StrategyUserDto {
|
||||
|
||||
/** 用户名或邮箱 */
|
||||
private String userName;
|
||||
|
||||
/** 权限 */
|
||||
private String privilege;
|
||||
|
||||
private Date lastLanding;
|
||||
|
||||
private String ownStrategy;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import com.jxy.common.core.web.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单权限表 sys_menu
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
@Data
|
||||
public class SysMenu extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 菜单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;
|
||||
|
||||
/** 是否为外链(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<SysMenu> children = new ArrayList<SysMenu>();
|
||||
|
||||
public Long getMenuId()
|
||||
{
|
||||
return menuId;
|
||||
}
|
||||
|
||||
public void setMenuId(Long menuId)
|
||||
{
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
public String getMenuName()
|
||||
{
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName)
|
||||
{
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName)
|
||||
{
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||
public String getComponent()
|
||||
{
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component)
|
||||
{
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query)
|
||||
{
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getIsFrame()
|
||||
{
|
||||
return isFrame;
|
||||
}
|
||||
|
||||
public void setIsFrame(String isFrame)
|
||||
{
|
||||
this.isFrame = isFrame;
|
||||
}
|
||||
|
||||
public String getIsCache()
|
||||
{
|
||||
return isCache;
|
||||
}
|
||||
|
||||
public void setIsCache(String isCache)
|
||||
{
|
||||
this.isCache = isCache;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
public String getMenuType()
|
||||
{
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(String menuType)
|
||||
{
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public String getVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(String visible)
|
||||
{
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||
public String getPerms()
|
||||
{
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms)
|
||||
{
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
public String getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public List<SysMenu> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysMenu> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("menuId", getMenuId())
|
||||
.append("menuName", getMenuName())
|
||||
.append("parentId", getParentId())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("path", getPath())
|
||||
.append("component", getComponent())
|
||||
.append("isFrame", getIsFrame())
|
||||
.append("IsCache", getIsCache())
|
||||
.append("menuType", getMenuType())
|
||||
.append("visible", getVisible())
|
||||
.append("status ", getStatus())
|
||||
.append("perms", getPerms())
|
||||
.append("icon", getIcon())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description 角色部门表实体类
|
||||
* @Date 2022/5/12 10:53
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleDept {
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/4 15:41
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleDto {
|
||||
|
||||
private static final long serialVersionUID = 1941856464L;
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 角色名称 */
|
||||
private String roleName;
|
||||
|
||||
/** 角色权限 */
|
||||
private String roleKey;
|
||||
|
||||
private Date LevelExpireDate;
|
||||
|
||||
private String level;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 角色和菜单关联 sys_role_menu
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
public class SysRoleMenu
|
||||
{
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 菜单ID */
|
||||
private Long menuId;
|
||||
|
||||
public Long getRoleId()
|
||||
{
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId)
|
||||
{
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getMenuId()
|
||||
{
|
||||
return menuId;
|
||||
}
|
||||
|
||||
public void setMenuId(Long menuId)
|
||||
{
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
.append("menuId", getMenuId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/4 15:41
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDto {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 用户账号 */
|
||||
private String userName;
|
||||
|
||||
/** 用户昵称 */
|
||||
private String nickName;
|
||||
|
||||
/** 用户邮箱 */
|
||||
private String email;
|
||||
|
||||
/** 手机号码 */
|
||||
private String phone;
|
||||
|
||||
/** 用户性别 */
|
||||
private String sex;
|
||||
|
||||
/** 帐号状态(0正常 1停用) */
|
||||
//private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
//private String delFlag;
|
||||
|
||||
/** 最后登录IP */
|
||||
private String loginIp;
|
||||
|
||||
/** 登录次数 */
|
||||
private Long loginCount;
|
||||
|
||||
/** 最后登录时间 */
|
||||
private Date loginDate;
|
||||
|
||||
/** 角色对象 */
|
||||
private SysRoleDto role;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description 用户角色中间表实体
|
||||
* @Date 2022/5/12 10:47
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class SysUserRole {
|
||||
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.jxy.system.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/4 15:41
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Data
|
||||
public class UserLevelInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date expireTime;
|
||||
|
||||
/** 会员状态(0正常 1停用) */
|
||||
private int status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
//private String delFlag;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.entity.StrategyUser;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:56
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface StrategyMapper {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public StrategyUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(StrategyUser user);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
|
||||
import com.jxy.system.api.entity.SysLogininfor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 数据层
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
public interface SysLogininforMapper
|
||||
{
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
public int insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
/**
|
||||
* 查询系统登录日志集合
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
* @return 登录记录集合
|
||||
*/
|
||||
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor);
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
* @param infoIds 需要删除的登录日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteLogininforByIds(Long[] infoIds);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int cleanLogininfor();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 角色数据层
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface SysMenuMapper {
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public List<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
|
||||
|
||||
import com.jxy.system.api.entity.SysOperLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 数据层
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
public interface SysOperLogMapper
|
||||
{
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
*/
|
||||
public int insertOperlog(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteOperLogByIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
public SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*/
|
||||
public void cleanOperLog();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 角色数据层
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface SysRoleMapper {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
public List<Long> selectRoleListByUserId(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名查询角色
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolesByUserName(String userName);
|
||||
|
||||
public Long[] getResigesterId();
|
||||
|
||||
public Long[] getVipId();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.entity.SysRoleMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与菜单关联表 数据层
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
public interface SysRoleMenuMapper
|
||||
{
|
||||
/**
|
||||
* 查询菜单使用数量
|
||||
*
|
||||
* @param menuId 菜单ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkMenuExistRole(Long menuId);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色和菜单关联
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleMenuByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色菜单关联信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleMenu(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量新增角色菜单信息
|
||||
*
|
||||
* @param roleMenuList 角色菜单列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchRoleMenu(List<SysRoleMenu> roleMenuList);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.api.entity.SysUserLeveDate;
|
||||
import com.jxy.system.entity.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/5/5 11:33
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface SysUserLevelMapper {
|
||||
|
||||
public SysUserLeveDate getUserLevelInfo(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 批量(逻辑)删除过期用户 根据会员时间表id
|
||||
* @param ids
|
||||
*/
|
||||
public void deleteExpireUserLevelInfo(@Param("ids") List<Long> ids);
|
||||
|
||||
public int deleteUserLevelInfoByUserId(@Param("userId") Long userId);
|
||||
|
||||
public int createUserLevelInfo(@Param("vo") SysUserLeveDate vo);
|
||||
|
||||
/**
|
||||
* 获取过期会员
|
||||
* @return
|
||||
*/
|
||||
public List<Long> getExpireUserIds();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface SysUserMapper {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 手机号码
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkPhoneUnique(String phonenumber);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
/**
|
||||
* 校验email是否存在
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkEmailExist(String email);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(SysUser user);
|
||||
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetUserPwd(@Param("userName") String userName, @Param("password") String password);
|
||||
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetPwdByEmail(@Param("email") String email, @Param("password") String password);
|
||||
|
||||
|
||||
@MapKey("user_id")
|
||||
public Map<Long, String> getUserInfoMap();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.jxy.system.mapper;
|
||||
|
||||
import com.jxy.system.entity.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与角色关联表 数据层
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
public interface SysUserRoleMapper
|
||||
{
|
||||
/**
|
||||
* 通过用户ID删除用户和角色关联
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRoleByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 批量删除用户和角色关联
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRole(Long[] ids);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int countUserRoleByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量新增用户角色信息
|
||||
*
|
||||
* @param userRoleList 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchUserRole(List<SysUserRole> userRoleList);
|
||||
|
||||
/**
|
||||
* 批量新增用户角色信息
|
||||
*
|
||||
* @param userRole 用户角色列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int createUserRole(SysUserRole userRole);
|
||||
|
||||
/**
|
||||
* 删除用户和角色关联信息
|
||||
*
|
||||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRoleInfo(SysUserRole userRole);
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.system.entity.StrategyLoginBody;
|
||||
import com.jxy.system.entity.StrategyResetPwdBody;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @Description 登录校验方法
|
||||
* @Date 2022/5/12 16:19
|
||||
* @Author 杜懿
|
||||
*/
|
||||
public interface StrategyService {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult login(StrategyLoginBody loginBody);
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult resetPwd(StrategyResetPwdBody resetPwdBody);
|
||||
|
||||
|
||||
public void logout(String loginName);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
|
||||
import com.jxy.system.api.entity.SysLogininfor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 服务层
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
public interface SysLogininforService
|
||||
{
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
public int insertLogininfor(SysLogininfor logininfor);
|
||||
|
||||
/**
|
||||
* 查询系统登录日志集合
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
* @return 登录记录集合
|
||||
*/
|
||||
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor);
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
* @param infoIds 需要删除的登录日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteLogininforByIds(Long[] infoIds);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*/
|
||||
public void cleanLogininfor();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface SysMenuService {
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> selectMenuPermsByUserId(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
|
||||
import com.jxy.system.api.entity.SysOperLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
public interface SysOperLogService
|
||||
{
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertOperlog(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteOperLogByIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
public SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*/
|
||||
public void cleanOperLog();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface SysPermissionService {
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @return 角色权限信息
|
||||
*/
|
||||
public Set<String> getRolePermission(Long userId);
|
||||
|
||||
/**
|
||||
* 获取菜单数据权限
|
||||
*
|
||||
* @param userId 用户Id
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermission(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SysRoleService {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRolesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
public List<Long> selectRoleListByUserId(Long userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.jxy.system.service;
|
||||
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import com.jxy.system.api.entity.SysUserLeveDate;
|
||||
import com.jxy.system.api.model.LoginUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysUserService {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户所属角色组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
public String selectUserRoleGroup(String userName);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkUserNameUnique(String userName);
|
||||
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkPhoneUnique(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkEmailUnique(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkEmailExist(String email);
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
public void checkUserAllowed(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void checkUserDataScope(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean registerUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserStatus(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserProfile(SysUser user);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetPwd(SysUser user);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetUserPwd(String userName, String password);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetPwdByEmail(String email, String password);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
* @return 结果
|
||||
* @param userLeveDate
|
||||
*/
|
||||
public int userLevelUp(SysUserLeveDate userLeveDate);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.common.core.constant.UserConstants;
|
||||
import com.jxy.common.core.exception.ServiceException;
|
||||
import com.jxy.common.core.utils.DateUtils;
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.common.core.web.Result.AjaxResult;
|
||||
import com.jxy.common.redis.service.RedisService;
|
||||
import com.jxy.common.security.utils.SecurityUtils;
|
||||
import com.jxy.system.entity.StrategyLoginBody;
|
||||
import com.jxy.system.entity.StrategyResetPwdBody;
|
||||
import com.jxy.system.entity.StrategyUser;
|
||||
import com.jxy.system.entity.StrategyUserDto;
|
||||
import com.jxy.system.mapper.StrategyMapper;
|
||||
import com.jxy.system.service.StrategyService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/1/30 11:32
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class StrategyServiceImpl implements StrategyService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StrategyMapper strategyMapper;
|
||||
|
||||
@Override
|
||||
public AjaxResult login(StrategyLoginBody loginBody) {
|
||||
|
||||
String username = loginBody.getUserName();
|
||||
String password= loginBody.getPassword();
|
||||
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password))
|
||||
{
|
||||
throw new ServiceException("用户名/密码不能为空");
|
||||
}
|
||||
// 密码如果不在指定范围内 错误
|
||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||
{
|
||||
throw new ServiceException("用户密码不在指定范围");
|
||||
}
|
||||
|
||||
//todo 可以添加校验验证码的功能
|
||||
|
||||
// 查询用户信息
|
||||
StrategyUser user = strategyMapper.selectUserByUserName(username);
|
||||
|
||||
if (StringUtils.isNull(user))
|
||||
{
|
||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||
}
|
||||
if (!SecurityUtils.matchesPassword(password, user.getPassword()))
|
||||
{
|
||||
//可能是存储的未加密的密码
|
||||
if(!password.equals(user.getPassword())){
|
||||
throw new ServiceException("密码错误");
|
||||
}else {
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
}
|
||||
}
|
||||
|
||||
//修改数据库中的用户登录次数和最后一次登录的ip
|
||||
user.setLastLanding(DateUtils.getNowDate());
|
||||
|
||||
StrategyUserDto dto = new StrategyUserDto();
|
||||
BeanUtils.copyProperties(user,dto);
|
||||
|
||||
//todo 单独存储用户的登录时间和ip
|
||||
strategyMapper.updateUser(user);
|
||||
|
||||
return AjaxResult.success(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult resetPwd(StrategyResetPwdBody resetPwdBody) {
|
||||
|
||||
String username = resetPwdBody.getUserName();
|
||||
String oldPassword= resetPwdBody.getOldPassword();
|
||||
String newPassword= resetPwdBody.getNewPassword();
|
||||
|
||||
StrategyUser user = strategyMapper.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user))
|
||||
{
|
||||
throw new ServiceException("用户:" + username + " 不存在");
|
||||
}
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, user.getPassword()))
|
||||
{
|
||||
//可能是存储的未加密的密码
|
||||
if(!oldPassword.equals(user.getPassword())){
|
||||
throw new ServiceException("原密码错误");
|
||||
}
|
||||
}
|
||||
user.setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||
|
||||
int i = strategyMapper.updateUser(user);
|
||||
|
||||
if (i < 1){
|
||||
return AjaxResult.error("密码修改失败,请稍后再试");
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(String loginName) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.system.api.entity.SysLogininfor;
|
||||
import com.jxy.system.mapper.SysLogininforMapper;
|
||||
import com.jxy.system.service.SysLogininforService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问日志情况信息 服务层处理
|
||||
*
|
||||
* @author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class SysLogininforServiceImpl implements SysLogininforService
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private SysLogininforMapper logininforMapper;
|
||||
|
||||
/**
|
||||
* 新增系统登录日志
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
*/
|
||||
@Override
|
||||
public int insertLogininfor(SysLogininfor logininfor)
|
||||
{
|
||||
return logininforMapper.insertLogininfor(logininfor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统登录日志集合
|
||||
*
|
||||
* @param logininfor 访问日志对象
|
||||
* @return 登录记录集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor)
|
||||
{
|
||||
return logininforMapper.selectLogininforList(logininfor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
* @param infoIds 需要删除的登录日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteLogininforByIds(Long[] infoIds)
|
||||
{
|
||||
return logininforMapper.deleteLogininforByIds(infoIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*/
|
||||
@Override
|
||||
public void cleanLogininfor()
|
||||
{
|
||||
logininforMapper.cleanLogininfor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.system.mapper.SysMenuMapper;
|
||||
import com.jxy.system.service.SysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description 用户业务层
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuServiceImpl implements SysMenuService {
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper menuMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(perm))
|
||||
{
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.system.api.entity.SysOperLog;
|
||||
import com.jxy.system.mapper.SysOperLogMapper;
|
||||
import com.jxy.system.service.SysOperLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
*
|
||||
* @author jxy
|
||||
*/
|
||||
@Service
|
||||
public class SysOperLogServiceImpl implements SysOperLogService
|
||||
{
|
||||
@Autowired
|
||||
private SysOperLogMapper operLogMapper;
|
||||
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertOperlog(SysOperLog operLog)
|
||||
{
|
||||
return operLogMapper.insertOperlog(operLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog)
|
||||
{
|
||||
return operLogMapper.selectOperLogList(operLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOperLogByIds(Long[] operIds)
|
||||
{
|
||||
return operLogMapper.deleteOperLogByIds(operIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
@Override
|
||||
public SysOperLog selectOperLogById(Long operId)
|
||||
{
|
||||
return operLogMapper.selectOperLogById(operId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*/
|
||||
@Override
|
||||
public void cleanOperLog()
|
||||
{
|
||||
operLogMapper.cleanOperLog();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import com.jxy.system.service.SysMenuService;
|
||||
import com.jxy.system.service.SysPermissionService;
|
||||
import com.jxy.system.service.SysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description 权限实现类
|
||||
* @Date 2022/6/16 11:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class SysPermissionServiceImpl implements SysPermissionService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private SysMenuService menuService;
|
||||
|
||||
@Override
|
||||
public Set<String> getRolePermission(Long userId) {
|
||||
|
||||
Set<String> roles = new HashSet<String>();
|
||||
// 管理员拥有所有权限
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
roles.add("admin");
|
||||
}
|
||||
else
|
||||
{
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(userId));
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMenuPermission(Long userId) {
|
||||
|
||||
Set<String> perms = new HashSet<String>();
|
||||
// 管理员拥有所有权限
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
perms.add("*:*:*");
|
||||
}
|
||||
else
|
||||
{
|
||||
perms.addAll(menuService.selectMenuPermsByUserId(userId));
|
||||
}
|
||||
return perms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.common.core.utils.SpringUtils;
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.common.datascope.annotation.DataScope;
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
import com.jxy.system.mapper.SysRoleMapper;
|
||||
import com.jxy.system.service.SysRoleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description 用户业务层
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleServiceImpl implements SysRoleService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SysRoleServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysRole> selectRoleList(SysRole role)
|
||||
{
|
||||
return roleMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId)
|
||||
{
|
||||
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (SysRole perm : perms)
|
||||
{
|
||||
if (StringUtils.isNotNull(perm))
|
||||
{
|
||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRolesByUserId(Long userId)
|
||||
{
|
||||
List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId);
|
||||
List<SysRole> roles = selectRoleAll();
|
||||
for (SysRole role : roles)
|
||||
{
|
||||
for (SysRole userRole : userRoles)
|
||||
{
|
||||
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
|
||||
{
|
||||
role.setFlag(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取用户角色id列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectRoleListByUserId(Long userId) {
|
||||
return roleMapper.selectRoleListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRoleAll()
|
||||
{
|
||||
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
package com.jxy.system.service.impl;
|
||||
|
||||
import com.jxy.common.core.constant.UserConstants;
|
||||
import com.jxy.common.core.exception.ServiceException;
|
||||
import com.jxy.common.core.utils.SpringUtils;
|
||||
import com.jxy.common.core.utils.StringUtils;
|
||||
import com.jxy.common.datascope.annotation.DataScope;
|
||||
import com.jxy.common.security.utils.SecurityUtils;
|
||||
import com.jxy.system.api.entity.SysRole;
|
||||
import com.jxy.system.api.entity.SysUser;
|
||||
import com.jxy.system.api.entity.SysUserLeveDate;
|
||||
import com.jxy.system.entity.SysUserRole;
|
||||
import com.jxy.system.mapper.SysRoleMapper;
|
||||
import com.jxy.system.mapper.SysUserLevelMapper;
|
||||
import com.jxy.system.mapper.SysUserMapper;
|
||||
import com.jxy.system.mapper.SysUserRoleMapper;
|
||||
import com.jxy.system.service.SysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description 用户业务层
|
||||
* @Date 2022/6/14 17:37
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements SysUserService {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SysPermissionServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserLevelMapper userLevelMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByEmail(String email) {
|
||||
return userMapper.selectUserByEmail(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId)
|
||||
{
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属角色组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName)
|
||||
{
|
||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||
if (CollectionUtils.isEmpty(list))
|
||||
{
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(String userName) {
|
||||
int count = userMapper.checkUserNameUnique(userName);
|
||||
if (count > 0)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkPhoneUnique(SysUser user)
|
||||
{
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getPhone());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailUnique(SysUser user)
|
||||
{
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否存在
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String checkEmailExist(String email)
|
||||
{
|
||||
String dbEmail = userMapper.checkEmailExist(email);
|
||||
if (StringUtils.isNotNull(dbEmail))
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
{
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId)
|
||||
{
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
||||
{
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
if (StringUtils.isEmpty(users))
|
||||
{
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean registerUser(SysUser user) {
|
||||
|
||||
boolean result = userMapper.insertUser(user) > 0;
|
||||
if(result){
|
||||
//用户添加成功后 默认设置用户为注册用户
|
||||
SysUser dbUser = userMapper.selectUserByUserName(user.getUserName());
|
||||
user.setUserId(dbUser.getUserId());
|
||||
|
||||
//查询角色:“注册用户”的id并且赋值到user中
|
||||
//Long[] roleIds = roleMapper.getResigesterId();
|
||||
//先把注册用户等级都升为vip 有效期三个月(后通过定时任务去控制)
|
||||
Long[] roleIds = roleMapper.getVipId();
|
||||
user.setRoleIds(roleIds);
|
||||
insertUserRole(user);
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateUser(SysUser user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理 此处要保证传过来的user中要携带roleIds
|
||||
insertUserRole(user);
|
||||
//// 删除用户与岗位关联
|
||||
//userPostMapper.deleteUserPostByUserId(userId);
|
||||
//// 新增用户与岗位管理
|
||||
//insertUserPost(user);
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwd(SysUser user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password)
|
||||
{
|
||||
return userMapper.resetUserPwd(userName, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwdByEmail(String email, String password)
|
||||
{
|
||||
return userMapper.resetPwdByEmail(email, password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int userLevelUp(SysUserLeveDate userInfo) {
|
||||
System.out.println("用户升级服务收到用户信息:"+userInfo);
|
||||
Long userId = userInfo.getUserId();
|
||||
|
||||
if(userInfo.getOper() == 1){
|
||||
//执行续费操作 用户角色不改变 会员过期日期在原有基础上增加
|
||||
//1、查询会员有效期
|
||||
SysUserLeveDate dbUserInfo = userLevelMapper.getUserLevelInfo(userId);
|
||||
Date date = dbUserInfo.getExpireTime();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
if(userInfo.getLevelType() > 0){
|
||||
//年度会员/年度vip 会员有效期设置为一年
|
||||
calendar.add(Calendar.YEAR,1);
|
||||
}else {
|
||||
calendar.add(Calendar.MONTH,1);
|
||||
}
|
||||
//2、根据购买类型修改会员有效期
|
||||
userInfo.setStartTime(dbUserInfo.getStartTime());
|
||||
userInfo.setExpireTime(calendar.getTime());
|
||||
|
||||
|
||||
userLevelMapper.deleteUserLevelInfoByUserId(userInfo.getUserId());
|
||||
// 新增用户与用户会员有效期关联
|
||||
return userLevelMapper.createUserLevelInfo(userInfo);
|
||||
|
||||
}else{
|
||||
//执行升级操作 用户角色改变 会员过期日期在更新
|
||||
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理 此处要保证传过来的user中要携带roleIds
|
||||
if (StringUtils.isNotNull(userInfo.getRoleId()))
|
||||
{
|
||||
// 新增用户与角色关联
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userInfo.getUserId());
|
||||
ur.setRoleId(userInfo.getRoleId());
|
||||
int userRole = userRoleMapper.createUserRole(ur);
|
||||
System.out.println("用户角色修改结果:"+userRole);
|
||||
//获取用户当前会员有效期信息 根据情况决定如何处理
|
||||
// 相同类型则表示续费、直接增加日期 不同类型则直接删除有效期再更新
|
||||
// 删除用户与用户会员有效期关联
|
||||
userLevelMapper.deleteUserLevelInfoByUserId(userInfo.getUserId());
|
||||
// 新增用户与用户会员有效期关联
|
||||
return userLevelMapper.createUserLevelInfo(userInfo);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public void insertUserRole(SysUser user)
|
||||
{
|
||||
//需要确保user.getRoleIds在整个传递过程中不丢失
|
||||
Long[] roles = user.getRoleIds();
|
||||
if (StringUtils.isNotNull(roles))
|
||||
{
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||
for (Long roleId : roles)
|
||||
{
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(user.getUserId());
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jxy.system.task;
|
||||
|
||||
import com.jxy.common.redis.service.RedisService;
|
||||
import com.jxy.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Date 2023/8/7 14:57
|
||||
* @Author 杜懿
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class TestTask {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
//@Scheduled(cron = "0 24 0/4 * * ?")
|
||||
//@Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void CapRealData(){
|
||||
|
||||
|
||||
Map<Long, String> map = sysUserMapper.getUserInfoMap();
|
||||
|
||||
System.out.println("所有用户数据:"+map);
|
||||
|
||||
System.out.println(map.get(15));
|
||||
|
||||
System.out.println(map.get(32));
|
||||
//if(list.size() > 0){
|
||||
// redisService.deleteObject("CapRealData");
|
||||
// redisService.setCacheList("CapRealData",list);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
25
jxy-modules/jxy-system/src/main/resources/bootstrap.yml
Normal file
25
jxy-modules/jxy-system/src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9201
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: jxy-system
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
74
jxy-modules/jxy-system/src/main/resources/logback.xml
Normal file
74
jxy-modules/jxy-system/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/jxy-system" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.jxy" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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.jxy.system.mapper.StrategyMapper">
|
||||
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultType="com.jxy.system.entity.StrategyUser">
|
||||
select
|
||||
username as userName,
|
||||
password,
|
||||
privilege,
|
||||
last_landing as lastLanding,
|
||||
own_strategy as ownStrategy
|
||||
from
|
||||
strategy_user
|
||||
where
|
||||
username = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="checkUserNameUnique" parameterType="String" resultType="int">
|
||||
select count(1) from strategy_user where username = #{userName} limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateUser" parameterType="com.jxy.system.entity.StrategyUser">
|
||||
update strategy_user
|
||||
<set>
|
||||
<if test="userName != null and userName != ''">username = #{userName},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="privilege != null and privilege != ''">privilege = #{privilege},</if>
|
||||
<if test="lastLanding != null">last_landing = #{lastLanding},</if>
|
||||
<if test="ownStrategy != null and ownStrategy != ''">own_strategy = #{ownStrategy},</if>
|
||||
</set>
|
||||
where username = #{userName}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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.jxy.system.mapper.SysLogininforMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.api.entity.SysLogininfor" id="SysLogininforResult">
|
||||
<id property="infoId" column="info_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="ipaddr" column="ipaddr" />
|
||||
<result property="msg" column="msg" />
|
||||
<result property="accessTime" column="access_time" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertLogininfor" parameterType="com.jxy.system.api.entity.SysLogininfor">
|
||||
insert into sys_logininfor (user_name, status, ipaddr, msg, access_time)
|
||||
values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="selectLogininforList" parameterType="com.jxy.system.api.entity.SysLogininfor" resultMap="SysLogininforResult">
|
||||
select info_id, user_name, ipaddr, status, msg, access_time from sys_logininfor
|
||||
<where>
|
||||
<if test="ipaddr != null and ipaddr != ''">
|
||||
AND ipaddr like concat('%', #{ipaddr}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(access_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(access_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by info_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteLogininforByIds" parameterType="Long">
|
||||
delete from sys_logininfor where info_id in
|
||||
<foreach collection="array" item="infoId" open="(" separator="," close=")">
|
||||
#{infoId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="cleanLogininfor">
|
||||
truncate table sys_logininfor
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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.jxy.system.mapper.SysMenuMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.entity.SysMenu" 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="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" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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.jxy.system.mapper.SysOperLogMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.api.entity.SysOperLog" id="SysOperLogResult">
|
||||
<id property="operId" column="oper_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="businessType" column="business_type" />
|
||||
<result property="method" column="method" />
|
||||
<result property="requestMethod" column="request_method" />
|
||||
<result property="operatorType" column="operator_type" />
|
||||
<result property="operName" column="oper_name" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="operUrl" column="oper_url" />
|
||||
<result property="operIp" column="oper_ip" />
|
||||
<result property="operParam" column="oper_param" />
|
||||
<result property="jsonResult" column="json_result" />
|
||||
<result property="status" column="status" />
|
||||
<result property="errorMsg" column="error_msg" />
|
||||
<result property="operTime" column="oper_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOperLogVo">
|
||||
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time
|
||||
from sys_oper_log
|
||||
</sql>
|
||||
|
||||
<insert id="insertOperlog" parameterType="com.jxy.system.api.entity.SysOperLog">
|
||||
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time)
|
||||
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="selectOperLogList" parameterType="com.jxy.system.api.entity.SysOperLog" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like concat('%', #{title}, '%')
|
||||
</if>
|
||||
<if test="businessType != null and businessType != ''">
|
||||
AND business_type = #{businessType}
|
||||
</if>
|
||||
<if test="businessTypes != null and businessTypes.length > 0">
|
||||
AND business_type in
|
||||
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
||||
#{businessType}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND oper_name like concat('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by oper_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||
delete from sys_oper_log where oper_id in
|
||||
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
||||
#{operId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
where oper_id = #{operId}
|
||||
</select>
|
||||
|
||||
<update id="cleanOperLog">
|
||||
truncate table sys_oper_log
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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.jxy.system.mapper.SysRoleMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.api.entity.SysRole" id="SysRoleResult">
|
||||
<id property="roleId" column="role_id" />
|
||||
<result property="roleName" column="role_name" />
|
||||
<result property="roleKey" column="role_key" />
|
||||
<result property="roleSort" column="role_sort" />
|
||||
<result property="dataScope" column="data_scope" />
|
||||
<result property="menuCheckStrictly" column="menu_check_strictly" />
|
||||
<result property="deptCheckStrictly" column="dept_check_strictly" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.status, r.del_flag, r.create_time, r.remark
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectRoleList" parameterType="com.jxy.system.api.entity.SysRole" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag = '0'
|
||||
<if test="roleId != null and roleId != 0">
|
||||
AND r.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
AND r.role_name like concat('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="roleKey != null and roleKey != ''">
|
||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleAll" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
|
||||
select r.role_id
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="getResigesterId" parameterType="String" resultType="Long">
|
||||
select role_id from sys_role where role_key = 'registered'
|
||||
</select>
|
||||
|
||||
<select id="getVipId" parameterType="String" resultType="Long">
|
||||
select role_id from sys_role where role_key = 'vip'
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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.jxy.system.mapper.SysRoleMenuMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.entity.SysRoleMenu" id="SysRoleMenuResult">
|
||||
<result property="roleId" column="role_id" />
|
||||
<result property="menuId" column="menu_id" />
|
||||
</resultMap>
|
||||
|
||||
<select id="checkMenuExistRole" resultType="Integer">
|
||||
select count(1) from sys_role_menu where menu_id = #{menuId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteRoleMenuByRoleId" parameterType="Long">
|
||||
delete from sys_role_menu where role_id=#{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRoleMenu" parameterType="Long">
|
||||
delete from sys_role_menu where role_id in
|
||||
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchRoleMenu">
|
||||
insert into sys_role_menu(role_id, menu_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.roleId},#{item.menuId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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.jxy.system.mapper.SysUserLevelMapper">
|
||||
|
||||
<select id="getUserLevelInfo" resultType="com.jxy.system.api.entity.SysUserLeveDate">
|
||||
SELECT
|
||||
l.id,l.user_id userId,u.user_name userName,u.email email,l.level_type levelType,l.create_time startTime,l.expire_time expireTime,r.role_id roleId
|
||||
FROM
|
||||
sys_user_level_date l
|
||||
LEFT JOIN sys_user u ON l.user_id = u.user_id
|
||||
LEFT JOIN sys_user_role ur on ur.user_id = u.user_id
|
||||
LEFT JOIN sys_role r on r.role_id = ur.role_id
|
||||
where l.user_id = #{userId} and l.status = 0 order by l.create_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getExpireUserIds" resultType="java.lang.Long">
|
||||
select id from sys_user_level_date where expire_time <= sysdate() and status = 0
|
||||
</select>
|
||||
|
||||
<insert id="createUserLevelInfo">
|
||||
insert into sys_user_level_date(user_id,create_time,expire_time,level_type,status) values
|
||||
(#{vo.userId},#{vo.startTime},#{vo.expireTime},#{vo.levelType},0)
|
||||
</insert>
|
||||
|
||||
<update id="deleteExpireUserLevelInfo">
|
||||
update sys_user_level_date set status = 1 where user_id in
|
||||
<foreach collection="ids" open="(" close=")" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserLevelInfoByUserId">
|
||||
delete from sys_user_level_date where user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
<?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.jxy.system.mapper.SysUserMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.api.entity.SysUser" id="SysUserResult">
|
||||
<id property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="email" column="email" />
|
||||
<result property="phone" column="phonenumber" />
|
||||
<result property="sex" column="sex" />
|
||||
<result property="avatar" column="avatar" />
|
||||
<result property="password" column="password" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="loginIp" column="login_ip" />
|
||||
<result property="loginDate" column="login_date" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="loginCount" column="login_count" />
|
||||
<result property="roleId" column="role_id" />
|
||||
<association property="dept" column="dept_id" javaType="com.jxy.system.api.entity.SysDept" resultMap="deptResult" />
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="deptResult" type="com.jxy.system.api.entity.SysDept">
|
||||
<id property="deptId" column="dept_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="leader" column="leader" />
|
||||
<result property="status" column="dept_status" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RoleResult" type="com.jxy.system.api.entity.SysRole">
|
||||
<id property="roleId" column="role_id" />
|
||||
<result property="roleName" column="role_name" />
|
||||
<result property="roleKey" column="role_key" />
|
||||
<result property="roleSort" column="role_sort" />
|
||||
<result property="dataScope" column="data_scope" />
|
||||
<result property="status" column="role_status" />
|
||||
<result property="levelExpireDate" column="expire_time" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.login_count,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
|
||||
l.expire_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
left join sys_user_level_date l on l.user_id = u.user_id
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectUserList" parameterType="com.jxy.system.api.entity.SysUser" resultMap="SysUserResult">
|
||||
select user_id, dept_id, nick_name, user_name, email, avatar, phonenumber, password,sex,status,del_flag,login_ip,login_date,create_by,create_time,remark,login_count from sys_user
|
||||
where del_flag = '0'
|
||||
<if test="userId != null and userId != 0">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND phonenumber like concat('%', #{phone}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_name = #{userName}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByEmail" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="checkUserNameUnique" parameterType="String" resultType="int">
|
||||
select count(1) from sys_user where user_name = #{userName} limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, email from sys_user where email = #{email} limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkEmailExist" parameterType="String" resultType="string">
|
||||
select email from sys_user where email = #{email} limit 1
|
||||
</select>
|
||||
|
||||
<select id="getUserInfoMap" resultType="java.util.Map" >
|
||||
select user_id ,email from sys_user
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="com.jxy.system.api.entity.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
<if test="phone != null and phone != ''">phonenumber,</if>
|
||||
<if test="sex != null and sex != ''">sex,</if>
|
||||
<if test="password != null and password != ''">password,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="sex != null and sex != ''">#{sex},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="com.jxy.system.api.entity.SysUser">
|
||||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phone != null ">phonenumber = #{phone},</if>
|
||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="loginCount != null">login_count = #{loginCount},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<update id="resetUserPwd" parameterType="com.jxy.system.api.entity.SysUser">
|
||||
update sys_user set password = #{password} where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<update id="resetPwdByEmail" parameterType="com.jxy.system.api.entity.SysUser">
|
||||
update sys_user set password = #{password} where email = #{email}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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.jxy.system.mapper.SysUserRoleMapper">
|
||||
|
||||
<resultMap type="com.jxy.system.entity.SysUserRole" id="SysUserRoleResult">
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="roleId" column="role_id" />
|
||||
</resultMap>
|
||||
|
||||
<delete id="deleteUserRoleByUserId" parameterType="Long">
|
||||
delete from sys_user_role where user_id=#{userId}
|
||||
</delete>
|
||||
|
||||
<select id="countUserRoleByRoleId" resultType="Integer">
|
||||
select count(1) from sys_user_role where role_id=#{roleId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteUserRole" parameterType="Long">
|
||||
delete from sys_user_role where user_id in
|
||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchUserRole">
|
||||
insert into sys_user_role(user_id, role_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.roleId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="createUserRole">
|
||||
insert into sys_user_role(user_id, role_id) values(#{userId},#{roleId})
|
||||
</insert>
|
||||
|
||||
|
||||
<delete id="deleteUserRoleInfo" parameterType="com.jxy.system.entity.SysUserRole">
|
||||
delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserRoleInfos">
|
||||
delete from sys_user_role where role_id=#{roleId} and user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user