refactor:调整

feature/comment
yang 2025-01-02 15:47:03 +08:00
parent 8df1daac3e
commit 5cc7874b77
19 changed files with 931 additions and 930 deletions

View File

@ -2,6 +2,8 @@ package com.mcwl;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import org.mybatis.spring.annotation.MapperScan; 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.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
@ -37,4 +39,10 @@ public class McWlApplication
public Jackson2ObjectMapperBuilderCustomizer customizer() { public Jackson2ObjectMapperBuilderCustomizer customizer() {
return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
} }
// mq 消息转换器
@Bean
public MessageConverter jacksonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
} }

View File

@ -10,7 +10,7 @@ spring:
listener: listener:
simple: simple:
prefetch: 1 # 每次之能获取一条 prefetch: 1 # 每次之能获取一条
acknowledge-mode: manual # 设置消费端手动ack确认 acknowledge-mode: auto # 设置消费端手动ack确认
retry: retry:
enabled: true # 是否支持重试 enabled: true # 是否支持重试
# 生产者配置 # 生产者配置

View File

@ -131,10 +131,8 @@ mybatis-plus:
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
idType: auto idType: auto
logic-delete-field: del_flag logic-delete-field: del_flag
# 逻辑已删除值 logic-delete-value: '2'
logicDeleteValue: '2' logic-not-delete-value: '0'
# 逻辑未删除值
logicNotDeleteValue: '0'
# 数据库字段下划线命名规则 # 数据库字段下划线命名规则
table-underline: true table-underline: true
# 字段验证策略之 insert,在 insert 的时候的字段验证策略 # 字段验证策略之 insert,在 insert 的时候的字段验证策略
@ -169,12 +167,12 @@ xss:
#aliyun-oss #aliyun-oss
aliyun: # aliyun:
oss: # oss:
file: # file:
endPoint: "http://oss-cn-beijing.aliyuncs.com" // 一般不用改,选择自己的地址即可 # endPoint: "http://oss-cn-beijing.aliyuncs.com" // 一般不用改,选择自己的地址即可
keyid: "保存的key" # keyid: "保存的key"
keyecrets: "保存的secret" # keyecrets: "保存的secret"
#bucket可以在控制台创建也可以使用java代码创建 # #bucket可以在控制台创建也可以使用java代码创建
bucketname: "实例名称" # bucketname: "实例名称"

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
@ -38,6 +39,10 @@ public class BaseEntity implements Serializable
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
// 删除标志0代表存在 2代表删除
@TableLogic
private String delFlag;
/** 备注 */ /** 备注 */
private String remark; private String remark;

View File

@ -2,7 +2,9 @@ package com.mcwl.common.domain;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class IdsParam { public class IdsParam {
private Long[] ids; private List<Long> ids;
} }

View File

