Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -4,17 +4,24 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.AccessKey;
|
||||
import com.gxwebsoft.common.system.param.AccessKeyParam;
|
||||
import com.gxwebsoft.common.system.service.AccessKeyService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.WebsiteConstants.CACHE_KEY_VERIFICATION_CODE_BY_DEV_SMS;
|
||||
|
||||
/**
|
||||
* 访问凭证管理控制器
|
||||
@@ -26,125 +33,140 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/api/system/access-key")
|
||||
public class AccessKeyController extends BaseController {
|
||||
@Resource
|
||||
private AccessKeyService accessKeyService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private AccessKeyService accessKeyService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询访问凭证")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AccessKey>> page(AccessKeyParam param) {
|
||||
// 使用关联查询
|
||||
final PageResult<AccessKey> accessKeyPageResult = accessKeyService.pageRel(param);
|
||||
if (param.getCode() != null) {
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(param.getPhone(), String.class);
|
||||
if (StrUtil.equals(code,param.getCode()) || "128880".equals(param.getCode())) {
|
||||
return success(accessKeyPageResult);
|
||||
}
|
||||
return fail("短信验证码不正确",null);
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询访问凭证")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AccessKey>> page(AccessKeyParam param) {
|
||||
// 使用关联查询
|
||||
final PageResult<AccessKey> accessKeyPageResult = accessKeyService.pageRel(param);
|
||||
if (param.getCode() != null) {
|
||||
// 短信验证码校验
|
||||
String code = cacheClient.get(param.getPhone(), String.class);
|
||||
if (StrUtil.equals(code, param.getCode()) || "128880".equals(param.getCode())) {
|
||||
return success(accessKeyPageResult);
|
||||
}
|
||||
// 默认不给查看AccessSecret
|
||||
accessKeyPageResult.getList().forEach( d -> {
|
||||
d.setAccessSecret(null);
|
||||
});
|
||||
return success(accessKeyPageResult);
|
||||
return fail("短信验证码不正确", null);
|
||||
}
|
||||
// 默认不给查看AccessSecret
|
||||
accessKeyPageResult.getList().forEach(d -> {
|
||||
d.setAccessSecret(null);
|
||||
});
|
||||
return success(accessKeyPageResult);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部访问凭证管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AccessKey>> list(AccessKeyParam param) {
|
||||
PageParam<AccessKey, AccessKeyParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(accessKeyService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(accessKeyService.listRel(param));
|
||||
}
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部访问凭证管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AccessKey>> list(AccessKeyParam param) {
|
||||
PageParam<AccessKey, AccessKeyParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(accessKeyService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(accessKeyService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询访问凭证管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AccessKey> get(@PathVariable("id") Integer id) {
|
||||
return success(accessKeyService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(accessKeyService.getByIdRel(id));
|
||||
}
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询访问凭证管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AccessKey> get(@PathVariable("id") Integer id) {
|
||||
return success(accessKeyService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(accessKeyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加访问凭证管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AccessKey accessKey) {
|
||||
final int count = accessKeyService.count();
|
||||
if (count >= 5) {
|
||||
return fail("当前账号只能绑定 5 个 AccessKey");
|
||||
}
|
||||
accessKey.setAccessKey("AI" + CommonUtil.randomUUID16());
|
||||
accessKey.setAccessSecret(CommonUtil.randomUUID16().concat(CommonUtil.randomUUID16()));
|
||||
if (accessKeyService.save(accessKey)) {
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("创建失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加访问凭证管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AccessKey accessKey) {
|
||||
final int count = accessKeyService.count();
|
||||
if (count >= 5) {
|
||||
return fail("当前账号只能绑定 5 个 AccessKey");
|
||||
}
|
||||
accessKey.setAccessKey("AI" + CommonUtil.randomUUID16());
|
||||
accessKey.setAccessSecret(CommonUtil.randomUUID16().concat(CommonUtil.randomUUID16()));
|
||||
if (accessKeyService.save(accessKey)) {
|
||||
return success("创建成功");
|
||||
}
|
||||
return fail("创建失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改访问凭证管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AccessKey accessKey) {
|
||||
if (accessKeyService.updateById(accessKey)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改访问凭证管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AccessKey accessKey) {
|
||||
if (accessKeyService.updateById(accessKey)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除访问凭证管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (accessKeyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除访问凭证管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (accessKeyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加访问凭证管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AccessKey> list) {
|
||||
if (accessKeyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加访问凭证管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AccessKey> list) {
|
||||
if (accessKeyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改访问凭证管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AccessKey> batchParam) {
|
||||
if (batchParam.update(accessKeyService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改访问凭证管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<AccessKey> batchParam) {
|
||||
if (batchParam.update(accessKeyService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除访问凭证管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (accessKeyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除访问凭证管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (accessKeyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:accessKey:resetSMSCode')")
|
||||
@OperationLog
|
||||
@ApiOperation("重置万能短信验证码")
|
||||
@PostMapping("/resetSMSCode")
|
||||
public ApiResult<?> resetSMSCode() {
|
||||
// 生成短信验证码
|
||||
Random randObj = new Random();
|
||||
String code = Integer.toString(100000 + randObj.nextInt(900000));
|
||||
redisUtil.set(CACHE_KEY_VERIFICATION_CODE_BY_DEV_SMS, code, 5L, TimeUnit.MINUTES);
|
||||
return success("新验证码:".concat(code));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,57 +1,134 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserRoleService;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserRoleParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.*;
|
||||
import com.gxwebsoft.common.system.param.UserImportParam;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户控制器
|
||||
* 用户角色控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:41
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "用户角色")
|
||||
@Api(tags = "用户角色管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/system/user-role")
|
||||
public class UserRoleController extends BaseController {
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@ApiOperation("查询角色下的用户")
|
||||
@GetMapping("/user-list-in-role/{id}")
|
||||
public ApiResult<List<UserRole>> userListInRole(@PathVariable Integer id) {
|
||||
return success(userRoleService.listByRoleId(id));
|
||||
@ApiOperation("查询角色下的用户")
|
||||
@GetMapping("/user-list-in-role/{id}")
|
||||
public ApiResult<List<UserRole>> userListInRole(@PathVariable Integer id) {
|
||||
return success(userRoleService.listByRoleId(id));
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询用户角色")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserRole>> page(UserRoleParam param) {
|
||||
// 使用关联查询
|
||||
return success(userRoleService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部用户角色")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserRole>> list(UserRoleParam param) {
|
||||
// 使用关联查询
|
||||
return success(userRoleService.listRel(param));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据id查询用户角色")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserRole> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userRoleService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userRole:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户角色")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserRole userRole) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userRole.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userRoleService.save(userRole)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户角色")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserRole userRole) {
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
if (userRoleService.updateById(userRole)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userRole:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户角色")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userRoleService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userRole:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户角色")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserRole> list) {
|
||||
if (userRoleService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userRole:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户角色")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserRole> batchParam) {
|
||||
if (batchParam.update(userRoleService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userRole:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户角色")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userRoleService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.Organization;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.common.system.service.UserVerifyService;
|
||||
import com.gxwebsoft.common.system.entity.UserVerify;
|
||||
import com.gxwebsoft.common.system.param.UserVerifyParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.service.OrganizationService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.common.system.service.UserVerifyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -32,119 +33,146 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/api/system/user-verify")
|
||||
public class UserVerifyController extends BaseController {
|
||||
@Resource
|
||||
private UserVerifyService userVerifyService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserVerifyService userVerifyService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:list')")
|
||||
@ApiOperation("分页查询实名认证")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserVerify>> page(UserVerifyParam param) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.pageRel(param));
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:list')")
|
||||
@ApiOperation("分页查询实名认证")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserVerify>> page(UserVerifyParam param) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:list')")
|
||||
@ApiOperation("查询全部实名认证")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserVerify>> list(UserVerifyParam param) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询实名认证")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserVerify> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据userId查询实名认证")
|
||||
@GetMapping("/myUserVerify")
|
||||
public ApiResult<UserVerify> myUserVerify(UserVerifyParam param) {
|
||||
if (getLoginUser() == null) {
|
||||
return fail("请先登录", null);
|
||||
}
|
||||
final LambdaQueryWrapper<UserVerify> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserVerify::getUserId, getLoginUserId());
|
||||
wrapper.eq(UserVerify::getDeleted, 0);
|
||||
if(param.getStatus() != null){
|
||||
wrapper.eq(UserVerify::getStatus, param.getStatus());
|
||||
}
|
||||
wrapper.last("limit 1");
|
||||
final UserVerify one = userVerifyService.getOne(wrapper);
|
||||
if(ObjUtil.isNotEmpty(one) && one.getOrganizationId() > 0){
|
||||
final Organization organization = organizationService.getById(one.getOrganizationId());
|
||||
one.setOrganizationName(organization.getOrganizationName());
|
||||
}
|
||||
return success(one);
|
||||
}
|
||||
|
||||
@ApiOperation("提交实名认证")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserVerify userVerify) {
|
||||
if (getLoginUser() == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
userVerify.setUserId(getLoginUserId());
|
||||
if (userVerifyService.save(userVerify)) {
|
||||
return success("提交成功");
|
||||
}
|
||||
return fail("提交失败");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ApiOperation("修改实名认证")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserVerify userVerify) {
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:list')")
|
||||
@ApiOperation("查询全部实名认证")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserVerify>> list(UserVerifyParam param) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.listRel(param));
|
||||
final User byUserId = userService.getById(userVerify.getUserId());
|
||||
if (ObjUtil.isEmpty(byUserId)) {
|
||||
return fail("用户不存在");
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询实名认证")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserVerify> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userVerifyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据userId查询实名认证")
|
||||
@GetMapping("/myUserVerify")
|
||||
public ApiResult<UserVerify> myUserVerify() {
|
||||
if(getLoginUser() == null){
|
||||
return fail("请先登录",null);
|
||||
// 不通过
|
||||
byUserId.setCertification(false);
|
||||
// 通过认证
|
||||
if (userVerify.getStatus().equals(1)) {
|
||||
byUserId.setRealName(userVerify.getRealName());
|
||||
byUserId.setCertification(true);
|
||||
byUserId.setType(userVerify.getType());
|
||||
// 企业认证
|
||||
if (userVerify.getType().equals(1)) {
|
||||
byUserId.setRealName(userVerify.getName());
|
||||
}
|
||||
return success(userVerifyService.getOne(new LambdaQueryWrapper<UserVerify>().eq(UserVerify::getUserId, getLoginUserId()).last("limit 1")));
|
||||
}
|
||||
userService.updateById(byUserId);
|
||||
|
||||
@ApiOperation("提交实名认证")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserVerify userVerify) {
|
||||
if (getLoginUser() == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
userVerify.setUserId(getLoginUserId());
|
||||
if (userVerifyService.save(userVerify)) {
|
||||
return success("提交成功");
|
||||
}
|
||||
return fail("提交失败");
|
||||
if (userVerifyService.updateById(userVerify)) {
|
||||
return success("提交成功");
|
||||
}
|
||||
return fail("提交失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改实名认证")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserVerify userVerify) {
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
if (userVerify.getStatus().equals(1)){
|
||||
loginUser.setRealName(userVerify.getRealName());
|
||||
if(userVerify.getType().equals(1)){
|
||||
loginUser.setRealName(userVerify.getName());
|
||||
}
|
||||
userService.updateById(loginUser);
|
||||
}
|
||||
if (userVerifyService.updateById(userVerify)) {
|
||||
return success("提交成功");
|
||||
}
|
||||
return fail("提交失败");
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除实名认证")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userVerifyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除实名认证")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userVerifyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加实名认证")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserVerify> list) {
|
||||
if (userVerifyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加实名认证")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserVerify> list) {
|
||||
if (userVerifyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改实名认证")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserVerify> batchParam) {
|
||||
if (batchParam.update(userVerifyService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改实名认证")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserVerify> batchParam) {
|
||||
if (batchParam.update(userVerifyService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除实名认证")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userVerifyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
@PreAuthorize("hasAuthority('sys:userVerify:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除实名认证")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userVerifyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ public class WxOfficialController extends BaseController {
|
||||
|
||||
@ApiOperation("验证微信服务器")
|
||||
@GetMapping("/{id}")
|
||||
public String validate(@PathVariable("id") Integer tenantId,@RequestParam String nonce,@RequestParam String timestamp,@RequestParam String signature,@RequestParam String echostr){
|
||||
public String validate(@PathVariable("id") Integer tenantId, @RequestParam String nonce, @RequestParam String timestamp, @RequestParam String signature, @RequestParam String echostr) {
|
||||
System.out.println("nonce = " + nonce);
|
||||
System.out.println("tenantId = " + tenantId);
|
||||
if(tenantId == null){
|
||||
if (tenantId == null) {
|
||||
return null;
|
||||
}
|
||||
String token = "gxwebsoft";
|
||||
@@ -87,7 +87,7 @@ public class WxOfficialController extends BaseController {
|
||||
Arrays.sort(array);
|
||||
// 将三个参数字符串拼接成一个字符串进行sha1加密
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String str: array){
|
||||
for (String str : array) {
|
||||
sb.append(str);
|
||||
}
|
||||
final String strSha1 = DigestUtil.sha1Hex(sb.toString());
|
||||
@@ -101,7 +101,7 @@ public class WxOfficialController extends BaseController {
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@RequestMapping("/{id}")
|
||||
@ResponseBody
|
||||
public String receiveMessages(HttpServletRequest request,@PathVariable("id") Integer tenantId) throws IOException {
|
||||
public String receiveMessages(HttpServletRequest request, @PathVariable("id") Integer tenantId) throws IOException {
|
||||
System.out.println("tenantId = " + tenantId);
|
||||
Integer userId = 0; // 用户ID
|
||||
// 从请求中获取XML数据
|
||||
@@ -113,9 +113,9 @@ public class WxOfficialController extends BaseController {
|
||||
Element FromUserName = XmlUtil.getElement(rootElement, "FromUserName");
|
||||
String openId = FromUserName.getTextContent();
|
||||
System.out.println("openId = " + openId);
|
||||
if(StrUtil.isNotBlank(openId)){
|
||||
if (StrUtil.isNotBlank(openId)) {
|
||||
// 获取用户基本信息(UnionID机制)
|
||||
final String userStr = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid="+ openId +"&lang=zh_CN");
|
||||
final String userStr = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid=" + openId + "&lang=zh_CN");
|
||||
// 保存第三方用户信息表shop_user_oauth
|
||||
final JSONObject jsonObject = JSONObject.parseObject(userStr);
|
||||
final String unionid = jsonObject.getString("unionid");
|
||||
@@ -123,15 +123,15 @@ public class WxOfficialController extends BaseController {
|
||||
System.out.println("unionid = " + unionid);
|
||||
sendTemplateMessage(openId);
|
||||
// 关注操作
|
||||
if (subscribe != null &&subscribe.equals("1")) {
|
||||
final int count = userOauthService.count(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getOauthType, MP_OFFICIAL).eq(UserOauth::getUnionid, unionid).eq(UserOauth::getTenantId,tenantId));
|
||||
if (subscribe != null && subscribe.equals("1")) {
|
||||
final int count = userOauthService.count(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getOauthType, MP_OFFICIAL).eq(UserOauth::getUnionid, unionid).eq(UserOauth::getTenantId, tenantId));
|
||||
System.out.println("count = " + count);
|
||||
if (count == 0) {
|
||||
// 其他平台是否有注册过
|
||||
final List<UserOauth> list = userOauthService.list(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getUnionid, unionid).eq(UserOauth::getDeleted, 0));
|
||||
final int size = list.size();
|
||||
// 新用户注册
|
||||
if (size== 0) {
|
||||
if (size == 0) {
|
||||
User user = new User();
|
||||
user.setStatus(0);
|
||||
user.setUsername("wxoff_".concat(RandomUtil.randomString(12)));
|
||||
@@ -160,8 +160,8 @@ public class WxOfficialController extends BaseController {
|
||||
}
|
||||
// 更新
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (UserOauth item: list){
|
||||
if(item.getUserId() != null){
|
||||
for (UserOauth item : list) {
|
||||
if (item.getUserId() != null) {
|
||||
userId = item.getUserId();
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class WxOfficialController extends BaseController {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void sendTemplateMessage(String openId){
|
||||
private void sendTemplateMessage(String openId) {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken();
|
||||
TemplateMessage templateMessage = new TemplateMessage();
|
||||
templateMessage.setToUser(openId);
|
||||
@@ -198,12 +198,12 @@ public class WxOfficialController extends BaseController {
|
||||
{{productType.DATA}}:{{name.DATA}} 消费时间:{{time.DATA}} {{remark.DATA}}
|
||||
*/
|
||||
HashMap<String, TemplateMessageDTO> data = new HashMap<>();
|
||||
data.put("first",new TemplateMessageDTO("您收到了一条新的订单。"));
|
||||
data.put("tradeDateTime",new TemplateMessageDTO("02月18日 01时05分"));
|
||||
data.put("customerInfo",new TemplateMessageDTO("广州 王俊"));
|
||||
data.put("orderItemName",new TemplateMessageDTO("兴趣车型"));
|
||||
data.put("orderItemData",new TemplateMessageDTO("骐达 2011款 1.6 CVT 舒适版"));
|
||||
data.put("remark",new TemplateMessageDTO("截止24日09:39分,您尚有10个订单未处理。"));
|
||||
data.put("first", new TemplateMessageDTO("您收到了一条新的订单。"));
|
||||
data.put("tradeDateTime", new TemplateMessageDTO("02月18日 01时05分"));
|
||||
data.put("customerInfo", new TemplateMessageDTO("广州 王俊"));
|
||||
data.put("orderItemName", new TemplateMessageDTO("兴趣车型"));
|
||||
data.put("orderItemData", new TemplateMessageDTO("骐达 2011款 1.6 CVT 舒适版"));
|
||||
data.put("remark", new TemplateMessageDTO("截止24日09:39分,您尚有10个订单未处理。"));
|
||||
System.out.println("data = " + data);
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.post(url)
|
||||
@@ -219,31 +219,31 @@ public class WxOfficialController extends BaseController {
|
||||
public ApiResult<?> send(UserParam param) {
|
||||
// send发送订阅通知
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token=" + getAccessToken();
|
||||
final UserOauth userOauth = userOauthService.getOne(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getUserId, param.getUserId()).eq(UserOauth::getOauthType,"MP-OFFICIAL").eq(UserOauth::getDeleted, 0));
|
||||
if(userOauth != null){
|
||||
final UserOauth userOauth = userOauthService.getOne(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getUserId, param.getUserId()).eq(UserOauth::getOauthType, "MP-OFFICIAL").eq(UserOauth::getDeleted, 0));
|
||||
if (userOauth != null) {
|
||||
param.setOpenid(userOauth.getOauthId());
|
||||
final String oauthId = userOauth.getOauthId();
|
||||
// 跳转小程序链接
|
||||
HashMap<String, String> miniprogram = new HashMap<>();
|
||||
miniprogram.put("appid",miniAppid);
|
||||
miniprogram.put("pagepath","pages/chat/chat?friendId=" + param.getUserId());
|
||||
miniprogram.put("appid", miniAppid);
|
||||
miniprogram.put("pagepath", "pages/chat/chat?friendId=" + param.getUserId());
|
||||
// 参数
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
final HashMap<String, String> thing1 = new HashMap<>();
|
||||
final HashMap<String, String> thing2 = new HashMap<>();
|
||||
thing1.put("value","有新访客需要接待");
|
||||
thing2.put("value","吉媒小红娘");
|
||||
data.put("thing1",thing1);
|
||||
data.put("thing2",thing2);
|
||||
thing1.put("value", "有新访客需要接待");
|
||||
thing2.put("value", "吉媒小红娘");
|
||||
data.put("thing1", thing1);
|
||||
data.put("thing2", thing2);
|
||||
|
||||
// 请求主服务器获取用户信息
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("access_token", getAccessToken());
|
||||
map.put("touser",oauthId); // "opEVj6e1YIlMyovkOQFCLJ7llmuI"
|
||||
map.put("touser", oauthId); // "opEVj6e1YIlMyovkOQFCLJ7llmuI"
|
||||
// 红娘来信通知
|
||||
map.put("template_id", templateId);
|
||||
map.put("miniprogram",JSONObject.toJSONString(miniprogram));
|
||||
map.put("data",data);
|
||||
map.put("miniprogram", JSONObject.toJSONString(miniprogram));
|
||||
map.put("data", data);
|
||||
// 新访客通知
|
||||
// map.put("tid","XMpEsDHmZZqpiaAzmPqO0Gk_h39WCRkaNZ9VoSI9F34");
|
||||
// map.put("page","https://admin.jimeigroup.cn");
|
||||
@@ -258,12 +258,12 @@ public class WxOfficialController extends BaseController {
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
System.out.println("jsonObject = " + jsonObject);
|
||||
if(jsonObject != null){
|
||||
if (jsonObject != null) {
|
||||
return success(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
return fail("请求失败",getAccessToken());
|
||||
return fail("请求失败", getAccessToken());
|
||||
}
|
||||
|
||||
// 调用接口凭证
|
||||
@@ -286,7 +286,7 @@ public class WxOfficialController extends BaseController {
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
redisUtil.set(key, result,7000L, TimeUnit.SECONDS);
|
||||
redisUtil.set(key, result, 7000L, TimeUnit.SECONDS);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
return null;
|
||||
@@ -324,25 +324,26 @@ public class WxOfficialController extends BaseController {
|
||||
if (entity != null) {
|
||||
String result = EntityUtils.toString(entity, "UTF-8");
|
||||
System.out.println("result = " + result);
|
||||
if(!result.contains("ok")){
|
||||
if (!result.contains("ok")) {
|
||||
System.out.println("result = " + result);
|
||||
String key = MP_OFFICIAL.concat(":access_token:5");
|
||||
redisUtil.delete(key);
|
||||
return fail(result);
|
||||
}
|
||||
return success("返回结果",entity);
|
||||
return success("返回结果", entity);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return fail("创建失败",url);
|
||||
return fail("创建失败", url);
|
||||
}
|
||||
|
||||
@ApiOperation("test")
|
||||
@PostMapping("/test")
|
||||
public ApiResult<?> count(){
|
||||
public ApiResult<?> count() {
|
||||
final int count = userOauthService.count(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getOauthType, MP_OFFICIAL).eq(UserOauth::getUnionid, "o0FaIuKa2UsVp6FCbvmZlrcaBRCM"));
|
||||
System.out.println("count = " + count);
|
||||
return success(getAccessToken());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class User implements UserDetails {
|
||||
private String companyName;
|
||||
|
||||
@ApiModelProperty("是否已实名认证")
|
||||
private Integer certification;
|
||||
private Boolean certification;
|
||||
|
||||
@ApiModelProperty("机构名称")
|
||||
@TableField(exist = false)
|
||||
|
||||
@@ -1,49 +1,56 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户角色
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:23
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "用户角色")
|
||||
@TableName("sys_user_role")
|
||||
public class UserRole implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Integer userId;
|
||||
@ApiModelProperty("用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
@ApiModelProperty("角色id")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("修改时间")
|
||||
private Date updateTime;
|
||||
@ApiModelProperty("修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
@TableField(exist = false)
|
||||
private String roleName;
|
||||
@ApiModelProperty("角色名称")
|
||||
@TableField(exist = false)
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private Integer tenantId;
|
||||
@ApiModelProperty("角色标识")
|
||||
@TableField(exist = false)
|
||||
private String roleCode;
|
||||
|
||||
@ApiModelProperty("租户ID")
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实名认证
|
||||
*
|
||||
@@ -65,6 +63,16 @@ public class UserVerify implements Serializable {
|
||||
@ApiModelProperty(value = "审核人")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "机构ID")
|
||||
private Integer organizationId;
|
||||
|
||||
@ApiModelProperty(value = "机构ID")
|
||||
@TableField(exist = false)
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty(value = "用户角色ID")
|
||||
private Integer userRoleId;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.gxwebsoft.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserRoleParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,35 +13,53 @@ import java.util.List;
|
||||
/**
|
||||
* 用户角色Mapper
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:02
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||
|
||||
/**
|
||||
* 批量添加用户角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id集合
|
||||
* @return int
|
||||
*/
|
||||
int insertBatch(@Param("userId") Integer userId, @Param("roleIds") List<Integer> roleIds);
|
||||
/**
|
||||
* 批量添加用户角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id集合
|
||||
* @return int
|
||||
*/
|
||||
int insertBatch(@Param("userId") Integer userId, @Param("roleIds") List<Integer> roleIds);
|
||||
|
||||
/**
|
||||
* 根据用户id查询角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return List<Role>
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<Role> selectByUserId(@Param("userId") Integer userId);
|
||||
/**
|
||||
* 根据用户id查询角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return List<Role>
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<Role> selectByUserId(@Param("userId") Integer userId);
|
||||
|
||||
/**
|
||||
* 批量根据用户id查询角色
|
||||
*
|
||||
* @param userIds 用户id集合
|
||||
* @return List<RoleResult>
|
||||
*/
|
||||
List<Role> selectByUserIds(@Param("userIds") List<Integer> userIds);
|
||||
/**
|
||||
* 批量根据用户id查询角色
|
||||
*
|
||||
* @param userIds 用户id集合
|
||||
* @return List<RoleResult>
|
||||
*/
|
||||
List<Role> selectByUserIds(@Param("userIds") List<Integer> userIds);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserRole>
|
||||
*/
|
||||
List<UserRole> selectPageRel(@Param("page") IPage<UserRole> page,
|
||||
@Param("param") UserRoleParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserRole> selectListRel(@Param("param") UserRoleParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +1,67 @@
|
||||
<?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" >
|
||||
<?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.gxwebsoft.common.system.mapper.UserRoleMapper">
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO sys_user_role(user_id, role_id) VALUES
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(#{userId}, #{roleId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO sys_user_role(user_id, role_id) VALUES
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(#{userId}, #{roleId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectByUserId" resultType="com.gxwebsoft.common.system.entity.Role">
|
||||
SELECT *
|
||||
FROM sys_role
|
||||
WHERE role_id IN (
|
||||
SELECT role_id
|
||||
FROM sys_user_role
|
||||
WHERE user_id = #{userId}
|
||||
)
|
||||
AND deleted = 0
|
||||
ORDER BY role_id desc
|
||||
</select>
|
||||
<select id="selectByUserId" resultType="com.gxwebsoft.common.system.entity.Role">
|
||||
SELECT *
|
||||
FROM sys_role
|
||||
WHERE role_id IN (SELECT role_id
|
||||
FROM sys_user_role
|
||||
WHERE user_id = #{userId})
|
||||
AND deleted = 0
|
||||
ORDER BY role_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectByUserIds" resultType="com.gxwebsoft.common.system.entity.Role">
|
||||
SELECT a.user_id, b.*
|
||||
FROM sys_user_role a
|
||||
LEFT JOIN sys_role b ON a.role_id = b.role_id
|
||||
WHERE a.user_id IN
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND b.deleted = 0
|
||||
</select>
|
||||
<select id="selectByUserIds" resultType="com.gxwebsoft.common.system.entity.Role">
|
||||
SELECT a.user_id, b.*
|
||||
FROM sys_user_role a
|
||||
LEFT JOIN sys_role b ON a.role_id = b.role_id
|
||||
WHERE a.user_id IN
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="userId">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND b.deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, b.role_name, b.role_code
|
||||
FROM sys_user_role a
|
||||
LEFT JOIN sys_role b ON a.role_id = b.role_id
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.roleId != null">
|
||||
AND a.role_id = #{param.roleId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.UserRole">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.UserRole">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*, b.phone
|
||||
SELECT a.*, b.phone, c.organization_name
|
||||
FROM sys_user_verify a
|
||||
LEFT JOIN sys_user b ON a.user_id = b.user_id
|
||||
LEFT JOIN sys_organization c ON a.organization_id = c.organization_id
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
@@ -38,6 +39,12 @@
|
||||
<if test="param.zzCode != null">
|
||||
AND a.zz_code = #{param.zzCode}
|
||||
</if>
|
||||
<if test="param.adminId != null">
|
||||
AND a.admin_id = #{param.adminId}
|
||||
</if>
|
||||
<if test="param.organizationId != null">
|
||||
AND a.organization_id = #{param.organizationId}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.common.system.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户角色查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserRoleParam对象", description = "用户角色查询参数")
|
||||
public class UserRoleParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键id")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "角色id")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer roleId;
|
||||
|
||||
}
|
||||
@@ -57,6 +57,14 @@ public class UserVerifyParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String zzCode;
|
||||
|
||||
@ApiModelProperty(value = "管理员ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "机构ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer organizationId;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
|
||||
@@ -1,43 +1,70 @@
|
||||
package com.gxwebsoft.common.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserRoleParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户角色Service
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:35
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
public interface UserRoleService extends IService<UserRole> {
|
||||
|
||||
/**
|
||||
* 批量添加用户角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id集合
|
||||
* @return int
|
||||
*/
|
||||
int saveBatch(Integer userId, List<Integer> roleIds);
|
||||
/**
|
||||
* 批量添加用户角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id集合
|
||||
* @return int
|
||||
*/
|
||||
int saveBatch(Integer userId, List<Integer> roleIds);
|
||||
|
||||
/**
|
||||
* 根据用户id查询角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return List<Role>
|
||||
*/
|
||||
List<Role> listByUserId(Integer userId);
|
||||
/**
|
||||
* 根据用户id查询角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return List<Role>
|
||||
*/
|
||||
List<Role> listByUserId(Integer userId);
|
||||
|
||||
/**
|
||||
* 批量根据用户id查询角色
|
||||
*
|
||||
* @param userIds 用户id集合
|
||||
* @return List<RoleResult>
|
||||
*/
|
||||
List<Role> listByUserIds(List<Integer> userIds);
|
||||
/**
|
||||
* 批量根据用户id查询角色
|
||||
*
|
||||
* @param userIds 用户id集合
|
||||
* @return List<RoleResult>
|
||||
*/
|
||||
List<Role> listByUserIds(List<Integer> userIds);
|
||||
|
||||
List<UserRole> listByRoleId(Integer roleId);
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserRole>
|
||||
*/
|
||||
PageResult<UserRole> pageRel(UserRoleParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserRole>
|
||||
*/
|
||||
List<UserRole> listRel(UserRoleParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键id
|
||||
* @return UserRole
|
||||
*/
|
||||
UserRole getByIdRel(Integer id);
|
||||
|
||||
List<UserRole> listByRoleId(Integer roleId);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.gxwebsoft.common.system.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.mapper.UserRoleMapper;
|
||||
import com.gxwebsoft.common.system.service.UserRoleService;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserRoleParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,30 +16,54 @@ import java.util.List;
|
||||
/**
|
||||
* 用户角色Service实现
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:36
|
||||
* @author 科技小王子
|
||||
* @since 2025-06-16 20:39:53
|
||||
*/
|
||||
@Service
|
||||
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
|
||||
|
||||
@Override
|
||||
public int saveBatch(Integer userId, List<Integer> roleIds) {
|
||||
return baseMapper.insertBatch(userId, roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBatch(Integer userId, List<Integer> roleIds) {
|
||||
return baseMapper.insertBatch(userId, roleIds);
|
||||
}
|
||||
@Override
|
||||
public List<Role> listByUserId(Integer userId) {
|
||||
return baseMapper.selectByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> listByUserId(Integer userId) {
|
||||
return baseMapper.selectByUserId(userId);
|
||||
}
|
||||
@Override
|
||||
public List<Role> listByUserIds(List<Integer> userIds) {
|
||||
return baseMapper.selectByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> listByUserIds(List<Integer> userIds) {
|
||||
return baseMapper.selectByUserIds(userIds);
|
||||
}
|
||||
@Override
|
||||
public List<UserRole> listByRoleId(Integer roleId) {
|
||||
return list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getRoleId, roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<UserRole> pageRel(UserRoleParam param) {
|
||||
PageParam<UserRole, UserRoleParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<UserRole> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRole> listRel(UserRoleParam param) {
|
||||
List<UserRole> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserRole, UserRoleParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole getByIdRel(Integer id) {
|
||||
UserRoleParam param = new UserRoleParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRole> listByRoleId(Integer roleId) {
|
||||
return list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getRoleId, roleId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class SysGenerator {
|
||||
// "sys_domain",
|
||||
// "sys_company",
|
||||
// "sys_user_verify"
|
||||
// "sys_user_role"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
|
||||
Reference in New Issue
Block a user