拆分核心模块
This commit is contained in:
@@ -6,15 +6,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.annotation.OperationModule;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.common.system.entity.OperationRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.OperationRecordService;
|
||||
import com.gxwebsoft.shop.entity.UserLook;
|
||||
import com.gxwebsoft.shop.service.UserLookService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
@@ -44,8 +41,6 @@ import java.util.Map;
|
||||
public class OperationLogAspect {
|
||||
@Resource
|
||||
private OperationRecordService operationRecordService;
|
||||
@Resource
|
||||
private UserLookService userLookService;
|
||||
|
||||
// 参数、返回结果、错误信息等最大保存长度
|
||||
private static final int MAX_LENGTH = 1000;
|
||||
@@ -128,19 +123,6 @@ public class OperationLogAspect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 记录访客日志
|
||||
// System.out.println("record = " + record);
|
||||
// if (record.getMethod().equals("com.gxwebsoft.love.controller.UserProfileController.detail")) {
|
||||
// final Integer toUserId = Integer.valueOf(StrUtil.removeSuffix(record.getParams()," "));
|
||||
// if (userLookService.count(new LambdaQueryWrapper<UserLook>().eq(UserLook::getUserId,record.getUserId()).eq(UserLook::getToUserId,toUserId)) == 0) {
|
||||
// final UserLook userLook = new UserLook();
|
||||
// userLook.setUserId(record.getUserId());
|
||||
// userLook.setToUserId(toUserId);
|
||||
// userLookService.save(userLook);
|
||||
// }
|
||||
// }
|
||||
|
||||
operationRecordService.saveAsync(record);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.gxwebsoft.common.core.Constants;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
@@ -108,16 +107,6 @@ public class JwtUtil {
|
||||
return JSONUtil.parseObject(claims.getSubject(), JwtSubject.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析支付方式里的json数据
|
||||
*
|
||||
* @param payment Payment
|
||||
* @return Payment
|
||||
*/
|
||||
public static Payment getPaymentConfig(Payment payment){
|
||||
return JSONUtil.parseObject(payment.getConfig(), Payment.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Key
|
||||
*
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
package com.gxwebsoft.common.core.utils;
|
||||
|
||||
import com.gxwebsoft.oa.entity.Assets;
|
||||
import com.gxwebsoft.oa.service.AssetsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 宝塔工具类
|
||||
* @author 科技小王子
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class BtUtil {
|
||||
public static Integer tenantId;
|
||||
public static String server;
|
||||
public static String token;
|
||||
private static String timestamp;
|
||||
@Resource
|
||||
private AssetsService assetsService;
|
||||
|
||||
// 实例化客户端
|
||||
public BtUtil client(Integer id) {
|
||||
Assets assets = assetsService.getByIdRel(id);
|
||||
try {
|
||||
String btSign = assets.getBtSign();
|
||||
server = "http://".concat(assets.getCode()).concat(":9003");
|
||||
String url = "http://".concat(assets.getCode()) + ":9003/system?action=GetSystemTotal";
|
||||
timestamp = (new Date().getTime()+"");
|
||||
String md5Sign = getMd5(btSign);
|
||||
String temp = timestamp+md5Sign;
|
||||
token = getMd5(temp);
|
||||
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
String responseText = sendPost(url,json);
|
||||
System.out.println("responseText = " + responseText);
|
||||
System.out.println(responseText);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSystemTotal(){
|
||||
String url = server.concat("/system?action=GetSystemTotal");
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
String responseText = sendPost(url,json);
|
||||
System.out.println("responseText = " + responseText);
|
||||
return responseText;
|
||||
}
|
||||
|
||||
public String getDiskInfo(){
|
||||
String url = server.concat("/system?action=GetDiskInfo");
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
return sendPost(url,json);
|
||||
}
|
||||
|
||||
// public void config()
|
||||
// {
|
||||
// try {
|
||||
// System.out.println("tenantId = " + tenantId);
|
||||
// String btSign = "XXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
// String url = "http://XXX.XXX.XXX.XXX:8888/system?action=GetSystemTotal";
|
||||
// String timestamp = (new Date().getTime()+"");
|
||||
// String md5Sign = getMd5(btSign);
|
||||
// String temp = timestamp+md5Sign;
|
||||
// String token = getMd5(temp);
|
||||
//
|
||||
// String json = "request_time="+timestamp+"&request_token="+token;
|
||||
// String responseText = sendPost(url,json);
|
||||
// System.out.println(responseText);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String getMd5(String str) throws Exception
|
||||
{
|
||||
try {
|
||||
// 生成一个MD5加密计算摘要
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
// 计算md5函数
|
||||
md.update(str.getBytes());
|
||||
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
|
||||
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
|
||||
return new BigInteger(1, md.digest()).toString(16);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("MD5加密出现错误,"+e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static String sendPost(String url, String param) {
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
StringBuffer result = new StringBuffer();
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "text/xml,text/javascript,text/html,application/json");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 发送请求参数
|
||||
out.print(param);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送 POST 请求出现异常!"+e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally{
|
||||
try{
|
||||
if(out!=null){
|
||||
out.close();
|
||||
}
|
||||
if(in!=null){
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch(IOException ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.gxwebsoft.common.core.utils;
|
||||
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 自动执行计划
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-14 08:38:19
|
||||
*/
|
||||
public class SchedulingUtil {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
// @Scheduled(cron="*/5 * * * * *")
|
||||
// public void reportCurrentTime() {
|
||||
// System.out.println("定时任务开始 = " + new Date());
|
||||
// int count = orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getPayStatus, 20));
|
||||
//// orderService.removeOrderByTimeOut();
|
||||
// System.out.println("count = " + count);
|
||||
// }
|
||||
}
|
||||
@@ -5,13 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.core.Constants;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.SignCheckUtil;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.service.MerchantClerkService;
|
||||
import com.gxwebsoft.shop.service.MerchantService;
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -21,10 +16,7 @@ import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Controller基类
|
||||
@@ -38,12 +30,6 @@ public class BaseController {
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private MerchantClerkService merchantClerkService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
@@ -207,98 +193,10 @@ public class BaseController {
|
||||
return request.getHeader("Authorization");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户所属的商户编号
|
||||
*
|
||||
* @return merchantCode
|
||||
*/
|
||||
public String getMerchantCode() {
|
||||
// 按店员查询
|
||||
return merchantClerkService.getMerchantCodeByClerk(getLoginUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录的商户信息
|
||||
*
|
||||
* @return merchantCode
|
||||
*/
|
||||
public Merchant getMerchant() {
|
||||
return merchantService.getMerchantByCode(getMerchantCode());
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
// 兼容小写
|
||||
if(request.getHeader("appid") != null){
|
||||
return request.getHeader("appid");
|
||||
}
|
||||
return request.getHeader("AppId");
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return request.getParameter("sign");
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否校验签名信息
|
||||
* 存在签名信息则需要验证
|
||||
*/
|
||||
public void isCheckSign() {
|
||||
if (StrUtil.isNotBlank(getSign())) {
|
||||
if(getTenantId() == null){
|
||||
throw new BusinessException("签名失败:TenantId不能为空");
|
||||
}
|
||||
|
||||
String timestamp1 = request.getParameter("timestamp");
|
||||
long timestamp2 = System.currentTimeMillis();
|
||||
long time = timestamp2 - Long.parseLong(timestamp1);
|
||||
if(time > 600000L){
|
||||
throw new BusinessException("签名失败:请求超时");
|
||||
}
|
||||
|
||||
Enumeration<String> names = request.getParameterNames();
|
||||
//2.遍历正文名称的枚举获得请求参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
while(names.hasMoreElements()){
|
||||
String name = names.nextElement();
|
||||
String value = request.getParameter(name);
|
||||
params.put(name,value);
|
||||
}
|
||||
String signString = SignCheckUtil.getSignString(params, getAppSecret());
|
||||
System.out.println("请求的参数 = " + params);
|
||||
System.out.println("正确的签名 = " + signString);
|
||||
System.out.println("签名是否正确 = " + SignCheckUtil.signCheck(params, getAppSecret()));
|
||||
|
||||
if (!SignCheckUtil.signCheck(params, getAppSecret())) {
|
||||
throw new BusinessException("签名失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 模拟提交参数
|
||||
// String key = "FRbMx1FkG4Qz6GZxY";
|
||||
// Map<String, String> param0 = new HashMap<>();
|
||||
// param0.put("orderId", "D2018062976332656413");
|
||||
// param0.put("MainAccountID", "DC3NHPJ73S");
|
||||
// param0.put("MainAccountSN", "320");
|
||||
// param0.put("payStatus", "2");
|
||||
// param0.put("title","测试");
|
||||
// System.out.println("请求的参数 = " + param0);
|
||||
// String signString0 = SignCheckUtil.getSignString(param0, key);
|
||||
// System.out.println("signString0 = " + signString0);
|
||||
|
||||
// return SignCheckUtil.signCheck(params, getAppSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前请求租户的AppSecret
|
||||
*
|
||||
* @return AppSecret
|
||||
*/
|
||||
public String getAppSecret() {
|
||||
String key = "cache5:AppSecret:" + Integer.valueOf(getAppId());
|
||||
System.out.println("key = " + key);
|
||||
return stringRedisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据账号|手机号码|邮箱查找用户ID
|
||||
* @return userId
|
||||
|
||||
@@ -71,7 +71,6 @@ public class FileController extends BaseController {
|
||||
result.setThumbnail(requestURL + "/thumbnail" + path);
|
||||
}
|
||||
result.setDownloadUrl(config.getFileServer() + "/download" + path);
|
||||
result.setMerchantCode(getMerchantCode());
|
||||
// 云存储配置
|
||||
final String s = redisUtil.get("setting:upload:" + getTenantId());
|
||||
final JSONObject jsonObject = JSONObject.parseObject(s);
|
||||
@@ -111,7 +110,6 @@ public class FileController extends BaseController {
|
||||
result.setPath(path);
|
||||
result.setUrl(requestURL + path);
|
||||
result.setThumbnail(FileServerUtil.isImage(upload) ? (requestURL + "/thumbnail" + path) : null);
|
||||
result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
@@ -148,7 +146,6 @@ public class FileController extends BaseController {
|
||||
result.setThumbnail(requestURL + "/thumbnail" + path);
|
||||
}
|
||||
result.setDownloadUrl(requestURL + "/download" + path);
|
||||
result.setMerchantCode(getMerchantCode());
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("name",result.getName());
|
||||
map.put("status","done");
|
||||
@@ -245,10 +242,6 @@ public class FileController extends BaseController {
|
||||
@ApiOperation("分页查询文件")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<FileRecord>> page(FileRecordParam param, HttpServletRequest request) {
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
PageResult<FileRecord> result = fileRecordService.pageRel(param);
|
||||
// String requestURL = StrUtil.removeSuffix(request.getRequestURL(), "/page");
|
||||
String requestURL = config.getFileServer();
|
||||
|
||||
@@ -1,242 +0,0 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.utils.FileServerUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.AccessKey;
|
||||
import com.gxwebsoft.common.system.entity.FileRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
|
||||
|
||||
/**
|
||||
* 文件上传下载控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:24
|
||||
*/
|
||||
@Api(tags = "文件服务器-文件预览")
|
||||
@RestController
|
||||
@RequestMapping("/api/file-preview")
|
||||
public class FilePreviewController extends BaseController {
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
@Resource
|
||||
private FileRecordService fileRecordService;
|
||||
@Resource
|
||||
private AccessKeyService accessKeyService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
public FilePreviewController(StringRedisTemplate redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
@ApiOperation("查看原文件")
|
||||
@GetMapping("/{dir}/{name:.+}")
|
||||
public void preview(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
HttpServletResponse response, HttpServletRequest request) {
|
||||
File file = new File(getUploadDir(), dir + "/" + name);
|
||||
FileServerUtil.preview(file, getPdfOutDir(), config.getOpenOfficeHome(), response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("下载原文件")
|
||||
@GetMapping("/download/{dir}/{name:.+}")
|
||||
public void download(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
HttpServletResponse response, HttpServletRequest request) {
|
||||
String path = dir + "/" + name;
|
||||
FileRecord record = fileRecordService.getByIdPath(path);
|
||||
File file = new File(getUploadDir(), path);
|
||||
String fileName = record == null ? file.getName() : record.getName();
|
||||
FileServerUtil.preview(file, true, fileName, null, null, response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("查看缩略图")
|
||||
@GetMapping("/thumbnail/{dir}/{name:.+}")
|
||||
public void thumbnail(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
HttpServletResponse response, HttpServletRequest request) {
|
||||
File file = new File(getUploadDir(), dir + "/" + name);
|
||||
File thumbnail = new File(getUploadSmDir(), dir + "/" + name);
|
||||
FileServerUtil.previewThumbnail(file, thumbnail, config.getThumbnailSize(), response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("查看缩略图")
|
||||
@GetMapping("/thumb/{dir}/{name:.+}")
|
||||
public void thumb(@PathVariable("dir") String dir, @PathVariable("name") String name,
|
||||
HttpServletResponse response, HttpServletRequest request) {
|
||||
File file = new File(getUploadDir(), dir + "/" + name);
|
||||
File thumbnail = new File(getUploadSmDir2(), dir + "/" + name);
|
||||
FileServerUtil.previewThumbnail(file, thumbnail, config.getThumbnailSize(), response, request);
|
||||
}
|
||||
|
||||
@ApiOperation("免密登录")
|
||||
@GetMapping("/token/{userId}/{accessKey}")
|
||||
public ApiResult<LoginResult> getToken(@PathVariable("userId") Integer userId, @PathVariable("accessKey") String accessKey) {
|
||||
// 免密登录 传指定的userId和AccessKey,请给指定的userId分配好角色和权限
|
||||
if (accessKeyService.count(new LambdaQueryWrapper<AccessKey>().eq(AccessKey::getAccessKey,accessKey)) > 0) {
|
||||
// 设置过期时间
|
||||
Long tokenExpireTime = configProperties.getTokenExpireTime();
|
||||
// 查询用户信息
|
||||
final User byId = userService.getById(userId);
|
||||
// 登录账号|手机号码|邮箱登录
|
||||
User user = userService.getByUsername(byId.getUsername(), byId.getTenantId());
|
||||
if(user == null){
|
||||
return fail("用户不存在",null);
|
||||
}
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
tokenExpireTime, configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
return fail("请求失败: 40010",null);
|
||||
}
|
||||
|
||||
@ApiOperation("APP应用信息")
|
||||
@GetMapping("/app-info2/{appid}/{accessKey}")
|
||||
public ApiResult<?> appInfo(@PathVariable("appid") Integer appId, @PathVariable("accessKey") String accessKey) {
|
||||
// 免密登录
|
||||
if (accessKeyService.count(new LambdaQueryWrapper<AccessKey>().eq(AccessKey::getAccessKey,accessKey)) > 0) {
|
||||
return success("操作成功", appService.getById(appId));
|
||||
}
|
||||
return fail("请求失败: 40011");
|
||||
}
|
||||
|
||||
@ApiOperation("获取企业信息")
|
||||
@GetMapping("/company-info2/{companyId}/{accessKey}")
|
||||
public ApiResult<?> companyInfo(@PathVariable("companyId") Integer companyId, @PathVariable("accessKey") String accessKey) {
|
||||
// 免密登录
|
||||
if (accessKeyService.count(new LambdaQueryWrapper<AccessKey>().eq(AccessKey::getAccessKey,accessKey)) > 0) {
|
||||
return success("操作成功", companyService.getById(companyId));
|
||||
}
|
||||
return fail("请求失败: 40012");
|
||||
}
|
||||
|
||||
@ApiOperation("获取微信小程序码")
|
||||
@GetMapping("/getQRCode")
|
||||
public ApiResult<?> getQRCode() {
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("path","pages/flash/index?user_id="+getLoginUserId());
|
||||
map.put("env_version","release");
|
||||
// map.put("env_version","trial");
|
||||
System.out.println("获取微信小程序码 = " + map);
|
||||
// 获取图片 Buffer
|
||||
byte[] qrCode = HttpRequest.post(apiUrl)
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().bodyBytes();
|
||||
|
||||
// 保存的文件名称
|
||||
final String fileName = CommonUtil.randomUUID8().concat(".png");
|
||||
// 保存路径
|
||||
String filePath = getUploadDir().concat("qrcode/") + fileName;
|
||||
File file = FileUtil.writeBytes(qrCode, filePath);
|
||||
if(file != null){
|
||||
return success("".concat("/qrcode/").concat(fileName));
|
||||
}
|
||||
return fail("获取失败",null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用凭据AccessToken
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
|
||||
*/
|
||||
private String getAccessToken() {
|
||||
String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString());
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 从缓存获取access_token
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
// 微信获取凭证接口
|
||||
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 组装url参数
|
||||
String url = apiUrl.concat("?grant_type=client_credential").concat("&appid=").concat(setting.getString("appId")).concat("&secret=").concat(setting.getString("appSecret"));
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(url);
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
redisTemplate.opsForValue().set(key, result,7000L, TimeUnit.SECONDS);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传基目录
|
||||
*/
|
||||
private String getUploadBaseDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
}
|
||||
|
||||
/**
|
||||
* office转pdf输出位置
|
||||
*/
|
||||
private String getPdfOutDir() {
|
||||
return getUploadBaseDir() + "pdf/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传位置(服务器)
|
||||
*/
|
||||
private String getUploadDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 缩略图生成位置
|
||||
*/
|
||||
private String getUploadSmDir() {
|
||||
return getUploadBaseDir() + "thumbnail/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 缩略图生成位置
|
||||
*/
|
||||
private String getUploadSmDir2() {
|
||||
return getUploadBaseDir() + "thumb/";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,6 @@ import com.gxwebsoft.common.system.service.DictionaryDataService;
|
||||
import com.gxwebsoft.common.system.service.OrganizationService;
|
||||
import com.gxwebsoft.common.system.service.RoleService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.love.entity.UserProfile;
|
||||
import com.gxwebsoft.love.service.UserProfileService;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@@ -58,10 +54,6 @@ public class UserController extends BaseController {
|
||||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private UserProfileService userProfileService;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:user:list')")
|
||||
@OperationLog
|
||||
@@ -108,14 +100,6 @@ public class UserController extends BaseController {
|
||||
user.setStatus(null);
|
||||
user.setUsername(null);
|
||||
user.setPassword(null);
|
||||
// 前端请求限制仅可以修改自己的用户信息
|
||||
if (getAppId() != null) {
|
||||
user.setUserId(getLoginUserId());
|
||||
}
|
||||
// 保存详细资料
|
||||
if(user.getUserProfile() != null){
|
||||
userProfileService.update(user.getUserProfile(),new LambdaUpdateWrapper<UserProfile>().eq(UserProfile::getUserId,user.getUserId()));
|
||||
}
|
||||
if (userService.updateUser(user)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
@@ -128,8 +112,6 @@ public class UserController extends BaseController {
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userService.removeById(id)) {
|
||||
QueryWrapper<UserOauth> userOauthQueryWrapper = new QueryWrapper<>();
|
||||
userOauthService.remove(userOauthQueryWrapper.eq("user_id",id));
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
@@ -155,10 +137,6 @@ public class UserController extends BaseController {
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> deleteBatch(@RequestBody List<Integer> ids) {
|
||||
ids.forEach(userId -> {
|
||||
QueryWrapper<UserOauth> userOauthQueryWrapper = new QueryWrapper<>();
|
||||
userOauthService.remove(userOauthQueryWrapper.eq("user_id",userId));
|
||||
});
|
||||
if (userService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
@@ -193,8 +171,6 @@ public class UserController extends BaseController {
|
||||
User u = new User();
|
||||
u.setUserId(user.getUserId());
|
||||
u.setRecommend(user.getRecommend());
|
||||
// 同步修改资料表
|
||||
userProfileService.updateById(user.getUserProfile());
|
||||
if (userService.updateById(u)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserGradeService;
|
||||
import com.gxwebsoft.common.system.entity.UserGrade;
|
||||
import com.gxwebsoft.common.system.param.UserGradeParam;
|
||||
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 io.swagger.annotations.Api;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户会员等级表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:51:17
|
||||
*/
|
||||
@Api(tags = "用户会员等级表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/common.system/user-grade")
|
||||
public class UserGradeController extends BaseController {
|
||||
@Resource
|
||||
private UserGradeService userGradeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户会员等级表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserGrade>> page(UserGradeParam param) {
|
||||
// 使用关联查询
|
||||
return success(userGradeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户会员等级表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserGrade>> list(UserGradeParam param) {
|
||||
// 使用关联查询
|
||||
return success(userGradeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户会员等级表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserGrade> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userGradeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户会员等级表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserGrade userGrade) {
|
||||
if (userGradeService.save(userGrade)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户会员等级表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserGrade userGrade) {
|
||||
if (userGradeService.updateById(userGrade)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户会员等级表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userGradeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户会员等级表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserGrade> list) {
|
||||
if (userGradeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户会员等级表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserGrade> batchParam) {
|
||||
if (batchParam.update(userGradeService, "grade_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userGrade:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户会员等级表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userGradeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserOauthService;
|
||||
import com.gxwebsoft.common.system.entity.UserOauth;
|
||||
import com.gxwebsoft.common.system.param.UserOauthParam;
|
||||
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 io.swagger.annotations.Api;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:39:46
|
||||
*/
|
||||
@Api(tags = "第三方用户信息表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/common.system/user-oauth")
|
||||
public class UserOauthController extends BaseController {
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询第三方用户信息表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserOauth>> page(UserOauthParam param) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部第三方用户信息表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserOauth>> list(UserOauthParam param) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询第三方用户信息表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserOauth> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加第三方用户信息表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserOauth userOauth) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userOauth.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userOauthService.save(userOauth)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改第三方用户信息表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserOauth userOauth) {
|
||||
if (userOauthService.updateById(userOauth)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除第三方用户信息表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userOauthService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加第三方用户信息表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserOauth> list) {
|
||||
if (userOauthService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改第三方用户信息表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserOauth> batchParam) {
|
||||
if (batchParam.update(userOauthService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:userOauth:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除第三方用户信息表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userOauthService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
@@ -24,27 +23,16 @@ import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.love.entity.UserProfile;
|
||||
import com.gxwebsoft.love.service.UserProfileService;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.entity.UserReferee;
|
||||
import com.gxwebsoft.shop.service.MerchantService;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import com.gxwebsoft.shop.service.UserRefereeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
|
||||
@@ -63,19 +51,11 @@ public class WxLoginController extends BaseController {
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
@Resource
|
||||
private UserProfileService userProfileService;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
|
||||
public WxLoginController(StringRedisTemplate redisTemplate) {
|
||||
this.redisTemplate = redisTemplate;
|
||||
@@ -97,14 +77,6 @@ public class WxLoginController extends BaseController {
|
||||
// 3.存在则签发token并返回登录成功,不存在则注册新用户
|
||||
if (user == null) {
|
||||
user = addUser(userParam);
|
||||
// 添加第三方用户信息
|
||||
UserOauth uo = new UserOauth();
|
||||
uo.setUserId(user.getUserId());
|
||||
uo.setTenantId(user.getTenantId());
|
||||
uo.setOauthType("MP-WEIXIN");
|
||||
uo.setOauthId(openid);
|
||||
uo.setUnionid(unionid);
|
||||
userOauthService.save(uo);
|
||||
}
|
||||
// 4.签发token
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
@@ -180,42 +152,6 @@ public class WxLoginController extends BaseController {
|
||||
userRole.setTenantId(addUser.getTenantId());
|
||||
userRole.setRoleId(addUser.getRoleId());
|
||||
userRoleService.save(userRole);
|
||||
// 用户详细资料表
|
||||
final UserProfile profile = new UserProfile();
|
||||
profile.setUserId(addUser.getUserId());
|
||||
profile.setRecommend(1);
|
||||
profile.setWhenMarriedMate("想要二年内结婚");
|
||||
userProfileService.save(profile);
|
||||
// 添加门店
|
||||
final Merchant merchant = new Merchant();
|
||||
merchant.setUserId(addUser.getUserId());
|
||||
merchant.setMerchantOwner(addUser.getUserId());
|
||||
merchant.setMerchantCode(addUser.getUserId()+"");
|
||||
merchant.setMerchantName(addUser.getNickname());
|
||||
merchant.setLogo(addUser.getAvatar());
|
||||
merchant.setProvince(addUser.getProvince());
|
||||
merchant.setCity(addUser.getCity());
|
||||
merchant.setRegion(addUser.getRegion());
|
||||
merchant.setMerchantPhone(addUser.getPhone());
|
||||
merchant.setMerchantHours("8:30 - 22:30");
|
||||
merchant.setSortNumber(100);
|
||||
merchant.setStatus(0);
|
||||
merchant.setFirstRatio(new BigDecimal("0.1"));
|
||||
merchant.setSecondRatio(new BigDecimal("0.1"));
|
||||
merchant.setOnlineRatio(new BigDecimal("0.1"));
|
||||
merchant.setOfflineRatio(new BigDecimal("0"));
|
||||
merchant.setShopRatio(new BigDecimal("0"));
|
||||
merchant.setTenantId(addUser.getTenantId());
|
||||
merchantService.save(merchant);
|
||||
}
|
||||
// 绑定推荐关系
|
||||
if(userParam.getRefereeId() != null && userParam.getRefereeId() > 0){
|
||||
final Integer refereeId = userParam.getRefereeId();
|
||||
final UserReferee userReferee = new UserReferee();
|
||||
userReferee.setUserId(addUser.getUserId());
|
||||
userReferee.setDealerId(refereeId);
|
||||
userReferee.setLevel(1);
|
||||
userRefereeService.save(userReferee);
|
||||
}
|
||||
return addUser;
|
||||
}
|
||||
@@ -322,18 +258,6 @@ public class WxLoginController extends BaseController {
|
||||
final String response = HttpUtil.get(apiUrl,map);
|
||||
System.out.println("response = " + response);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
|
||||
// 保存openid
|
||||
final List<UserOauth> list = userOauthService.list(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getUserId, loginUser.getUserId()).eq(UserOauth::getOauthType,"MP-WEIXIN"));
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
final UserOauth userOauth = new UserOauth();
|
||||
userOauth.setUserId(getLoginUserId());
|
||||
userOauth.setOauthId(jsonObject.getString("openid"));
|
||||
userOauth.setUnionid(jsonObject.getString("unionid"));
|
||||
userOauth.setOauthType("MP-WEIXIN");
|
||||
userOauthService.save(userOauth);
|
||||
return success("保存openid成功",jsonObject);
|
||||
}
|
||||
return fail("更新失败",null);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ package com.gxwebsoft.common.system.entity;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gxwebsoft.love.entity.UserPlanEquity;
|
||||
import com.gxwebsoft.love.entity.UserProfile;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -219,10 +216,6 @@ public class User implements UserDetails {
|
||||
@TableField(exist = false)
|
||||
private List<Role> roles;
|
||||
|
||||
@ApiModelProperty("详细资料")
|
||||
@TableField(exist = false)
|
||||
private UserProfile userProfile;
|
||||
|
||||
@ApiModelProperty("权限列表")
|
||||
@TableField(exist = false)
|
||||
private List<Menu> authorities;
|
||||
@@ -267,18 +260,10 @@ public class User implements UserDetails {
|
||||
@TableField(exist = false)
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("应用信息")
|
||||
@TableField(exist = false)
|
||||
private App appInfo;
|
||||
|
||||
@ApiModelProperty("企业信息")
|
||||
@TableField(exist = false)
|
||||
private Company companyInfo;
|
||||
|
||||
@ApiModelProperty("权益列表")
|
||||
@TableField(exist = false)
|
||||
private List<UserPlanEquity> userPlanEquityList;
|
||||
|
||||
@ApiModelProperty("系统配置信息")
|
||||
@TableField(exist = false)
|
||||
private Object system;
|
||||
@@ -302,14 +287,7 @@ public class User implements UserDetails {
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// public String getRealName(){
|
||||
// return DesensitizedUtil.chineseName(this.realName);
|
||||
// }
|
||||
//
|
||||
// public String getIdCard(){
|
||||
// return DesensitizedUtil.idCardNum(this.idCard,1,2);
|
||||
// }
|
||||
|
||||
public String getMobile(){
|
||||
return DesensitizedUtil.mobilePhone(this.phone);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户会员等级表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:51:17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "UserGrade对象", description = "用户会员等级表")
|
||||
@TableName("sys_user_grade")
|
||||
public class UserGrade implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "等级ID")
|
||||
@TableId(value = "grade_id", type = IdType.AUTO)
|
||||
private Integer gradeId;
|
||||
|
||||
@ApiModelProperty(value = "等级名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "等级权重(1-9999)")
|
||||
private Integer weight;
|
||||
|
||||
@ApiModelProperty(value = "升级条件")
|
||||
private String upgrade;
|
||||
|
||||
@ApiModelProperty(value = "等级权益(折扣率0-100)")
|
||||
private String equity;
|
||||
|
||||
@ApiModelProperty(value = "佣金比率")
|
||||
private String commission;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:39:46
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "UserOauth对象", description = "第三方用户信息表")
|
||||
@TableName("sys_user_oauth")
|
||||
public class UserOauth implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "第三方登陆类型(MP-WEIXIN)")
|
||||
private String oauthType;
|
||||
|
||||
@ApiModelProperty(value = "第三方用户唯一标识 (uid openid)")
|
||||
private String oauthId;
|
||||
|
||||
@ApiModelProperty(value = "微信unionID")
|
||||
private String unionid;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.system.entity.UserGrade;
|
||||
import com.gxwebsoft.common.system.param.UserGradeParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户会员等级表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:51:17
|
||||
*/
|
||||
public interface UserGradeMapper extends BaseMapper<UserGrade> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserGrade>
|
||||
*/
|
||||
List<UserGrade> selectPageRel(@Param("page") IPage<UserGrade> page,
|
||||
@Param("param") UserGradeParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserGrade> selectListRel(@Param("param") UserGradeParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.system.entity.UserOauth;
|
||||
import com.gxwebsoft.common.system.param.UserOauthParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:39:46
|
||||
*/
|
||||
public interface UserOauthMapper extends BaseMapper<UserOauth> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<UserOauth>
|
||||
*/
|
||||
List<UserOauth> selectPageRel(@Param("page") IPage<UserOauth> page,
|
||||
@Param("param") UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<UserOauth> selectListRel(@Param("param") UserOauthParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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.UserGradeMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_user_grade a
|
||||
<where>
|
||||
<if test="param.gradeId != null">
|
||||
AND a.grade_id = #{param.gradeId}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.weight != null">
|
||||
AND a.weight = #{param.weight}
|
||||
</if>
|
||||
<if test="param.upgrade != null">
|
||||
AND a.upgrade LIKE CONCAT('%', #{param.upgrade}, '%')
|
||||
</if>
|
||||
<if test="param.equity != null">
|
||||
AND a.equity LIKE CONCAT('%', #{param.equity}, '%')
|
||||
</if>
|
||||
<if test="param.commission != null">
|
||||
AND a.commission LIKE CONCAT('%', #{param.commission}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||
</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.UserGrade">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.UserGrade">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -175,7 +175,7 @@
|
||||
LEFT JOIN (
|
||||
<include refid="selectSexDictSql"/>
|
||||
) c ON a.sex = c.dict_data_code
|
||||
LEFT JOIN shop_user_oauth f ON f.user_id = a.user_id and f.oauth_type = 'MP-WEIXIN'
|
||||
LEFT JOIN sys_user_oauth f ON f.user_id = a.user_id and f.oauth_type = 'MP-WEIXIN'
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
AND (a.username = #{username} OR a.phone = #{username} OR a.email = #{username})
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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.UserOauthMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_user_oauth a
|
||||
<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.oauthType != null">
|
||||
AND a.oauth_type LIKE CONCAT('%', #{param.oauthType}, '%')
|
||||
</if>
|
||||
<if test="param.oauthId != null">
|
||||
AND a.oauth_id LIKE CONCAT('%', #{param.oauthId}, '%')
|
||||
</if>
|
||||
<if test="param.unionid != null">
|
||||
AND a.unionid LIKE CONCAT('%', #{param.unionid}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.merchantCode != null">
|
||||
AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
|
||||
</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.UserOauth">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.UserOauth">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,63 @@
|
||||
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 2023-10-07 22:51:17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserGradeParam对象", description = "用户会员等级表查询参数")
|
||||
public class UserGradeParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "等级ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer gradeId;
|
||||
|
||||
@ApiModelProperty(value = "等级名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "等级权重(1-9999)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer weight;
|
||||
|
||||
@ApiModelProperty(value = "升级条件")
|
||||
private String upgrade;
|
||||
|
||||
@ApiModelProperty(value = "等级权益(折扣率0-100)")
|
||||
private String equity;
|
||||
|
||||
@ApiModelProperty(value = "佣金比率")
|
||||
private String commission;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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 2023-10-07 22:39:46
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "UserOauthParam对象", description = "第三方用户信息表查询参数")
|
||||
public class UserOauthParam 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 = "第三方登陆类型(MP-WEIXIN)")
|
||||
private String oauthType;
|
||||
|
||||
@ApiModelProperty(value = "第三方用户唯一标识 (uid openid)")
|
||||
private String oauthId;
|
||||
|
||||
@ApiModelProperty(value = "微信unionID")
|
||||
private String unionid;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商户编码")
|
||||
private String merchantCode;
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ 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 com.gxwebsoft.love.entity.UserProfile;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -191,10 +190,6 @@ public class UserParam extends BaseParam {
|
||||
@TableField(exist = false)
|
||||
private Set<Integer> userIds;
|
||||
|
||||
@ApiModelProperty("详细资料")
|
||||
@TableField(exist = false)
|
||||
private UserProfile userProfile;
|
||||
|
||||
@ApiModelProperty("是否查询用户详细资料表")
|
||||
@TableField(exist = false)
|
||||
private Boolean showProfile;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
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.LoginRecord;
|
||||
import com.gxwebsoft.common.system.param.LoginRecordParam;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付宝服务层
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:41
|
||||
*/
|
||||
public interface AlipayService extends IService<Payment> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
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.UserGrade;
|
||||
import com.gxwebsoft.common.system.param.UserGradeParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户会员等级表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:51:17
|
||||
*/
|
||||
public interface UserGradeService extends IService<UserGrade> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserGrade>
|
||||
*/
|
||||
PageResult<UserGrade> pageRel(UserGradeParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserGrade>
|
||||
*/
|
||||
List<UserGrade> listRel(UserGradeParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param gradeId 等级ID
|
||||
* @return UserGrade
|
||||
*/
|
||||
UserGrade getByIdRel(Integer gradeId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
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.UserOauth;
|
||||
import com.gxwebsoft.common.system.param.UserOauthParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:39:46
|
||||
*/
|
||||
public interface UserOauthService extends IService<UserOauth> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<UserOauth>
|
||||
*/
|
||||
PageResult<UserOauth> pageRel(UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<UserOauth>
|
||||
*/
|
||||
List<UserOauth> listRel(UserOauthParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return UserOauth
|
||||
*/
|
||||
UserOauth getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -31,7 +31,6 @@ public interface UserService extends IService<User>, UserDetailsService {
|
||||
* @return List<User>
|
||||
*/
|
||||
List<User> listRel(UserParam param);
|
||||
void listRanking(UserParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询用户
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.common.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.mapper.UserGradeMapper;
|
||||
import com.gxwebsoft.common.system.service.UserGradeService;
|
||||
import com.gxwebsoft.common.system.entity.UserGrade;
|
||||
import com.gxwebsoft.common.system.param.UserGradeParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户会员等级表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:51:17
|
||||
*/
|
||||
@Service
|
||||
public class UserGradeServiceImpl extends ServiceImpl<UserGradeMapper, UserGrade> implements UserGradeService {
|
||||
|
||||
@Override
|
||||
public PageResult<UserGrade> pageRel(UserGradeParam param) {
|
||||
PageParam<UserGrade, UserGradeParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<UserGrade> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserGrade> listRel(UserGradeParam param) {
|
||||
List<UserGrade> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserGrade, UserGradeParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserGrade getByIdRel(Integer gradeId) {
|
||||
UserGradeParam param = new UserGradeParam();
|
||||
param.setGradeId(gradeId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.common.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.mapper.UserOauthMapper;
|
||||
import com.gxwebsoft.common.system.service.UserOauthService;
|
||||
import com.gxwebsoft.common.system.entity.UserOauth;
|
||||
import com.gxwebsoft.common.system.param.UserOauthParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 第三方用户信息表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-10-07 22:39:46
|
||||
*/
|
||||
@Service
|
||||
public class UserOauthServiceImpl extends ServiceImpl<UserOauthMapper, UserOauth> implements UserOauthService {
|
||||
|
||||
@Override
|
||||
public PageResult<UserOauth> pageRel(UserOauthParam param) {
|
||||
PageParam<UserOauth, UserOauthParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<UserOauth> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOauth> listRel(UserOauthParam param) {
|
||||
List<UserOauth> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<UserOauth, UserOauthParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserOauth getByIdRel(Integer id) {
|
||||
UserOauthParam param = new UserOauthParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,9 @@ package com.gxwebsoft.common.system.service.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
@@ -17,37 +15,22 @@ import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.mapper.UserMapper;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.love.entity.UserPlanEquity;
|
||||
import com.gxwebsoft.love.entity.UserProfile;
|
||||
import com.gxwebsoft.love.param.UserProfileParam;
|
||||
import com.gxwebsoft.love.service.UserPlanEquityService;
|
||||
import com.gxwebsoft.love.service.UserProfileService;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.entity.MerchantClerk;
|
||||
import com.gxwebsoft.shop.service.MerchantClerkService;
|
||||
import com.gxwebsoft.shop.service.MerchantService;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import com.gxwebsoft.common.system.service.RoleMenuService;
|
||||
import com.gxwebsoft.common.system.service.UserRoleService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.USER_RANKING_BY_APPS;
|
||||
|
||||
/**
|
||||
* 用户Service实现
|
||||
*
|
||||
@@ -63,26 +46,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
@Resource
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private MerchantClerkService merchantClerkService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private UserProfileService userProfileService;
|
||||
|
||||
@Resource
|
||||
private UserPlanEquityService userPlanEquityService;
|
||||
|
||||
@Override
|
||||
public PageResult<User> pageRel(UserParam param) {
|
||||
@@ -91,10 +55,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
List<User> list = baseMapper.selectPageRel(page, param);
|
||||
// 查询用户的角色
|
||||
selectUserRoles(list);
|
||||
// 查询用户详细资料
|
||||
if (param.getShowProfile() != null) {
|
||||
selectUserProfile(list);
|
||||
}
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@@ -109,18 +69,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listRanking(UserParam param) {
|
||||
List<User> list = baseMapper.selectListRel(param);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
list.forEach(d -> {
|
||||
int count = appService.count(new LambdaQueryWrapper<App>()
|
||||
.eq(App::getUserId, d.getUserId()));
|
||||
// 更新全部用户的插件数量
|
||||
cacheClient.zAdd(USER_RANKING_BY_APPS, d.getUserId(), (double) count);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getByIdRel(Integer userId) {
|
||||
UserParam param = new UserParam();
|
||||
@@ -163,24 +111,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
final Company company = redisUtil.get(key2, Company.class);
|
||||
user.setCompanyInfo(company);
|
||||
user.setSystem(map);
|
||||
// 商户编号
|
||||
Merchant merchant = merchantService.getOne(new QueryWrapper<Merchant>()
|
||||
.eq("merchant_owner", user.getUserId()), false);
|
||||
if (merchant != null) {
|
||||
user.setMerchantCode(merchant.getMerchantCode());
|
||||
user.setMerchantName(merchant.getMerchantName());
|
||||
} else {
|
||||
MerchantClerk clerk = merchantClerkService.getOne(new QueryWrapper<MerchantClerk>().eq("user_id", user.getUserId()), false);
|
||||
if (clerk != null) {
|
||||
user.setMerchantCode(clerk.getMerchantCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 我的权益
|
||||
List<UserPlanEquity> userPlanEquityList = userPlanEquityService.list(new LambdaQueryWrapper<UserPlanEquity>()
|
||||
.eq(UserPlanEquity::getUserId, userId)
|
||||
.gt(UserPlanEquity::getExpirationTime, LocalDateTime.now()));
|
||||
user.setUserPlanEquityList(userPlanEquityList);
|
||||
|
||||
}
|
||||
return user;
|
||||
@@ -320,27 +250,4 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询用户的详细资料
|
||||
*
|
||||
* @param users 用户集合
|
||||
*/
|
||||
private void selectUserProfile(List<User> users) {
|
||||
if (users != null && users.size() > 0) {
|
||||
Set<Integer> userIds = users.stream().map(User::getUserId).collect(Collectors.toSet());
|
||||
final UserProfileParam userProfileParam = new UserProfileParam();
|
||||
userProfileParam.setUserIds(userIds);
|
||||
final List<UserProfile> userProfiles = userProfileService.listRel(userProfileParam);
|
||||
final Map<Integer, List<UserProfile>> collect = userProfiles.stream().collect(Collectors.groupingBy(UserProfile::getUserId));
|
||||
for (User user: users){
|
||||
final List<UserProfile> list = collect.get(user.getUserId());
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
final UserProfile profile = collect.get(user.getUserId()).get(0);
|
||||
user.setUserProfile(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user