@ -1,220 +1,220 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.domain.response; //package com.mcwl.common.domain.response;
//
//
import com.mcwl.common.i18n.I18nMessage; //import com.mcwl.common.i18n.I18nMessage;
//
/** ///**
* @author FrozenWatermelon // * @author FrozenWatermelon
* @date 2020/7/9 // * @date 2020/7/9
*/ // */
public enum ResponseEnum { //public enum ResponseEnum {
//
/** // /**
* ok // * ok
*/ // */
OK("00000", "ok"), // OK("00000", "ok"),
//
/** // /**
* // * 用于直接显示提示用户的错误,内容由输入内容决定
*/ // */
SHOW_FAIL("A00001", ""), // SHOW_FAIL("A00001", ""),
//
/** // /**
* // * 用于直接显示提示系统的成功,内容由输入内容决定
*/ // */
SHOW_SUCCESS("A00002", ""), // SHOW_SUCCESS("A00002", ""),
//
/** // /**
* // * 未授权
*/ // */
UNAUTHORIZED("A00004", "Unauthorized"), // UNAUTHORIZED("A00004", "Unauthorized"),
//
/** // /**
* // * 服务器出了点小差
*/ // */
EXCEPTION("A00005", "服务器出了点小差"), // EXCEPTION("A00005", "服务器出了点小差"),
//
/** // /**
* TempUid // * TempUid异常
* // * 一般不会出现这个异常,出现这个异常会有两种已知可能
* 1. tempUid // * 1. 一种是旧的tempUid
* 2. localstorage tempUid // * 2. 一种是同域名的localstorage 有个也叫tempUid的存储覆盖了有的人测试环境和正式环境放在同一个域名不同子目录下
* codetempUid // * 如果前端看到返回了这个异常为了让用户能够顺利登录需要重新获取一遍code重新获取tempUid
*/ // */
TEMP_UID_ERROR("A00012", "TempUid Error"), // TEMP_UID_ERROR("A00012", "TempUid Error"),
//
/** // /**
* // * 接口不存在
*/ // */
NOT_FOUND("A00013", "接口不存在"), // NOT_FOUND("A00013", "接口不存在"),
//
/** // /**
* // * 方法参数没有校验,内容由输入内容决定
*/ // */
METHOD_ARGUMENT_NOT_VALID("A00014", "方法参数没有校验"), // METHOD_ARGUMENT_NOT_VALID("A00014", "方法参数没有校验"),
//
/** // /**
* // * 支付密码错误
*/ // */
PAY_PASSWORD_ERROR("A00015", I18nMessage.getMessage("yami.user.pay.password.error")), // PAY_PASSWORD_ERROR("A00015", I18nMessage.getMessage("yami.user.pay.password.error")),
//
//
SCANCODE_PAY_ERROR("A00016", "扫描支付发生错误"), // SCANCODE_PAY_ERROR("A00016", "扫描支付发生错误"),
//
//
NEW_USER_NO_INVITOR_ERROR("A00017", "新注册用户必须填写邀请码"), // NEW_USER_NO_INVITOR_ERROR("A00017", "新注册用户必须填写邀请码"),
//
NEW_USER_INVITOR_ERROR("A00018", "邀请码错误"), // NEW_USER_INVITOR_ERROR("A00018", "邀请码错误"),
//
/** // /**
* 01 // * 01开头代表商品
* // * 商品已下架,返回特殊的状态码,用于渲染商品下架的页面
*/ // */
// SPU_NOT_EXIST("A01000", "商品不存在"), //// SPU_NOT_EXIST("A01000", "商品不存在"),
//
/** // /**
* 02 // * 02开头代表购物车
*/ // */
// SHOP_CART_NOT_EXIST("A02000", "商品已下架"), //// SHOP_CART_NOT_EXIST("A02000", "商品已下架"),
//
/** // /**
* 03 // * 03开头代表订单
*/ // */
API_ORDER_NOT_EXIST("A03000", "订单不存在"), // API_ORDER_NOT_EXIST("A03000", "订单不存在"),
ORDER_BUSY("A03001", "订单繁忙,请稍后再试"), // ORDER_BUSY("A03001", "订单繁忙,请稍后再试"),
//
/** // /**
* // * 订单不支持该配送方式
*/ // */
ORDER_DELIVERY_NOT_SUPPORTED("A03001", "The delivery method is not supported"), // ORDER_DELIVERY_NOT_SUPPORTED("A03001", "The delivery method is not supported"),
//
/** // /**
* // * 请勿重复提交订单,
* 1. // * 1.当前端遇到该异常时,说明前端防多次点击没做好
* 2. // * 2.提示用户 订单已发生改变,请勿重复下单
*/ // */
REPEAT_ORDER("A03002", "订单已过期,请重新下单"), // REPEAT_ORDER("A03002", "订单已过期,请重新下单"),
//
/** // /**
* // * 优惠券不能共用
*/ // */
COUPON_CANNOT_USE_TOGETHER("A03003", "优惠券不能共用"), // COUPON_CANNOT_USE_TOGETHER("A03003", "优惠券不能共用"),
//
/** // /**
* // * 代金券金额超过了订单金额
*/ // */
COUPON_OF_RMRT_GT_ORDER("A03004", "代金券金额超过了订单金额"), // COUPON_OF_RMRT_GT_ORDER("A03004", "代金券金额超过了订单金额"),
//
/** // /**
* bodyskuidskuId // * 库存不足body会具体返回那个skuid的库存不足后台通过skuId知道哪个商品库存不足前端不需要判断
*/ // */
NOT_STOCK("A03010", "not stock"), // NOT_STOCK("A03010", "not stock"),
//
/** // /**
* // * 该社交账号被其他用户绑定了,如果返回这个状态码,前端应该提示用户解绑已经绑定的账号重新绑定
*/ // */
SOCIAL_ACCOUNT_BIND_BY_OTHER("A04002", "social account bind by other"), // SOCIAL_ACCOUNT_BIND_BY_OTHER("A04002", "social account bind by other"),
//
/** // /**
* // * 存在未完成订单不能注销
*/ // */
DESTROY_USER_FAIL("A05000", "您的账户当前有未完成的订单,请待所有订单完成后再注销账户"), // DESTROY_USER_FAIL("A05000", "您的账户当前有未完成的订单,请待所有订单完成后再注销账户"),
//
/** // /**
* // * 用户收货地址超过配送范围
*/ // */
DELIVERY_OVER("A07001", ""), // DELIVERY_OVER("A07001", ""),
/** // /**
* // * 账号重复
*/ // */
ACCOUNT_REPEAT("P01001", "账号已经被使用"), // ACCOUNT_REPEAT("P01001", "账号已经被使用"),
ACCOUNT_NOT_EXIT("P01002", "账号不存在"), // ACCOUNT_NOT_EXIT("P01002", "账号不存在"),
ACCOUNT_NOT_ROLE("P01003", "账号不存在角色"), // ACCOUNT_NOT_ROLE("P01003", "账号不存在角色"),
ACCOUNT_STATUS_ERROR("P01004", "账号被锁"), // ACCOUNT_STATUS_ERROR("P01004", "账号被锁"),
ACCOUNT_NOT_AREA("P01005", "账号没绑定经营地区"), // ACCOUNT_NOT_AREA("P01005", "账号没绑定经营地区"),
ACCOUNT_CREATE_ERROR("P01006", "账号创建失败"), // ACCOUNT_CREATE_ERROR("P01006", "账号创建失败"),
ACCOUNT_NO_MENU("P01007", "账号无菜单权限"), // ACCOUNT_NO_MENU("P01007", "账号无菜单权限"),
PUSH_ID_NO_ACCOUNT("P01008", "该id无账号"), // PUSH_ID_NO_ACCOUNT("P01008", "该id无账号"),
ACCOUNT_ERROR("P01009", "账号权限错误"), // ACCOUNT_ERROR("P01009", "账号权限错误"),
QUERY_TYPE_ERROR("P01010", "分页查询用户类型有误"), // QUERY_TYPE_ERROR("P01010", "分页查询用户类型有误"),
// P02 钱包类 // // P02 钱包类
PUSH_USER_WALLET_NOT_EXIST("P02001", "用户钱包不存在"), // PUSH_USER_WALLET_NOT_EXIST("P02001", "用户钱包不存在"),
ORDER_NOT_EXIST("P02002", "订单不存在"), // ORDER_NOT_EXIST("P02002", "订单不存在"),
NOT_SCANCODE_ORDER("P02003", "订单不是扫码下单"), // NOT_SCANCODE_ORDER("P02003", "订单不是扫码下单"),
NOT_PAY_ORDER("P02004", "订单为未支付完成"), // NOT_PAY_ORDER("P02004", "订单为未支付完成"),
ACTUAL_PAY_LITTLE_ORDER("P02005", "订单支付金额小于1元不进行分成"), // ACTUAL_PAY_LITTLE_ORDER("P02005", "订单支付金额小于1元不进行分成"),
NOT_BIND_ORDER("P02006", "订单商家未被推客绑定,不进行分成"), // NOT_BIND_ORDER("P02006", "订单商家未被推客绑定,不进行分成"),
PUSH_ERR("P02007", "分成失败"), // PUSH_ERR("P02007", "分成失败"),
ACCOUNT_WX_BIND("P02101","改用户已经绑定openid" ), // ACCOUNT_WX_BIND("P02101","改用户已经绑定openid" ),
WX_APPID_SECRET_ERR("P02102","获取配置的appid错误" ), // WX_APPID_SECRET_ERR("P02102","获取配置的appid错误" ),
WITHDRAW_EXCESS_ERROR("P02005", "提现金额超出可提现额度"), // WITHDRAW_EXCESS_ERROR("P02005", "提现金额超出可提现额度"),
SHOP_BANK_CARD_NOT_EXIST("P02006", "银行卡不存在"), // SHOP_BANK_CARD_NOT_EXIST("P02006", "银行卡不存在"),
SHOP_BANK_CARD_STATE_ERROR("P02007", "申请提现银行卡状态错误"), // SHOP_BANK_CARD_STATE_ERROR("P02007", "申请提现银行卡状态错误"),
//
SHOP_BANK_ACCOUNT_ERROR("P02008", "注册新生账号异常"), // SHOP_BANK_ACCOUNT_ERROR("P02008", "注册新生账号异常"),
SHOP_BANK_BIND_CONFIRM("P02010", "请输入验证码绑定银行卡"), // SHOP_BANK_BIND_CONFIRM("P02010", "请输入验证码绑定银行卡"),
/** // /**
* C // * C开头为公共部分
*/ // */
ACCESS_TOKEN_ERR("C01001", "获取access_token失败"), // ACCESS_TOKEN_ERR("C01001", "获取access_token失败"),
TICKET_ERR("C01002", "获取ticket失败"), // TICKET_ERR("C01002", "获取ticket失败"),
GENERATE_URL_LINK_ERR("C01003", "创建URLLink失败"), // GENERATE_URL_LINK_ERR("C01003", "创建URLLink失败"),
GET_WX_CODE_SESSION_ERR("C01004", "微信登录凭证校验败"), // GET_WX_CODE_SESSION_ERR("C01004", "微信登录凭证校验败"),
//
DATA_EXISTS("C01009", "数据已存在"), // DATA_EXISTS("C01009", "数据已存在"),
DATA_NOT_CHANGE_ABLE("C01010", "数据不可变更"), // DATA_NOT_CHANGE_ABLE("C01010", "数据不可变更"),
//
//
//
//
/** // /**
* // * 远程接口调用错误
*/ // */
RPC_CALL_EXCEPTION("A08001", ""), // RPC_CALL_EXCEPTION("A08001", ""),
/** // /**
* // *
*/ // */
RPC_CALL_HTTP_EXCEPTION("A08002", ""), // RPC_CALL_HTTP_EXCEPTION("A08002", ""),
//
//
BAIDU_MAP_CONVERT_ERROR("A08003","百度地图接口调用错误" ), // BAIDU_MAP_CONVERT_ERROR("A08003","百度地图接口调用错误" ),
//
/** // /**
* T // * T 平台活动类
*/ // */
REPEAT_ACTIVITY_SUB_ITEM("T00001", "重复的活动子项目"),; // REPEAT_ACTIVITY_SUB_ITEM("T00001", "重复的活动子项目"),;
//
//
//
private final String code; // private final String code;
//
private final String msg; // private final String msg;
//
public String value() { // public String value() {
return code; // return code;
} // }
//
public String getMsg() { // public String getMsg() {
return msg; // return msg;
} // }
//
ResponseEnum(String code, String msg) { // ResponseEnum(String code, String msg) {
this.code = code; // this.code = code;
this.msg = msg; // this.msg = msg;
} // }
//
@Override // @Override
public String toString() { // public String toString() {
return "ResponseEnum{" + "code='" + code + '\'' + ", msg='" + msg + '\'' + "} " + super.toString(); // return "ResponseEnum{" + "code='" + code + '\'' + ", msg='" + msg + '\'' + "} " + super.toString();
} // }
//
} //}

