Merge branch 'preview' of https://gitea.qinmian.online/CY/mcwl-ai into feature/resource
commit
dcce7b4b29
|
@ -2,6 +2,8 @@ package com.mcwl;
|
|||
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
|
@ -37,4 +39,10 @@ public class McWlApplication
|
|||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||
return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
}
|
||||
|
||||
// mq 消息转换器
|
||||
@Bean
|
||||
public MessageConverter jacksonMessageConverter() {
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
package com.mcwl.web.controller.common;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.GetObjectRequest;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Oss服务调用
|
||||
*/
|
||||
@Log4j2
|
||||
public class OssUtil {
|
||||
|
||||
/**
|
||||
* Endpoint 存储对象概述 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限 访问路径前缀 存储对象概述
|
||||
*/
|
||||
private static String endPoint = "oss-cn-beijing.aliyuncs.com";
|
||||
private static String accessKeyId = "LTAI5tSHZZ8wHJRP8X4r9TXT";
|
||||
private static String accessKeySecret = "F82IVNx0IGJ3AnP6gSIfcyql1HCXIH";
|
||||
private static String accessPre = "https://ybl2112.oss-cn-beijing.aliyuncs.com/";
|
||||
|
||||
/**
|
||||
* bucket名称
|
||||
* @return
|
||||
*/
|
||||
private static String bucketName = "ybl2112";
|
||||
|
||||
private static OSS ossClient ;
|
||||
|
||||
static {
|
||||
ossClient = new OSSClientBuilder().build(
|
||||
endPoint,
|
||||
accessKeyId,
|
||||
accessKeySecret);
|
||||
log.info("oss服务连接成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传本地文件
|
||||
* @param filePath
|
||||
*/
|
||||
public static String uploadFile(String filePath){
|
||||
return uploadFileForBucket(bucketName,getOssFilePath(filePath) ,filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认路径上传multipartFile文件
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(MultipartFile multipartFile) {
|
||||
return uploadMultipartFile(bucketName,getOssFilePath(multipartFile.getOriginalFilename()),multipartFile);
|
||||
}
|
||||
/**
|
||||
* 上传 multipartFile 类型文件
|
||||
* @param bucketName
|
||||
* @param ossPath
|
||||
* @param multipartFile
|
||||
*/
|
||||
public static String uploadMultipartFile(String bucketName , String ossPath , MultipartFile multipartFile){
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = multipartFile.getInputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用File上传PutObject上传文件 ** 程序默认使用次方法上传
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileForBucket(String bucketName , String ossPath , String filePath) {
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, ossPath, new File(filePath));
|
||||
|
||||
// 上传
|
||||
ossClient.putObject(putObjectRequest);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用文件流上传到指定的bucket实例
|
||||
* @param bucketName 实例名称
|
||||
* @param ossPath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static String uploadFileInputStreamForBucket(String bucketName , String ossPath , String filePath){
|
||||
|
||||
// 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件流。
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = new FileInputStream(filePath);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 填写Bucket名称和Object完整路径。Object完整路径中不能包含Bucket名称。
|
||||
uploadFileInputStreamForBucket(bucketName, ossPath, inputStream);
|
||||
return accessPre+ossPath;
|
||||
}
|
||||
|
||||
public static void uploadFileInputStreamForBucket(String bucketName , String ossPath , InputStream inputStream ){
|
||||
ossClient.putObject(bucketName, ossPath, inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
* @param ossFilePath
|
||||
* @param filePath
|
||||
*/
|
||||
public static void downloadFile(String ossFilePath , String filePath ){
|
||||
downloadFileForBucket(bucketName , ossFilePath , filePath);
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
* @param bucketName 实例名称
|
||||
* @param ossFilePath oss存储路径
|
||||
* @param filePath 本地文件路径
|
||||
*/
|
||||
public static void downloadFileForBucket(String bucketName , String ossFilePath , String filePath ){
|
||||
ossClient.getObject(new GetObjectRequest(bucketName, ossFilePath), new File(filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getOssDefaultPath(){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String url =
|
||||
now.getYear()+"/"+
|
||||
now.getMonth()+"/"+
|
||||
now.getDayOfMonth()+"/"+
|
||||
now.getHour()+"/"+
|
||||
now.getMinute()+"/";
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String getOssFilePath(String filePath){
|
||||
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
||||
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,20 @@
|
|||
package com.mcwl.web.controller.resource;
|
||||
import com.mcwl.common.annotation.Anonymous;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.common.core.controller.BaseController;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.common.domain.IdsParam;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import com.mcwl.resource.service.MallProductService;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 商品
|
||||
* @Author:ChenYan
|
||||
* @Project:McWl
|
||||
* @Package:com.mcwl.web.controller.resource
|
||||
|
@ -83,4 +87,15 @@ public class MallProductController extends BaseController {
|
|||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看用户发布的作品
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selectByUserId")
|
||||
public AjaxResult selectByUserId(@RequestBody MallProductVo mallProductVo){
|
||||
|
||||
Page<MallProduct> mallProductList = mallProductRuleInfoService.selectByUserId(mallProductVo);
|
||||
return AjaxResult.success(mallProductList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.mcwl.web.controller.resource;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
import com.mcwl.resource.service.MallProductLikeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 点赞商品
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
@RequestMapping("like")
|
||||
@RestController
|
||||
public class MallProductLikeController {
|
||||
|
||||
@Autowired
|
||||
private MallProductLikeService mallProductLikeService;
|
||||
|
||||
@PostMapping("/selectByUserLike")
|
||||
public AjaxResult selectByUserLike(@RequestBody MallProductVo mallProductVo){
|
||||
|
||||
Page<MallProduct> mallProductPage = mallProductLikeService.selectByUserLike(mallProductVo);
|
||||
return AjaxResult.success(mallProductPage);
|
||||
}
|
||||
}
|
|
@ -86,7 +86,7 @@ public class SysLoginController
|
|||
|
||||
rabbitTemplate.convertAndSend(QueueConstants.CODE_QUEUE,s);
|
||||
|
||||
return AjaxResult.success();
|
||||
return AjaxResult.success(s);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,20 @@ import com.mcwl.common.core.domain.AjaxResult;
|
|||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.common.core.domain.model.LoginUser;
|
||||
import com.mcwl.common.core.redis.RedisCache;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.common.utils.uuid.IdUtils;
|
||||
import com.mcwl.framework.web.service.SysPermissionService;
|
||||
import com.mcwl.framework.web.service.TokenService;
|
||||
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import com.mcwl.system.service.ISysUserThirdAccountService;
|
||||
import com.mcwl.system.service.IWXService;
|
||||
import com.mcwl.web.controller.common.OssUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
@ -30,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @apiNote
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx")
|
||||
public class WXController {
|
||||
|
@ -37,6 +41,12 @@ public class WXController {
|
|||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@Resource
|
||||
private ISysUserThirdAccountService iSysUserThirdAccountService;
|
||||
|
||||
|
@ -49,6 +59,13 @@ public class WXController {
|
|||
@Resource
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Anonymous
|
||||
@PostMapping("/test")
|
||||
public AjaxResult test(@RequestParam MultipartFile file){
|
||||
|
||||
String s = OssUtil.uploadMultipartFile(file);
|
||||
return AjaxResult.success(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码登录用uuid生成
|
||||
|
@ -91,17 +108,21 @@ public class WXController {
|
|||
@Anonymous
|
||||
@GetMapping("/uuid/login")
|
||||
public AjaxResult loginByOpenId(@RequestParam("uuid") String uuid) throws IOException {
|
||||
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
String verifyKey = CacheConstants.WX_OPENID_KEY + uuid;
|
||||
String openid = redisCache.getCacheObject(verifyKey);
|
||||
// String openid = redisCache.getCacheObject(verifyKey);
|
||||
String openid = redisTemplate.opsForValue().get(verifyKey);
|
||||
ajax.put("status", 0);
|
||||
System.out.println("openid:{}" + openid);
|
||||
if (openid != null) {
|
||||
if (!StringUtils.isEmpty(openid)) {
|
||||
redisTemplate.delete(verifyKey);
|
||||
SysUser user = iSysUserThirdAccountService.selectUserByOpenId(openid);
|
||||
System.out.println("用户:{}" + user);
|
||||
if (user == null) {
|
||||
System.out.println("用户不存在");
|
||||
return AjaxResult.error("用户不存在");
|
||||
if (user.getUserId() == null) {
|
||||
|
||||
iSysUserService.addUser(openid,CacheConstants.WE_CHAT,null);
|
||||
user = iSysUserThirdAccountService.selectUserByOpenId(openid);
|
||||
}
|
||||
LoginUser loginUser = new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
|
||||
// 生成token
|
||||
|
|
|
@ -121,6 +121,7 @@ mybatis-plus:
|
|||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
|
||||
global-config:
|
||||
# 是否打印 Logo banner
|
||||
banner: false
|
||||
|
@ -129,10 +130,8 @@ mybatis-plus:
|
|||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||
idType: auto
|
||||
logic-delete-field: del_flag
|
||||
# 逻辑已删除值
|
||||
logicDeleteValue: '2'
|
||||
# 逻辑未删除值
|
||||
logicNotDeleteValue: '0'
|
||||
logic-delete-value: '2'
|
||||
logic-not-delete-value: '0'
|
||||
# 数据库字段下划线命名规则
|
||||
table-underline: true
|
||||
# 字段验证策略之 insert,在 insert 的时候的字段验证策略
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
@ -38,6 +39,10 @@ public class BaseEntity implements Serializable
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.domain.response;
|
||||
//
|
||||
//
|
||||
//import com.mcwl.common.i18n.I18nMessage;
|
||||
//
|
||||
///**
|
||||
// * @author FrozenWatermelon
|
||||
// * @date 2020/7/9
|
||||
// */
|
||||
//public enum ResponseEnum {
|
||||
//
|
||||
// /**
|
||||
// * ok
|
||||
// */
|
||||
// OK("00000", "ok"),
|
||||
//
|
||||
// /**
|
||||
// * 用于直接显示提示用户的错误,内容由输入内容决定
|
||||
// */
|
||||
// SHOW_FAIL("A00001", ""),
|
||||
//
|
||||
// /**
|
||||
// * 用于直接显示提示系统的成功,内容由输入内容决定
|
||||
// */
|
||||
// SHOW_SUCCESS("A00002", ""),
|
||||
//
|
||||
// /**
|
||||
// * 未授权
|
||||
// */
|
||||
// UNAUTHORIZED("A00004", "Unauthorized"),
|
||||
//
|
||||
// /**
|
||||
// * 服务器出了点小差
|
||||
// */
|
||||
// EXCEPTION("A00005", "服务器出了点小差"),
|
||||
//
|
||||
// /**
|
||||
// * TempUid异常
|
||||
// * 一般不会出现这个异常,出现这个异常会有两种已知可能
|
||||
// * 1. 一种是旧的tempUid
|
||||
// * 2. 一种是同域名的localstorage 有个也叫tempUid的存储覆盖了(有的人测试环境和正式环境放在同一个域名不同子目录下)
|
||||
// * 如果前端看到返回了这个异常,为了让用户能够顺利登录,需要重新获取一遍code,重新获取tempUid
|
||||
// */
|
||||
// TEMP_UID_ERROR("A00012", "TempUid Error"),
|
||||
//
|
||||
// /**
|
||||
// * 接口不存在
|
||||
// */
|
||||
// NOT_FOUND("A00013", "接口不存在"),
|
||||
//
|
||||
// /**
|
||||
// * 方法参数没有校验,内容由输入内容决定
|
||||
// */
|
||||
// METHOD_ARGUMENT_NOT_VALID("A00014", "方法参数没有校验"),
|
||||
//
|
||||
// /**
|
||||
// * 支付密码错误
|
||||
// */
|
||||
// PAY_PASSWORD_ERROR("A00015", I18nMessage.getMessage("yami.user.pay.password.error")),
|
||||
//
|
||||
//
|
||||
// SCANCODE_PAY_ERROR("A00016", "扫描支付发生错误"),
|
||||
//
|
||||
//
|
||||
// NEW_USER_NO_INVITOR_ERROR("A00017", "新注册用户必须填写邀请码"),
|
||||
//
|
||||
// NEW_USER_INVITOR_ERROR("A00018", "邀请码错误"),
|
||||
//
|
||||
// /**
|
||||
// * 01开头代表商品
|
||||
// * 商品已下架,返回特殊的状态码,用于渲染商品下架的页面
|
||||
// */
|
||||
//// SPU_NOT_EXIST("A01000", "商品不存在"),
|
||||
//
|
||||
// /**
|
||||
// * 02开头代表购物车
|
||||
// */
|
||||
//// SHOP_CART_NOT_EXIST("A02000", "商品已下架"),
|
||||
//
|
||||
// /**
|
||||
// * 03开头代表订单
|
||||
// */
|
||||
// API_ORDER_NOT_EXIST("A03000", "订单不存在"),
|
||||
// ORDER_BUSY("A03001", "订单繁忙,请稍后再试"),
|
||||
//
|
||||
// /**
|
||||
// * 订单不支持该配送方式
|
||||
// */
|
||||
// ORDER_DELIVERY_NOT_SUPPORTED("A03001", "The delivery method is not supported"),
|
||||
//
|
||||
// /**
|
||||
// * 请勿重复提交订单,
|
||||
// * 1.当前端遇到该异常时,说明前端防多次点击没做好
|
||||
// * 2.提示用户 订单已发生改变,请勿重复下单
|
||||
// */
|
||||
// REPEAT_ORDER("A03002", "订单已过期,请重新下单"),
|
||||
//
|
||||
// /**
|
||||
// * 优惠券不能共用
|
||||
// */
|
||||
// COUPON_CANNOT_USE_TOGETHER("A03003", "优惠券不能共用"),
|
||||
//
|
||||
// /**
|
||||
// * 代金券金额超过了订单金额
|
||||
// */
|
||||
// COUPON_OF_RMRT_GT_ORDER("A03004", "代金券金额超过了订单金额"),
|
||||
//
|
||||
// /**
|
||||
// * 库存不足,body会具体返回那个skuid的库存不足,后台通过skuId知道哪个商品库存不足,前端不需要判断
|
||||
// */
|
||||
// NOT_STOCK("A03010", "not stock"),
|
||||
//
|
||||
// /**
|
||||
// * 该社交账号被其他用户绑定了,如果返回这个状态码,前端应该提示用户解绑已经绑定的账号重新绑定
|
||||
// */
|
||||
// SOCIAL_ACCOUNT_BIND_BY_OTHER("A04002", "social account bind by other"),
|
||||
//
|
||||
// /**
|
||||
// * 存在未完成订单不能注销
|
||||
// */
|
||||
// DESTROY_USER_FAIL("A05000", "您的账户当前有未完成的订单,请待所有订单完成后再注销账户"),
|
||||
//
|
||||
// /**
|
||||
// * 用户收货地址超过配送范围
|
||||
// */
|
||||
// DELIVERY_OVER("A07001", ""),
|
||||
// /**
|
||||
// * 账号重复
|
||||
// */
|
||||
// ACCOUNT_REPEAT("P01001", "账号已经被使用"),
|
||||
// ACCOUNT_NOT_EXIT("P01002", "账号不存在"),
|
||||
// ACCOUNT_NOT_ROLE("P01003", "账号不存在角色"),
|
||||
// ACCOUNT_STATUS_ERROR("P01004", "账号被锁"),
|
||||
// ACCOUNT_NOT_AREA("P01005", "账号没绑定经营地区"),
|
||||
// ACCOUNT_CREATE_ERROR("P01006", "账号创建失败"),
|
||||
// ACCOUNT_NO_MENU("P01007", "账号无菜单权限"),
|
||||
// PUSH_ID_NO_ACCOUNT("P01008", "该id无账号"),
|
||||
// ACCOUNT_ERROR("P01009", "账号权限错误"),
|
||||
// QUERY_TYPE_ERROR("P01010", "分页查询用户类型有误"),
|
||||
// // P02 钱包类
|
||||
// PUSH_USER_WALLET_NOT_EXIST("P02001", "用户钱包不存在"),
|
||||
// ORDER_NOT_EXIST("P02002", "订单不存在"),
|
||||
// NOT_SCANCODE_ORDER("P02003", "订单不是扫码下单"),
|
||||
// NOT_PAY_ORDER("P02004", "订单为未支付完成"),
|
||||
// ACTUAL_PAY_LITTLE_ORDER("P02005", "订单支付金额小于1元,不进行分成"),
|
||||
// NOT_BIND_ORDER("P02006", "订单商家未被推客绑定,不进行分成"),
|
||||
// PUSH_ERR("P02007", "分成失败"),
|
||||
// ACCOUNT_WX_BIND("P02101","改用户已经绑定openid" ),
|
||||
// WX_APPID_SECRET_ERR("P02102","获取配置的appid错误" ),
|
||||
// WITHDRAW_EXCESS_ERROR("P02005", "提现金额超出可提现额度"),
|
||||
// SHOP_BANK_CARD_NOT_EXIST("P02006", "银行卡不存在"),
|
||||
// SHOP_BANK_CARD_STATE_ERROR("P02007", "申请提现银行卡状态错误"),
|
||||
//
|
||||
// SHOP_BANK_ACCOUNT_ERROR("P02008", "注册新生账号异常"),
|
||||
// SHOP_BANK_BIND_CONFIRM("P02010", "请输入验证码绑定银行卡"),
|
||||
// /**
|
||||
// * C开头为公共部分
|
||||
// */
|
||||
// ACCESS_TOKEN_ERR("C01001", "获取access_token失败"),
|
||||
// TICKET_ERR("C01002", "获取ticket失败"),
|
||||
// GENERATE_URL_LINK_ERR("C01003", "创建URLLink失败"),
|
||||
// GET_WX_CODE_SESSION_ERR("C01004", "微信登录凭证校验败"),
|
||||
//
|
||||
// DATA_EXISTS("C01009", "数据已存在"),
|
||||
// DATA_NOT_CHANGE_ABLE("C01010", "数据不可变更"),
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 远程接口调用错误
|
||||
// */
|
||||
// RPC_CALL_EXCEPTION("A08001", ""),
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// RPC_CALL_HTTP_EXCEPTION("A08002", ""),
|
||||
//
|
||||
//
|
||||
// BAIDU_MAP_CONVERT_ERROR("A08003","百度地图接口调用错误" ),
|
||||
//
|
||||
// /**
|
||||
// * T 平台活动类
|
||||
// */
|
||||
// REPEAT_ACTIVITY_SUB_ITEM("T00001", "重复的活动子项目"),;
|
||||
//
|
||||
//
|
||||
//
|
||||
// private final String code;
|
||||
//
|
||||
// private final String msg;
|
||||
//
|
||||
// public String value() {
|
||||
// return code;
|
||||
// }
|
||||
//
|
||||
// public String getMsg() {
|
||||
// return msg;
|
||||
// }
|
||||
//
|
||||
// ResponseEnum(String code, String msg) {
|
||||
// this.code = code;
|
||||
// this.msg = msg;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "ResponseEnum{" + "code='" + code + '\'' + ", msg='" + msg + '\'' + "} " + super.toString();
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -0,0 +1,215 @@
|
|||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.domain.response;
|
||||
//
|
||||
//import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
//import com.mcwl.common.config.serializer.SensitiveJsonSerializer;
|
||||
//import io.swagger.v3.oas.annotations.media.Schema;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 响应实体
|
||||
// * @author mcwl
|
||||
// */
|
||||
//public class ServerResponseEntity<T> implements Serializable {
|
||||
//
|
||||
// private static final Logger log = LoggerFactory.getLogger(ServerResponseEntity.class);
|
||||
//
|
||||
// /**
|
||||
// * 状态码
|
||||
// */
|
||||
// @Schema(description = "状态码" ) private String code;
|
||||
//
|
||||
// /**
|
||||
// * 信息
|
||||
// */
|
||||
// @Schema(description = "信息" ) private String msg;
|
||||
//
|
||||
// /**
|
||||
// * 数据
|
||||
// */
|
||||
// @Schema(description = "数据" )
|
||||
// @JsonSerialize(using = SensitiveJsonSerializer.class)
|
||||
// private T data;
|
||||
//
|
||||
// /**
|
||||
// * 版本
|
||||
// */
|
||||
// private String version;
|
||||
//
|
||||
// /**
|
||||
// * 时间
|
||||
// */
|
||||
// private Long timestamp;
|
||||
//
|
||||
// private String sign;
|
||||
//
|
||||
// public String getSign() {
|
||||
// return sign;
|
||||
// }
|
||||
//
|
||||
// public void setSign(String sign) {
|
||||
// this.sign = sign;
|
||||
// }
|
||||
//
|
||||
// public String getCode() {
|
||||
// return code;
|
||||
// }
|
||||
//
|
||||
// public void setCode(String code) {
|
||||
// this.code = code;
|
||||
// }
|
||||
//
|
||||
// public String getMsg() {
|
||||
// return msg;
|
||||
// }
|
||||
//
|
||||
// public void setMsg(String msg) {
|
||||
// this.msg = msg;
|
||||
// }
|
||||
//
|
||||
// public T getData() {
|
||||
// return data;
|
||||
// }
|
||||
//
|
||||
// public ServerResponseEntity setData(T data) {
|
||||
// this.data = data;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Long getTimestamp() {
|
||||
// return timestamp;
|
||||
// }
|
||||
//
|
||||
// public void setTimestamp(Long timestamp) {
|
||||
// this.timestamp = timestamp;
|
||||
// }
|
||||
//
|
||||
// public String getVersion() {
|
||||
// return version;
|
||||
// }
|
||||
//
|
||||
// public void setVersion(String version) {
|
||||
// this.version = version;
|
||||
// }
|
||||
//
|
||||
// public boolean isSuccess() {
|
||||
// return Objects.equals(ResponseEnum.OK.value(), this.code);
|
||||
// }
|
||||
// public boolean isFail() {
|
||||
// return !Objects.equals(ResponseEnum.OK.value(), this.code);
|
||||
// }
|
||||
//
|
||||
// public ServerResponseEntity() {
|
||||
// // 版本号
|
||||
// this.version = "mall4j.v231204";
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> success(T data) {
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setData(data);
|
||||
// serverResponseEntity.setCode(ResponseEnum.OK.value());
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> success() {
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setCode(ResponseEnum.OK.value());
|
||||
// serverResponseEntity.setMsg(ResponseEnum.OK.getMsg());
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> success(Integer code, T data) {
|
||||
// return success(String.valueOf(code), data);
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> success(String code, T data) {
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setCode(code);
|
||||
// serverResponseEntity.setData(data);
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 前端显示失败消息
|
||||
// * @param msg 失败消息
|
||||
// * @return
|
||||
// */
|
||||
// public static <T> ServerResponseEntity<T> showFailMsg(String msg) {
|
||||
// log.error(msg);
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setMsg(msg);
|
||||
// serverResponseEntity.setCode(ResponseEnum.SHOW_FAIL.value());
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum) {
|
||||
// log.error(responseEnum.toString());
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setMsg(responseEnum.getMsg());
|
||||
// serverResponseEntity.setCode(responseEnum.value());
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum, T data) {
|
||||
// log.error(responseEnum.toString());
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setMsg(responseEnum.getMsg());
|
||||
// serverResponseEntity.setCode(responseEnum.value());
|
||||
// serverResponseEntity.setData(data);
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> fail(String code, String msg, T data) {
|
||||
// log.error(msg);
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setMsg(msg);
|
||||
// serverResponseEntity.setCode(code);
|
||||
// serverResponseEntity.setData(data);
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> fail(String code, String msg) {
|
||||
// return fail(code, msg, null);
|
||||
// }
|
||||
//
|
||||
// public static <T> ServerResponseEntity<T> fail(Integer code, T data) {
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setCode(String.valueOf(code));
|
||||
// serverResponseEntity.setData(data);
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// public static <T> ServerResponseEntity<T> transform(ServerResponseEntity<?> oldServerResponseEntity) {
|
||||
// ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
|
||||
// serverResponseEntity.setMsg(oldServerResponseEntity.getMsg());
|
||||
// serverResponseEntity.setCode(oldServerResponseEntity.getCode());
|
||||
// serverResponseEntity.setData((T) oldServerResponseEntity.getData());
|
||||
// log.error(serverResponseEntity.toString());
|
||||
// return serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "ServerResponseEntity{" +
|
||||
// "code='" + code + '\'' +
|
||||
// ", msg='" + msg + '\'' +
|
||||
// ", data=" + data +
|
||||
// ", version='" + version + '\'' +
|
||||
// ", timestamp=" + timestamp +
|
||||
// ", sign='" + sign + '\'' +
|
||||
// '}';
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,60 @@
|
|||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.exception;
|
||||
//
|
||||
//
|
||||
//import com.mcwl.common.domain.response.ResponseEnum;
|
||||
//import lombok.Getter;
|
||||
//
|
||||
///**
|
||||
// * 自定义异常
|
||||
// * @author mcwl
|
||||
// */
|
||||
//@Getter
|
||||
//public class YamiBizException extends RuntimeException{
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private static final long serialVersionUID = -4137688758944857209L;
|
||||
//
|
||||
// /**
|
||||
// * http状态码
|
||||
// */
|
||||
// private String code;
|
||||
//
|
||||
// /**
|
||||
// * @param responseEnum http状态码
|
||||
// */
|
||||
// public YamiBizException(ResponseEnum responseEnum) {
|
||||
// super(responseEnum.getMsg());
|
||||
// this.code = responseEnum.value();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param responseEnum http状态码
|
||||
// */
|
||||
// public YamiBizException(ResponseEnum responseEnum, String msg) {
|
||||
// super(msg);
|
||||
// this.code = responseEnum.value();
|
||||
// }
|
||||
//
|
||||
// public YamiBizException(String msg) {
|
||||
//// super(msg);
|
||||
// super(msg);
|
||||
// this.code = ResponseEnum.SHOW_FAIL.value();
|
||||
// }
|
||||
//
|
||||
// public YamiBizException(String code,String msg) {
|
||||
//// super(msg);
|
||||
// super(msg);
|
||||
// this.code = code;
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,74 @@
|
|||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.exception;
|
||||
//
|
||||
//import com.mcwl.common.domain.response.ResponseEnum;
|
||||
//import com.mcwl.common.domain.response.ServerResponseEntity;
|
||||
//import com.mcwl.common.i18n.I18nMessage;
|
||||
//import lombok.Getter;
|
||||
//
|
||||
///**
|
||||
// * 自定义异常
|
||||
// * @author mcwl
|
||||
// */
|
||||
//@Getter
|
||||
//public class YamiShopBindException extends RuntimeException{
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private static final long serialVersionUID = -4137688758944857209L;
|
||||
//
|
||||
// /**
|
||||
// * http状态码
|
||||
// */
|
||||
// private String code;
|
||||
//
|
||||
// private Object object;
|
||||
//
|
||||
// private ServerResponseEntity<?> serverResponseEntity;
|
||||
//
|
||||
// /**
|
||||
// * @param responseEnum http状态码
|
||||
// */
|
||||
// public YamiShopBindException(ResponseEnum responseEnum) {
|
||||
// super(responseEnum.getMsg());
|
||||
// this.code = responseEnum.value();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param responseEnum http状态码
|
||||
// */
|
||||
// public YamiShopBindException(ResponseEnum responseEnum, String msg) {
|
||||
// super(I18nMessage.getMessage(msg));
|
||||
// this.code = responseEnum.value();
|
||||
// }
|
||||
//
|
||||
// public YamiShopBindException(ServerResponseEntity<?> serverResponseEntity) {
|
||||
// this.serverResponseEntity = serverResponseEntity;
|
||||
// }
|
||||
//
|
||||
// public YamiShopBindException(String msg) {
|
||||
//// super(msg);
|
||||
// super(I18nMessage.getMessage(msg));
|
||||
// this.code = ResponseEnum.SHOW_FAIL.value();
|
||||
// }
|
||||
//
|
||||
// public YamiShopBindException(String msg, Object object) {
|
||||
// super(I18nMessage.getMessage(msg));
|
||||
// this.code = ResponseEnum.SHOW_FAIL.value();
|
||||
// this.object = object;
|
||||
// }
|
||||
//
|
||||
// public YamiShopBindException(String code, String msg) {
|
||||
// super(I18nMessage.getMessage(msg));
|
||||
// this.code = code;
|
||||
// }
|
||||
//}
|
|
@ -1,53 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
*
|
||||
* https://www.mall4j.com/
|
||||
*
|
||||
* 未经允许,不可做商业用途!
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
package com.mcwl.common.i18n;
|
||||
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* RequestContextFilter 会传入默认的Locale,优先级(-105) 要比RequestContextFilter优先级高
|
||||
* @author LGH
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Order(-104)
|
||||
public class YamiLocaleChangeFilter implements Filter {
|
||||
|
||||
public static String ZH_CN = "zh_CN";
|
||||
public static String ZH_CN_L = "zh_cn";
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
|
||||
String newLocale = request.getHeader("locale");
|
||||
if(Objects.equals(newLocale,ZH_CN)||Objects.equals(newLocale,ZH_CN_L)){
|
||||
newLocale = "zh";
|
||||
}
|
||||
if (newLocale != null) {
|
||||
String lowerLocale = newLocale.toLowerCase();
|
||||
LocaleContextHolder.setLocale(new Locale(lowerLocale));
|
||||
}
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.i18n;
|
||||
//
|
||||
//
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.context.i18n.LocaleContextHolder;
|
||||
//import org.springframework.core.annotation.Order;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.servlet.*;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.io.IOException;
|
||||
//import java.util.Locale;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * RequestContextFilter 会传入默认的Locale,优先级(-105) 要比RequestContextFilter优先级高
|
||||
// * @author LGH
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@Order(-104)
|
||||
//public class YamiLocaleChangeFilter implements Filter {
|
||||
//
|
||||
// public static String ZH_CN = "zh_CN";
|
||||
// public static String ZH_CN_L = "zh_cn";
|
||||
//
|
||||
// @Override
|
||||
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
// HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
// HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
//
|
||||
// String newLocale = request.getHeader("locale");
|
||||
// if(Objects.equals(newLocale,ZH_CN)||Objects.equals(newLocale,ZH_CN_L)){
|
||||
// newLocale = "zh";
|
||||
// }
|
||||
// if (newLocale != null) {
|
||||
// String lowerLocale = newLocale.toLowerCase();
|
||||
// LocaleContextHolder.setLocale(new Locale(lowerLocale));
|
||||
// }
|
||||
// filterChain.doFilter(request, response);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
*
|
||||
* https://www.mall4j.com/
|
||||
*
|
||||
* 未经允许,不可做商业用途!
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
package com.mcwl.common.i18n;
|
||||
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author LGH
|
||||
*/
|
||||
@Component("localeChangeInterceptor")
|
||||
@Slf4j
|
||||
public class YamiLocaleChangeInterceptor extends LocaleChangeInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
String newLocale = request.getHeader(getParamName());
|
||||
if (newLocale != null) {
|
||||
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
|
||||
if (localeResolver == null) {
|
||||
throw new IllegalStateException(
|
||||
"No LocaleResolver found: not in a DispatcherServlet request?");
|
||||
}
|
||||
try {
|
||||
localeResolver.setLocale(request, response, parseLocaleValue(newLocale));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (isIgnoreInvalidLocale()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Proceed in any case.
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.i18n;
|
||||
//
|
||||
//
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.web.servlet.LocaleResolver;
|
||||
//import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
//import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
///**
|
||||
// * @author LGH
|
||||
// */
|
||||
//@Component("localeChangeInterceptor")
|
||||
//@Slf4j
|
||||
//public class YamiLocaleChangeInterceptor extends LocaleChangeInterceptor {
|
||||
//
|
||||
// @Override
|
||||
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
//
|
||||
// String newLocale = request.getHeader(getParamName());
|
||||
// if (newLocale != null) {
|
||||
// LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
|
||||
// if (localeResolver == null) {
|
||||
// throw new IllegalStateException(
|
||||
// "No LocaleResolver found: not in a DispatcherServlet request?");
|
||||
// }
|
||||
// try {
|
||||
// localeResolver.setLocale(request, response, parseLocaleValue(newLocale));
|
||||
// }
|
||||
// catch (IllegalArgumentException ex) {
|
||||
// if (isIgnoreInvalidLocale()) {
|
||||
// if (logger.isDebugEnabled()) {
|
||||
// logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage());
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// throw ex;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // Proceed in any case.
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
///*
|
||||
// * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
// *
|
||||
// * https://www.mall4j.com/
|
||||
// *
|
||||
// * 未经允许,不可做商业用途!
|
||||
// *
|
||||
// * 版权所有,侵权必究!
|
||||
// */
|
||||
//package com.mcwl.common.utils;
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.mcwl.common.exception.YamiShopBindException;
|
||||
//
|
||||
//
|
||||
//import javax.imageio.ImageIO;
|
||||
//import java.awt.*;
|
||||
//import java.awt.image.BufferedImage;
|
||||
//import java.io.ByteArrayOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.net.URL;
|
||||
//
|
||||
///**
|
||||
// * 图片处理工具类
|
||||
//
|
||||
// */
|
||||
//public class ImageUtil {
|
||||
// private static final String JPG = "jpg";
|
||||
// private static final String JPEG = "jpeg";
|
||||
// /**
|
||||
// * 将图片转为二进制数组
|
||||
// * @param imgUrl
|
||||
// * @return
|
||||
// */
|
||||
// public static byte[] imgToBinary(String imgUrl) {
|
||||
// try {
|
||||
// BufferedImage bufferedImage = ImageIO.read(new URL(imgUrl));
|
||||
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
// String suffix = imgUrlFileType(imgUrl);
|
||||
// //ImageIO无法写入jpeg文件 报Invalid argument to native writeImage,需重画
|
||||
// if(StrUtil.equals(suffix, JPG) || StrUtil.equals(suffix,JPEG)){
|
||||
// BufferedImage tag;
|
||||
// tag = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_BGR);
|
||||
// Graphics g = tag.getGraphics();
|
||||
// g.drawImage(bufferedImage, 0, 0, null);
|
||||
// g.dispose();
|
||||
// bufferedImage = tag;
|
||||
// }
|
||||
// ImageIO.write(bufferedImage, suffix, baos);
|
||||
// byte[] bytes = baos.toByteArray();
|
||||
// return bytes;
|
||||
// } catch (IOException e) {
|
||||
// // 图片丢失,请重新上传图片
|
||||
// throw new YamiShopBindException("yami.img.lose");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param imgUrl
|
||||
// * @return 文件得后缀,文件类型 jpg , png , ...
|
||||
// */
|
||||
// public static String imgUrlFileType(String imgUrl) {
|
||||
// if (StrUtil.isBlank(imgUrl)) {
|
||||
// return imgUrl;
|
||||
// }
|
||||
// imgUrl.trim();
|
||||
// String[] split = imgUrl.split("\\.");
|
||||
// String s = split[split.length - 1];
|
||||
// return s;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param imgUrl
|
||||
// * @return 获取文件名称
|
||||
// */
|
||||
// public static String imgUrlFileName(String imgUrl) {
|
||||
// if (StrUtil.isBlank(imgUrl)) {
|
||||
// return imgUrl;
|
||||
// }
|
||||
// imgUrl.trim();
|
||||
// String[] split = imgUrl.split("/");
|
||||
// String s = split[split.length - 1];
|
||||
// return s;
|
||||
// }
|
||||
// /**
|
||||
// * @param imgUrl
|
||||
// * @return 获取文件名称 45d3631e97d8438d80f9db1369595b8c
|
||||
// */
|
||||
// public static String imgUrlFileNameNoSuffix(String imgUrl) {
|
||||
// if (StrUtil.isBlank(imgUrl)) {
|
||||
// return imgUrl;
|
||||
// }
|
||||
// imgUrl.trim();
|
||||
// String[] split = imgUrl.split("/");
|
||||
// String s = split[split.length - 1];
|
||||
// String[] split1 = s.split("\\.");
|
||||
// return split1[0];
|
||||
// }
|
||||
//}
|
|
@ -21,6 +21,7 @@ import com.mcwl.framework.security.context.AuthenticationContextHolder;
|
|||
import com.mcwl.framework.security.sms.SmsCodeAuthenticationToken;
|
||||
import com.mcwl.system.service.ISysConfigService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import com.mcwl.system.service.impl.SysUserServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
|
@ -60,6 +61,9 @@ public class SysLoginService
|
|||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private SysUserServiceImpl sysUserService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
|
@ -195,7 +199,10 @@ public class SysLoginService
|
|||
//根据手机号查询数据
|
||||
SysUser sysUser = userService.selectUserByPhone(phone);
|
||||
if (sysUser == null){
|
||||
throw new UserNotExistsException();
|
||||
|
||||
//注册数据
|
||||
sysUserService.addUser(null,null,phone);
|
||||
sysUser = userService.selectUserByPhone(phone);
|
||||
}
|
||||
|
||||
// 登录前置校验
|
||||
|
|
|
@ -4,12 +4,15 @@ import com.mcwl.common.constant.QueueConstants;
|
|||
import com.mcwl.memberCenter.domain.UserMember;
|
||||
import com.mcwl.memberCenter.service.UserMemberService;
|
||||
import com.mcwl.memberCenter.task.UserMemberTask;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
@ -20,21 +23,37 @@ public class EmptyPointsRemindConsumer {
|
|||
|
||||
private final UserMemberService userMemberService;
|
||||
|
||||
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE)
|
||||
public void emptyPointsRemind(List<UserMember> userMemberList) {
|
||||
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
|
||||
public void emptyPointsRemind(UserMember UserMember, Channel channel, Message message) {
|
||||
try {
|
||||
// TODO 发送短信提醒用户积分即将清零
|
||||
log.info("消费者获取到积分清零提醒的数据:{}", userMemberList);
|
||||
log.info("获取到积分清零提醒的数据:{}", UserMember);
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (Exception e) {
|
||||
log.error("处理积分清零提醒消息时出错: {}", e.getMessage(), e);
|
||||
try {
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
} catch (IOException ex) {
|
||||
log.error("消息确认失败: {}", ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RabbitListener(queues = QueueConstants.MEMBER_BILLING_QUEUE)
|
||||
public void memberBillingQueue(UserMember userMember) {
|
||||
@RabbitListener(queues = QueueConstants.MEMBER_BILLING_QUEUE, ackMode = "MANUAL")
|
||||
public void memberBillingQueue(UserMember userMember, Channel channel, Message message) {
|
||||
try {
|
||||
// TODO 发送短信提醒用户会员账单,如果支付成功,更新last_payment_date,并重新计算end_date(start_date + 1个月)
|
||||
log.info("消费者获取到会员账单的数据:{}", userMember);
|
||||
log.info("获取到会员账单的数据:{}", userMember);
|
||||
} catch (Exception e) {
|
||||
log.error("处理会员账单消息时出错: {}", e.getMessage(), e);
|
||||
try {
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
} catch (IOException ex) {
|
||||
log.error("消息确认失败: {}", ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,9 +34,6 @@ public class Member extends BaseEntity {
|
|||
// 订阅周期(天)
|
||||
private Integer subscriptionPeriod;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
private String delFlag;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mcwl.memberCenter.domain;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import com.mcwl.memberCenter.enums.MemberMenu;
|
||||
|
@ -34,8 +35,7 @@ public class UserMember extends BaseEntity {
|
|||
// 会员积分
|
||||
private Integer points;
|
||||
|
||||
// 订阅状态 active(活跃)、inactive(非活跃)、pending(待支付)和expired(过期)
|
||||
@EnumValue
|
||||
// 订阅状态 active(活跃,连续包月)、inactive(非活跃,不连续包月)、pending(待支付)和expired(过期)
|
||||
private MemberMenu subscriptionStatus;
|
||||
|
||||
// 支付方式
|
||||
|
@ -53,9 +53,6 @@ public class UserMember extends BaseEntity {
|
|||
// 状态(0:正常 1:禁用)
|
||||
private String status;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
private String delFlag;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
|
||||
|
|
|
@ -31,9 +31,13 @@ public class UserMemberTask {
|
|||
*/
|
||||
public void emptyPointsRemindTask() {
|
||||
List<UserMember> userMemberList = this.getUseUserMember();
|
||||
|
||||
if (userMemberList == null || userMemberList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 发送积分清零消息
|
||||
rabbitTemplate.convertAndSend(QueueConstants.EMPTY_POINTS_REMIND_QUEUE, userMemberList);
|
||||
for (UserMember userMember : userMemberList) {
|
||||
rabbitTemplate.convertAndSend(QueueConstants.EMPTY_POINTS_REMIND_QUEUE, userMember);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,7 +64,8 @@ public class UserMemberTask {
|
|||
LambdaQueryWrapper<UserMember> qw = new LambdaQueryWrapper<>();
|
||||
// endDate大于当前时间, subscriptionStatus不为过期
|
||||
qw.gt(UserMember::getEndDate, System.currentTimeMillis())
|
||||
.ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_EXPIRED);
|
||||
.ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_EXPIRED)
|
||||
.ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_PENDING);
|
||||
List<UserMember> userMemberList = userMemberService.list(qw);
|
||||
if (userMemberList == null || userMemberList.isEmpty()) {
|
||||
return;
|
||||
|
@ -97,12 +102,14 @@ public class UserMemberTask {
|
|||
// subscriptionStatus 不为 "过期" 或 "待支付"
|
||||
// status 为 0 的
|
||||
LambdaQueryWrapper<UserMember> qw = new LambdaQueryWrapper<>();
|
||||
qw.le(UserMember::getStartDate, System.currentTimeMillis())
|
||||
.ge(UserMember::getEndDate, System.currentTimeMillis())
|
||||
qw.le(UserMember::getStartDate, new Date())
|
||||
.ge(UserMember::getEndDate, new Date())
|
||||
.ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_EXPIRED)
|
||||
.ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_PENDING)
|
||||
.eq(UserMember::getStatus, '0');
|
||||
return userMemberService.list();
|
||||
.eq(UserMember::getStatus, "0");
|
||||
// 对应的sql为
|
||||
System.out.println("sql = " + qw.getSqlSegment());
|
||||
return userMemberService.list(qw);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,9 +27,6 @@ public class Commission extends BaseEntity {
|
|||
// 支付状态
|
||||
private Integer payStatus;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
private String delFlag;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@ public class Consume extends BaseEntity {
|
|||
// 消费时间
|
||||
private Date consumeDate;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
private String delFlag;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@ public class Invitation extends BaseEntity {
|
|||
// 邀请码
|
||||
private String invitationCode;
|
||||
|
||||
// 删除标志(0代表存在 2代表删除)
|
||||
private String delFlag;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.mcwl.resource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.mcwl.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 作品点赞表
|
||||
*
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class MallProductLike extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String createName;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.mcwl.resource.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 查看个人发布作品入参
|
||||
*
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class MallProductVo {
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Long order;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNumber;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.mcwl.resource.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface MallProductLikeMapper {
|
||||
List<Long> selectByUserId(@Param("userId") Long userId);
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
|
||||
/**
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
public interface MallProductLikeService {
|
||||
Page<MallProduct> selectByUserLike(MallProductVo mallProductVo);
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package com.mcwl.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.common.domain.IdsParam;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import kotlin.Result;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -29,4 +30,7 @@ public interface MallProductService extends IService<MallProduct> {
|
|||
|
||||
void deleteMallProductByIds(IdsParam ids);
|
||||
|
||||
Page<MallProduct> selectByUserId(MallProductVo mallProductVo);
|
||||
|
||||
Page<MallProduct> pageLike(MallProductVo mallProductVo, List<Long> list);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
import com.mcwl.resource.mapper.MallProductLikeMapper;
|
||||
import com.mcwl.resource.service.MallProductLikeService;
|
||||
import com.mcwl.resource.service.MallProductService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DaiZibo
|
||||
* @date 2025/1/2
|
||||
* @apiNote
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class MallProductLikeServiceImpl implements MallProductLikeService {
|
||||
|
||||
@Autowired
|
||||
private MallProductLikeMapper mallProductLikeMapper;
|
||||
|
||||
@Autowired
|
||||
private MallProductService mallProductService;
|
||||
|
||||
@Override
|
||||
public Page<MallProduct> selectByUserLike(MallProductVo mallProductVo) {
|
||||
|
||||
//获取登录人
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<Long> list = mallProductLikeMapper.selectByUserId(userId);
|
||||
|
||||
//分页查询作品数据
|
||||
return mallProductService.pageLike(mallProductVo,list);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,15 @@
|
|||
package com.mcwl.resource.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.domain.IdsParam;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.resource.domain.MallProduct;
|
||||
import com.mcwl.resource.mapper.MallProductMapper;
|
||||
import com.mcwl.resource.service.MallProductService;
|
||||
import kotlin.Result;
|
||||
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -24,8 +27,6 @@ import java.util.List;
|
|||
@Service
|
||||
public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallProduct> implements MallProductService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private MallProductMapper postMapper;
|
||||
|
||||
|
@ -59,5 +60,55 @@ public class MallProductServiceImpl extends ServiceImpl<MallProductMapper,MallPr
|
|||
postMapper.deleteBatchIds(ids.getIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MallProduct> selectByUserId(MallProductVo mallProductVo) {
|
||||
|
||||
// 创建分页对象
|
||||
Page<MallProduct> mallProductPage = new Page<>(mallProductVo.getPageNumber(), mallProductVo.getPageSize());
|
||||
|
||||
//获取当前登录人ID
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
LambdaQueryWrapper<MallProduct> mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
mallProductLambdaQueryWrapper.eq(MallProduct::getUserId,userId);
|
||||
mallProductLambdaQueryWrapper.eq(MallProduct::getDelFlag,0);
|
||||
|
||||
if (mallProductVo.getStatus() != 0){
|
||||
mallProductLambdaQueryWrapper.eq(MallProduct::getStatus,mallProductVo.getStatus());
|
||||
}
|
||||
|
||||
if (mallProductVo.getOrder() == 1){
|
||||
mallProductLambdaQueryWrapper.orderByDesc(MallProduct::getProductId);
|
||||
}else {
|
||||
|
||||
}
|
||||
|
||||
// 开始时间和结束时间过滤
|
||||
if (mallProductVo.getStartTime() != null && mallProductVo.getEndTime() != null) {
|
||||
// 查询开始时间和结束时间之间的商品
|
||||
mallProductLambdaQueryWrapper.between(MallProduct::getCreateTime, mallProductVo.getStartTime(), mallProductVo.getEndTime());
|
||||
} else if (mallProductVo.getStartTime() != null) {
|
||||
// 只有开始时间,查询大于等于开始时间的商品
|
||||
mallProductLambdaQueryWrapper.ge(MallProduct::getCreateTime, mallProductVo.getStartTime());
|
||||
} else if (mallProductVo.getEndTime() != null) {
|
||||
// 只有结束时间,查询小于等于结束时间的商品
|
||||
mallProductLambdaQueryWrapper.le(MallProduct::getCreateTime, mallProductVo.getEndTime());
|
||||
}
|
||||
|
||||
return postMapper.selectPage(mallProductPage, mallProductLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MallProduct> pageLike(MallProductVo mallProductVo, List<Long> list) {
|
||||
|
||||
// 创建分页对象
|
||||
Page<MallProduct> mallProductPage = new Page<>(mallProductVo.getPageNumber(), mallProductVo.getPageSize());
|
||||
|
||||
LambdaQueryWrapper<MallProduct> mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
mallProductLambdaQueryWrapper.in(MallProduct::getProductId,list);
|
||||
|
||||
return postMapper.selectPage(mallProductPage,mallProductLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?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.mcwl.resource.mapper.MallProductLikeMapper">
|
||||
|
||||
|
||||
<select id="selectByUserId" resultType="java.lang.Long">
|
||||
select product_id FROM mall_product_like WHERE user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -207,4 +207,5 @@ public interface ISysUserService
|
|||
|
||||
SysUser selectUserByPhone(String phone);
|
||||
|
||||
void addUser(String openid,String type,String phone);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mcwl.system.service;
|
||||
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||
|
||||
/**
|
||||
* 第三方登录表
|
||||
|
@ -12,4 +13,6 @@ import com.mcwl.common.core.domain.entity.SysUser;
|
|||
public interface ISysUserThirdAccountService {
|
||||
SysUser selectUserByOpenId(String openid);
|
||||
|
||||
void add(SysUserThirdAccount sysUserThirdAccount);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ import com.mcwl.common.utils.spring.SpringUtils;
|
|||
import com.mcwl.system.domain.SysPost;
|
||||
import com.mcwl.system.domain.SysUserPost;
|
||||
import com.mcwl.system.domain.SysUserRole;
|
||||
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||
import com.mcwl.system.mapper.*;
|
||||
import com.mcwl.system.service.ISysConfigService;
|
||||
import com.mcwl.system.service.ISysDeptService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import com.mcwl.system.service.ISysUserThirdAccountService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -24,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.validation.Validator;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -62,6 +65,16 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private ISysUserThirdAccountService iSysUserThirdAccountService;
|
||||
|
||||
private static final String UPPER_CASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private static final String LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz";
|
||||
private static final String DIGITS = "0123456789";
|
||||
// private static final String SPECIAL_CHARACTERS = "!@#$%^&*()-_=+[]{}|;:,.<>?";
|
||||
private static final String ALL_CHARACTERS = UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + DIGITS;
|
||||
private static final SecureRandom random = new SecureRandom();
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -550,4 +563,46 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
|
||||
return userMapper.selectUserByPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUser(String openid,String type,String phone) {
|
||||
|
||||
//初始化一个用户信息
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserName("默认用户:"+ generateRandomPassword(8));
|
||||
sysUser.setNickName("用户:" + generateRandomPassword(8));
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(generateRandomPassword(10)));
|
||||
sysUser.setPhonenumber(phone);
|
||||
sysUser.setRoleIds(new Long[]{2L});
|
||||
|
||||
//新增用户
|
||||
insertUser(sysUser);
|
||||
|
||||
if (openid != null){
|
||||
SysUserThirdAccount sysUserThirdAccount = SysUserThirdAccount.builder().userId(sysUser.getUserId())
|
||||
.bindType(type)
|
||||
.openid(openid.substring(1, openid.length() - 1)).build();
|
||||
iSysUserThirdAccountService.add(sysUserThirdAccount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机密码
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
public static String generateRandomPassword(int length) {
|
||||
if (length < 1) {
|
||||
throw new IllegalArgumentException("Password length must be at least 1");
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int randomIndex = random.nextInt(ALL_CHARACTERS.length());
|
||||
sb.append(ALL_CHARACTERS.charAt(randomIndex));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,4 +47,11 @@ public class SysUserThirdAccountServiceImpl implements ISysUserThirdAccountServi
|
|||
return sysUserService.selectUserById(sysUserThirdAccount.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(SysUserThirdAccount sysUserThirdAccount) {
|
||||
|
||||
//添加第三方登录权限
|
||||
sysUserThirdAccountMapper.insert(sysUserThirdAccount);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue