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