View File

@ -1,215 +1,215 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.domain.response; //package com.mcwl.common.domain.response;
//
import com.fasterxml.jackson.databind.annotation.JsonSerialize; //import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mcwl.common.config.serializer.SensitiveJsonSerializer; //import com.mcwl.common.config.serializer.SensitiveJsonSerializer;
import io.swagger.v3.oas.annotations.media.Schema; //import io.swagger.v3.oas.annotations.media.Schema;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
//
import java.io.Serializable; //import java.io.Serializable;
import java.util.Objects; //import java.util.Objects;
//
/** ///**
* // * 响应实体
* @author mcwl // * @author mcwl
*/ // */
public class ServerResponseEntity<T> implements Serializable { //public class ServerResponseEntity<T> implements Serializable {
//
private static final Logger log = LoggerFactory.getLogger(ServerResponseEntity.class); // private static final Logger log = LoggerFactory.getLogger(ServerResponseEntity.class);
//
/** // /**
* // * 状态码
*/ // */
@Schema(description = "状态码" ) private String code; // @Schema(description = "状态码" ) private String code;
//
/** // /**
* // * 信息
*/ // */
@Schema(description = "信息" ) private String msg; // @Schema(description = "信息" ) private String msg;
//
/** // /**
* // * 数据
*/ // */
@Schema(description = "数据" ) // @Schema(description = "数据" )
@JsonSerialize(using = SensitiveJsonSerializer.class) // @JsonSerialize(using = SensitiveJsonSerializer.class)
private T data; // private T data;
//
/** // /**
* // * 版本
*/ // */
private String version; // private String version;
//
/** // /**
* // * 时间
*/ // */
private Long timestamp; // private Long timestamp;
//
private String sign; // private String sign;
//
public String getSign() { // public String getSign() {
return sign; // return sign;
} // }
//
public void setSign(String sign) { // public void setSign(String sign) {
this.sign = sign; // this.sign = sign;
} // }
//
public String getCode() { // public String getCode() {
return code; // return code;
} // }
//
public void setCode(String code) { // public void setCode(String code) {
this.code = code; // this.code = code;
} // }
//
public String getMsg() { // public String getMsg() {
return msg; // return msg;
} // }
//
public void setMsg(String msg) { // public void setMsg(String msg) {
this.msg = msg; // this.msg = msg;
} // }
//
public T getData() { // public T getData() {
return data; // return data;
} // }
//
public ServerResponseEntity setData(T data) { // public ServerResponseEntity setData(T data) {
this.data = data; // this.data = data;
return this; // return this;
} // }
//
public Long getTimestamp() { // public Long getTimestamp() {
return timestamp; // return timestamp;
} // }
//
public void setTimestamp(Long timestamp) { // public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; // this.timestamp = timestamp;
} // }
//
public String getVersion() { // public String getVersion() {
return version; // return version;
} // }
//
public void setVersion(String version) { // public void setVersion(String version) {
this.version = version; // this.version = version;
} // }
//
public boolean isSuccess() { // public boolean isSuccess() {
return Objects.equals(ResponseEnum.OK.value(), this.code); // return Objects.equals(ResponseEnum.OK.value(), this.code);
} // }
public boolean isFail() { // public boolean isFail() {
return !Objects.equals(ResponseEnum.OK.value(), this.code); // return !Objects.equals(ResponseEnum.OK.value(), this.code);
} // }
//
public ServerResponseEntity() { // public ServerResponseEntity() {
// 版本号 // // 版本号
this.version = "mall4j.v231204"; // this.version = "mall4j.v231204";
} // }
//
public static <T> ServerResponseEntity<T> success(T data) { // public static <T> ServerResponseEntity<T> success(T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setData(data); // serverResponseEntity.setData(data);
serverResponseEntity.setCode(ResponseEnum.OK.value()); // serverResponseEntity.setCode(ResponseEnum.OK.value());
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> success() { // public static <T> ServerResponseEntity<T> success() {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(ResponseEnum.OK.value()); // serverResponseEntity.setCode(ResponseEnum.OK.value());
serverResponseEntity.setMsg(ResponseEnum.OK.getMsg()); // serverResponseEntity.setMsg(ResponseEnum.OK.getMsg());
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> success(Integer code, T data) { // public static <T> ServerResponseEntity<T> success(Integer code, T data) {
return success(String.valueOf(code), data); // return success(String.valueOf(code), data);
} // }
//
public static <T> ServerResponseEntity<T> success(String code, T data) { // public static <T> ServerResponseEntity<T> success(String code, T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(code); // serverResponseEntity.setCode(code);
serverResponseEntity.setData(data); // serverResponseEntity.setData(data);
return serverResponseEntity; // return serverResponseEntity;
} // }
//
/** // /**
* // * 前端显示失败消息
* @param msg // * @param msg 失败消息
* @return // * @return
*/ // */
public static <T> ServerResponseEntity<T> showFailMsg(String msg) { // public static <T> ServerResponseEntity<T> showFailMsg(String msg) {
log.error(msg); // log.error(msg);
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(msg); // serverResponseEntity.setMsg(msg);
serverResponseEntity.setCode(ResponseEnum.SHOW_FAIL.value()); // serverResponseEntity.setCode(ResponseEnum.SHOW_FAIL.value());
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum) { // public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum) {
log.error(responseEnum.toString()); // log.error(responseEnum.toString());
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(responseEnum.getMsg()); // serverResponseEntity.setMsg(responseEnum.getMsg());
serverResponseEntity.setCode(responseEnum.value()); // serverResponseEntity.setCode(responseEnum.value());
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum, T data) { // public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum, T data) {
log.error(responseEnum.toString()); // log.error(responseEnum.toString());
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(responseEnum.getMsg()); // serverResponseEntity.setMsg(responseEnum.getMsg());
serverResponseEntity.setCode(responseEnum.value()); // serverResponseEntity.setCode(responseEnum.value());
serverResponseEntity.setData(data); // serverResponseEntity.setData(data);
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> fail(String code, String msg, T data) { // public static <T> ServerResponseEntity<T> fail(String code, String msg, T data) {
log.error(msg); // log.error(msg);
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(msg); // serverResponseEntity.setMsg(msg);
serverResponseEntity.setCode(code); // serverResponseEntity.setCode(code);
serverResponseEntity.setData(data); // serverResponseEntity.setData(data);
return serverResponseEntity; // return serverResponseEntity;
} // }
//
public static <T> ServerResponseEntity<T> fail(String code, String msg) { // public static <T> ServerResponseEntity<T> fail(String code, String msg) {
return fail(code, msg, null); // return fail(code, msg, null);
} // }
//
public static <T> ServerResponseEntity<T> fail(Integer code, T data) { // public static <T> ServerResponseEntity<T> fail(Integer code, T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(String.valueOf(code)); // serverResponseEntity.setCode(String.valueOf(code));
serverResponseEntity.setData(data); // serverResponseEntity.setData(data);
return serverResponseEntity; // return serverResponseEntity;
} // }
//
@SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
public static <T> ServerResponseEntity<T> transform(ServerResponseEntity<?> oldServerResponseEntity) { // public static <T> ServerResponseEntity<T> transform(ServerResponseEntity<?> oldServerResponseEntity) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>(); // ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(oldServerResponseEntity.getMsg()); // serverResponseEntity.setMsg(oldServerResponseEntity.getMsg());
serverResponseEntity.setCode(oldServerResponseEntity.getCode()); // serverResponseEntity.setCode(oldServerResponseEntity.getCode());
serverResponseEntity.setData((T) oldServerResponseEntity.getData()); // serverResponseEntity.setData((T) oldServerResponseEntity.getData());
log.error(serverResponseEntity.toString()); // log.error(serverResponseEntity.toString());
return serverResponseEntity; // return serverResponseEntity;
} // }
//
@Override // @Override
public String toString() { // public String toString() {
return "ServerResponseEntity{" + // return "ServerResponseEntity{" +
"code='" + code + '\'' + // "code='" + code + '\'' +
", msg='" + msg + '\'' + // ", msg='" + msg + '\'' +
", data=" + data + // ", data=" + data +
", version='" + version + '\'' + // ", version='" + version + '\'' +
", timestamp=" + timestamp + // ", timestamp=" + timestamp +
", sign='" + sign + '\'' + // ", sign='" + sign + '\'' +
'}'; // '}';
} // }
} //}

View File

@ -1,60 +1,60 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.exception; //package com.mcwl.common.exception;
//
//
import com.mcwl.common.domain.response.ResponseEnum; //import com.mcwl.common.domain.response.ResponseEnum;
import lombok.Getter; //import lombok.Getter;
//
/** ///**
* // * 自定义异常
* @author mcwl // * @author mcwl
*/ // */
@Getter //@Getter
public class YamiBizException extends RuntimeException{ //public class YamiBizException extends RuntimeException{
//
/** // /**
* // *
*/ // */
private static final long serialVersionUID = -4137688758944857209L; // private static final long serialVersionUID = -4137688758944857209L;
//
/** // /**
* http // * http状态码
*/ // */
private String code; // private String code;
//
/** // /**
* @param responseEnum http // * @param responseEnum http状态码
*/ // */
public YamiBizException(ResponseEnum responseEnum) { // public YamiBizException(ResponseEnum responseEnum) {
super(responseEnum.getMsg()); // super(responseEnum.getMsg());
this.code = responseEnum.value(); // this.code = responseEnum.value();
} // }
//
/** // /**
* @param responseEnum http // * @param responseEnum http状态码
*/ // */
public YamiBizException(ResponseEnum responseEnum, String msg) { // public YamiBizException(ResponseEnum responseEnum, String msg) {
super(msg);
this.code = responseEnum.value();
}
public YamiBizException(String msg) {
// super(msg); // super(msg);
super(msg); // this.code = responseEnum.value();
this.code = ResponseEnum.SHOW_FAIL.value(); // }
} //
// public YamiBizException(String msg) {
public YamiBizException(String code,String msg) { //// super(msg);
// super(msg); // super(msg);
super(msg); // this.code = ResponseEnum.SHOW_FAIL.value();
this.code = code; // }
} //
} // public YamiBizException(String code,String msg) {
//// super(msg);
// super(msg);
// this.code = code;
// }
//}

View File

@ -1,74 +1,74 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.exception; //package com.mcwl.common.exception;
//
import com.mcwl.common.domain.response.ResponseEnum; //import com.mcwl.common.domain.response.ResponseEnum;
import com.mcwl.common.domain.response.ServerResponseEntity; //import com.mcwl.common.domain.response.ServerResponseEntity;
import com.mcwl.common.i18n.I18nMessage; //import com.mcwl.common.i18n.I18nMessage;
import lombok.Getter; //import lombok.Getter;
//
/** ///**
* // * 自定义异常
* @author mcwl // * @author mcwl
*/ // */
@Getter //@Getter
public class YamiShopBindException extends RuntimeException{ //public class YamiShopBindException extends RuntimeException{
//
/** // /**
* // *
*/ // */
private static final long serialVersionUID = -4137688758944857209L; // private static final long serialVersionUID = -4137688758944857209L;
//
/** // /**
* http // * http状态码
*/ // */
private String code; // private String code;
//
private Object object; // private Object object;
//
private ServerResponseEntity<?> serverResponseEntity; // private ServerResponseEntity<?> serverResponseEntity;
//
/** // /**
* @param responseEnum http // * @param responseEnum http状态码
*/ // */
public YamiShopBindException(ResponseEnum responseEnum) { // public YamiShopBindException(ResponseEnum responseEnum) {
super(responseEnum.getMsg()); // super(responseEnum.getMsg());
this.code = responseEnum.value(); // this.code = responseEnum.value();
} // }
//
/** // /**
* @param responseEnum http // * @param responseEnum http状态码
*/ // */
public YamiShopBindException(ResponseEnum responseEnum, String msg) { // public YamiShopBindException(ResponseEnum responseEnum, String msg) {
super(I18nMessage.getMessage(msg)); // super(I18nMessage.getMessage(msg));
this.code = responseEnum.value(); // this.code = responseEnum.value();
} // }
//
public YamiShopBindException(ServerResponseEntity<?> serverResponseEntity) { // public YamiShopBindException(ServerResponseEntity<?> serverResponseEntity) {
this.serverResponseEntity = serverResponseEntity; // this.serverResponseEntity = serverResponseEntity;
} // }
//
public YamiShopBindException(String msg) { // public YamiShopBindException(String msg) {
// super(msg); //// super(msg);
super(I18nMessage.getMessage(msg)); // super(I18nMessage.getMessage(msg));
this.code = ResponseEnum.SHOW_FAIL.value(); // this.code = ResponseEnum.SHOW_FAIL.value();
} // }
//
public YamiShopBindException(String msg, Object object) { // public YamiShopBindException(String msg, Object object) {
super(I18nMessage.getMessage(msg)); // super(I18nMessage.getMessage(msg));
this.code = ResponseEnum.SHOW_FAIL.value(); // this.code = ResponseEnum.SHOW_FAIL.value();
this.object = object; // this.object = object;
} // }
//
public YamiShopBindException(String code, String msg) { // public YamiShopBindException(String code, String msg) {
super(I18nMessage.getMessage(msg)); // super(I18nMessage.getMessage(msg));
this.code = code; // this.code = code;
} // }
} //}

View File

@ -1,45 +1,56 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.i18n; //package com.mcwl.common.i18n;
//
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.context.i18n.LocaleContextHolder; //import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.MessageSourceAccessor; //import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //import org.springframework.context.support.ReloadableResourceBundleMessageSource;
//
import java.io.IOException; //import java.io.IOException;
import java.util.Locale; //import java.util.Locale;
import java.util.Objects; //import java.util.Objects;
//
/** ///**
* // * 多语言国际化消息工具类
* @author mcwl // * @author mcwl
*/ // */
@Slf4j //@Slf4j
public class I18nMessage { //public class I18nMessage {
private static MessageSourceAccessor accessor; // private static MessageSourceAccessor accessor;
//
// private static final String BASE_FOLDE = "i18n"; //// private static final String BASE_FOLDE = "i18n";
//
private static final String BASE_NAME = "i18n/messages"; // private static final String BASE_NAME = "i18n/messages";
//
static{ // static{
ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = new ReloadableResourceBundleMessageSource(); // ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = new ReloadableResourceBundleMessageSource();
reloadableResourceBundleMessageSource.setBasenames(BASE_NAME); // reloadableResourceBundleMessageSource.setBasenames(BASE_NAME);
reloadableResourceBundleMessageSource.setCacheSeconds(5); // reloadableResourceBundleMessageSource.setCacheSeconds(5);
reloadableResourceBundleMessageSource.setDefaultEncoding("UTF-8"); // reloadableResourceBundleMessageSource.setDefaultEncoding("UTF-8");
accessor = new MessageSourceAccessor(reloadableResourceBundleMessageSource); // accessor = new MessageSourceAccessor(reloadableResourceBundleMessageSource);
} // }
//
//
//// /**
//// * 获取一条语言配置信息
//// *
//// * @param message 配置信息属性名,eg: api.response.code.user.signUp
//// * @return
//// */
//// public static String getMessage(String message) {
//// Locale locale = LocaleContextHolder.getLocale();
//// return I18nMessage.accessor.getMessage(message,locale);
//// }
//
// /** // /**
// * 获取一条语言配置信息 // * 获取一条语言配置信息
// * // *
@ -48,97 +59,86 @@ public class I18nMessage {
// */ // */
// public static String getMessage(String message) { // public static String getMessage(String message) {
// Locale locale = LocaleContextHolder.getLocale(); // Locale locale = LocaleContextHolder.getLocale();
// return I18nMessage.accessor.getMessage(message,locale); // try {
// return accessor.getMessage(message,locale);
// }catch (Exception e){
// return message;
// }
//
// } // }
/**
*
*
* @param message ,eg: api.response.code.user.signUp
* @return
*/
public static String getMessage(String message) {
Locale locale = LocaleContextHolder.getLocale();
try {
return accessor.getMessage(message,locale);
}catch (Exception e){
return message;
}
}
/**
*
*
* @return
* @throws IOException
*/
public static Integer getLang() {
Locale locale = LocaleContextHolder.getLocale();
return LanguageEnum.valueOf(locale).getLang();
}
/**
* (pc)
*
* @return
* @throws IOException
*/
public static Integer getDbLang() {
Integer lang = getLang();
if (Objects.equals(lang, 0)) {
return LanguageEnum.LANGUAGE_ZH_CN.getLang();
}
return lang;
}
// /** // /**
// * 获取文件夹下所有的国际化文件名 // * 获取一条语言配置信息(后台管理)
// * // *
// * @param folderName 文件名
// * @return // * @return
// * @throws IOException // * @throws IOException
// */ // */
// private static String[] getAllBaseNames(final String folderName) throws IOException { // public static Integer getLang() {
// URL url = Thread.currentThread().getContextClassLoader() // Locale locale = LocaleContextHolder.getLocale();
// .getResource(folderName); // return LanguageEnum.valueOf(locale).getLang();
// if (null == url) {
// throw new RuntimeException("无法获取资源文件路径");
// }
//
// List<String> baseNames = new ArrayList<>();
// if (url.getProtocol().equalsIgnoreCase("file")) {
// // 文件夹形式,用File获取资源路径
// File file = new File(url.getFile());
// if (file.exists() && file.isDirectory()) {
// baseNames = Files.walk(file.toPath())
// .filter(path -> path.toFile().isFile())
// .map(Path::toString)
// .map(path -> path.substring(path.indexOf(folderName)))
// .map(I18nMessage::getI18FileName)
// .distinct()
// .collect(Collectors.toList());
// } else {
// log.error("指定的baseFile不存在或者不是文件夹");
// }
// }
// return baseNames.toArray(new String[0]);
// } // }
// //
// /** // /**
// * 把普通文件名转换成国际化文件名 // * 获取一条语言配置信息(小程序、pc)
// * // *
// * @param filename
// * @return // * @return
// * @throws IOException
// */ // */
// private static String getI18FileName(String filename) { // public static Integer getDbLang() {
// filename = filename.replace(".properties", ""); // Integer lang = getLang();
//// for (int i = 0; i < 2; i++) { // if (Objects.equals(lang, 0)) {
//// int index = filename.lastIndexOf("_"); // return LanguageEnum.LANGUAGE_ZH_CN.getLang();
//// if (index != -1) { // }
//// filename = filename.substring(0, index); // return lang;
//// } // }
//// } //
// return filename.replace("\\", "/"); //// /**
//// * 获取文件夹下所有的国际化文件名
//// *
//// * @param folderName 文件名
//// * @return
//// * @throws IOException
//// */
//// private static String[] getAllBaseNames(final String folderName) throws IOException {
//// URL url = Thread.currentThread().getContextClassLoader()
//// .getResource(folderName);
//// if (null == url) {
//// throw new RuntimeException("无法获取资源文件路径");
//// }
////
//// List<String> baseNames = new ArrayList<>();
//// if (url.getProtocol().equalsIgnoreCase("file")) {
//// // 文件夹形式,用File获取资源路径
//// File file = new File(url.getFile());
//// if (file.exists() && file.isDirectory()) {
//// baseNames = Files.walk(file.toPath())
//// .filter(path -> path.toFile().isFile())
//// .map(Path::toString)
//// .map(path -> path.substring(path.indexOf(folderName)))
//// .map(I18nMessage::getI18FileName)
//// .distinct()
//// .collect(Collectors.toList());
//// } else {
//// log.error("指定的baseFile不存在或者不是文件夹");
//// }
//// }
//// return baseNames.toArray(new String[0]);
//// }
////
//// /**
//// * 把普通文件名转换成国际化文件名
//// *
//// * @param filename
//// * @return
//// */
//// private static String getI18FileName(String filename) {
//// filename = filename.replace(".properties", "");
////// for (int i = 0; i < 2; i++) {
////// int index = filename.lastIndexOf("_");
////// if (index != -1) {
////// filename = filename.substring(0, index);
////// }
////// }
//// return filename.replace("\\", "/");
//// }
//
//} //}
}

View File

@ -1,53 +1,53 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.i18n; //package com.mcwl.common.i18n;
//
//
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.context.i18n.LocaleContextHolder; //import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.annotation.Order; //import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
import javax.servlet.*; //import javax.servlet.*;
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
import java.io.IOException; //import java.io.IOException;
import java.util.Locale; //import java.util.Locale;
import java.util.Objects; //import java.util.Objects;
//
/** ///**
* RequestContextFilter Locale(-105) RequestContextFilter // * RequestContextFilter 会传入默认的Locale优先级(-105) 要比RequestContextFilter优先级高
* @author LGH // * @author LGH
*/ // */
@Slf4j //@Slf4j
@Component //@Component
@Order(-104) //@Order(-104)
public class YamiLocaleChangeFilter implements Filter { //public class YamiLocaleChangeFilter implements Filter {
//
public static String ZH_CN = "zh_CN"; // public static String ZH_CN = "zh_CN";
public static String ZH_CN_L = "zh_cn"; // public static String ZH_CN_L = "zh_cn";
//
@Override // @Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { // public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest; // HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse; // HttpServletResponse response = (HttpServletResponse) servletResponse;
//
String newLocale = request.getHeader("locale"); // String newLocale = request.getHeader("locale");
if(Objects.equals(newLocale,ZH_CN)||Objects.equals(newLocale,ZH_CN_L)){ // if(Objects.equals(newLocale,ZH_CN)||Objects.equals(newLocale,ZH_CN_L)){
newLocale = "zh"; // newLocale = "zh";
} // }
if (newLocale != null) { // if (newLocale != null) {
String lowerLocale = newLocale.toLowerCase(); // String lowerLocale = newLocale.toLowerCase();
LocaleContextHolder.setLocale(new Locale(lowerLocale)); // LocaleContextHolder.setLocale(new Locale(lowerLocale));
} // }
filterChain.doFilter(request, response); // filterChain.doFilter(request, response);
} // }
} //}

View File

@ -1,58 +1,58 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.i18n; //package com.mcwl.common.i18n;
//
//
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.web.servlet.LocaleResolver; //import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; //import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.support.RequestContextUtils; //import org.springframework.web.servlet.support.RequestContextUtils;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
//
/** ///**
* @author LGH // * @author LGH
*/ // */
@Component("localeChangeInterceptor") //@Component("localeChangeInterceptor")
@Slf4j //@Slf4j
public class YamiLocaleChangeInterceptor extends LocaleChangeInterceptor { //public class YamiLocaleChangeInterceptor extends LocaleChangeInterceptor {
//
@Override // @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { // public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//
String newLocale = request.getHeader(getParamName()); // String newLocale = request.getHeader(getParamName());
if (newLocale != null) { // if (newLocale != null) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); // LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver == null) { // if (localeResolver == null) {
throw new IllegalStateException( // throw new IllegalStateException(
"No LocaleResolver found: not in a DispatcherServlet request?"); // "No LocaleResolver found: not in a DispatcherServlet request?");
} // }
try { // try {
localeResolver.setLocale(request, response, parseLocaleValue(newLocale)); // localeResolver.setLocale(request, response, parseLocaleValue(newLocale));
} // }
catch (IllegalArgumentException ex) { // catch (IllegalArgumentException ex) {
if (isIgnoreInvalidLocale()) { // if (isIgnoreInvalidLocale()) {
if (logger.isDebugEnabled()) { // if (logger.isDebugEnabled()) {
logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage()); // logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage());
} // }
} // }
else { // else {
throw ex; // throw ex;
} // }
} // }
} // }
// Proceed in any case. // // Proceed in any case.
return true; // return true;
} // }
//
} //}

View File

@ -1,99 +1,99 @@
/* ///*
* Copyright (c) 2018-2999 广 All rights reserved. // * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
* // *
* https://www.mall4j.com/ // * https://www.mall4j.com/
* // *
* // * 未经允许,不可做商业用途!
* // *
* // * 版权所有,侵权必究!
*/ // */
package com.mcwl.common.utils; //package com.mcwl.common.utils;
//
import cn.hutool.core.util.StrUtil; //import cn.hutool.core.util.StrUtil;
import com.mcwl.common.exception.YamiShopBindException; //import com.mcwl.common.exception.YamiShopBindException;
//
//
import javax.imageio.ImageIO; //import javax.imageio.ImageIO;
import java.awt.*; //import java.awt.*;
import java.awt.image.BufferedImage; //import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; //import java.io.ByteArrayOutputStream;
import java.io.IOException; //import java.io.IOException;
import java.net.URL; //import java.net.URL;
//
/** ///**
* // * 图片处理工具类
//
*/ // */
public class ImageUtil { //public class ImageUtil {
private static final String JPG = "jpg"; // private static final String JPG = "jpg";
private static final String JPEG = "jpeg"; // private static final String JPEG = "jpeg";
/** // /**
* // * 将图片转为二进制数组
* @param imgUrl // * @param imgUrl
* @return // * @return
*/ // */
public static byte[] imgToBinary(String imgUrl) { // public static byte[] imgToBinary(String imgUrl) {
try { // try {
BufferedImage bufferedImage = ImageIO.read(new URL(imgUrl)); // BufferedImage bufferedImage = ImageIO.read(new URL(imgUrl));
ByteArrayOutputStream baos = new ByteArrayOutputStream(); // ByteArrayOutputStream baos = new ByteArrayOutputStream();
String suffix = imgUrlFileType(imgUrl); // String suffix = imgUrlFileType(imgUrl);
//ImageIO无法写入jpeg文件 报Invalid argument to native writeImage需重画 // //ImageIO无法写入jpeg文件 报Invalid argument to native writeImage需重画
if(StrUtil.equals(suffix, JPG) || StrUtil.equals(suffix,JPEG)){ // if(StrUtil.equals(suffix, JPG) || StrUtil.equals(suffix,JPEG)){
BufferedImage tag; // BufferedImage tag;
tag = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_BGR); // tag = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_BGR);
Graphics g = tag.getGraphics(); // Graphics g = tag.getGraphics();
g.drawImage(bufferedImage, 0, 0, null); // g.drawImage(bufferedImage, 0, 0, null);
g.dispose(); // g.dispose();
bufferedImage = tag; // bufferedImage = tag;
} // }
ImageIO.write(bufferedImage, suffix, baos); // ImageIO.write(bufferedImage, suffix, baos);
byte[] bytes = baos.toByteArray(); // byte[] bytes = baos.toByteArray();
return bytes; // return bytes;
} catch (IOException e) { // } catch (IOException e) {
// 图片丢失,请重新上传图片 // // 图片丢失,请重新上传图片
throw new YamiShopBindException("yami.img.lose"); // throw new YamiShopBindException("yami.img.lose");
} // }
} // }
//
/** // /**
* @param imgUrl // * @param imgUrl
* @return jpg , png , ... // * @return 文件得后缀,文件类型 jpg , png , ...
*/ // */
public static String imgUrlFileType(String imgUrl) { // public static String imgUrlFileType(String imgUrl) {
if (StrUtil.isBlank(imgUrl)) { // if (StrUtil.isBlank(imgUrl)) {
return imgUrl; // return imgUrl;
} // }
imgUrl.trim(); // imgUrl.trim();
String[] split = imgUrl.split("\\."); // String[] split = imgUrl.split("\\.");
String s = split[split.length - 1]; // String s = split[split.length - 1];
return s; // return s;
} // }
//
/** // /**
* @param imgUrl // * @param imgUrl
* @return // * @return 获取文件名称
*/ // */
public static String imgUrlFileName(String imgUrl) { // public static String imgUrlFileName(String imgUrl) {
if (StrUtil.isBlank(imgUrl)) { // if (StrUtil.isBlank(imgUrl)) {
return imgUrl; // return imgUrl;
} // }
imgUrl.trim(); // imgUrl.trim();
String[] split = imgUrl.split("/"); // String[] split = imgUrl.split("/");
String s = split[split.length - 1]; // String s = split[split.length - 1];
return s; // return s;
} // }
/** // /**
* @param imgUrl // * @param imgUrl
* @return 45d3631e97d8438d80f9db1369595b8c // * @return 获取文件名称 45d3631e97d8438d80f9db1369595b8c
*/ // */
public static String imgUrlFileNameNoSuffix(String imgUrl) { // public static String imgUrlFileNameNoSuffix(String imgUrl) {
if (StrUtil.isBlank(imgUrl)) { // if (StrUtil.isBlank(imgUrl)) {
return imgUrl; // return imgUrl;
} // }
imgUrl.trim(); // imgUrl.trim();
String[] split = imgUrl.split("/"); // String[] split = imgUrl.split("/");
String s = split[split.length - 1]; // String s = split[split.length - 1];
String[] split1 = s.split("\\."); // String[] split1 = s.split("\\.");
return split1[0]; // return split1[0];
} // }
} //}

View File

@ -34,9 +34,6 @@ public class Member extends BaseEntity {
// 订阅周期(天) // 订阅周期(天)
private Integer subscriptionPeriod; private Integer subscriptionPeriod;
// 删除标志0代表存在 2代表删除
private String delFlag;
// 备注 // 备注
private String remark; private String remark;
} }

View File

@ -3,6 +3,7 @@ package com.mcwl.memberCenter.domain;
import com.baomidou.mybatisplus.annotation.EnumValue; import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.mcwl.common.core.domain.BaseEntity; import com.mcwl.common.core.domain.BaseEntity;
import com.mcwl.memberCenter.enums.MemberMenu; import com.mcwl.memberCenter.enums.MemberMenu;
@ -53,9 +54,6 @@ public class UserMember extends BaseEntity {
// 状态(0:正常 1:禁用) // 状态(0:正常 1:禁用)
private String status; private String status;
// 删除标志0代表存在 2代表删除
private String delFlag;
// 备注 // 备注
private String remark; private String remark;

View File

@ -101,7 +101,9 @@ public class UserMemberTask {
.ge(UserMember::getEndDate, System.currentTimeMillis()) .ge(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) .ne(UserMember::getSubscriptionStatus, MemberMenu.MEMBER_CENTER_PENDING)
.eq(UserMember::getStatus, '0'); .eq(UserMember::getStatus, "0");
// 对应的sql为
System.out.println("sql = " + qw.getSqlSegment());
return userMemberService.list(); return userMemberService.list();
} }

View File

@ -27,9 +27,6 @@ public class Commission extends BaseEntity {
// 支付状态 // 支付状态
private Integer payStatus; private Integer payStatus;
// 删除标志0代表存在 2代表删除
private String delFlag;
// 备注 // 备注
private String remark; private String remark;

View File

@ -25,9 +25,6 @@ public class Consume extends BaseEntity {
// 消费时间 // 消费时间
private Date consumeDate; private Date consumeDate;
// 删除标志0代表存在 2代表删除
private String delFlag;
// 备注 // 备注
private String remark; private String remark;

View File

@ -25,9 +25,6 @@ public class Invitation extends BaseEntity {
// 邀请码 // 邀请码
private String invitationCode; private String invitationCode;
// 删除标志0代表存在 2代表删除
private String delFlag;
// 备注 // 备注
private String remark; private String remark;