mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-19 21:45:06 +08:00
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
package cn.iocoder.yudao.framework.common.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -7,6 +11,9 @@ import java.io.Serializable;
|
||||
*
|
||||
* 类名加了 ing 的原因是,避免和 ES SortField 重名。
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SortingField implements Serializable {
|
||||
|
||||
/**
|
||||
@ -27,30 +34,4 @@ public class SortingField implements Serializable {
|
||||
*/
|
||||
private String order;
|
||||
|
||||
// 空构造方法,解决反序列化
|
||||
public SortingField() {
|
||||
}
|
||||
|
||||
public SortingField(String field, String order) {
|
||||
this.field = field;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public SortingField setField(String field) {
|
||||
this.field = field;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public SortingField setOrder(String order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class DateUtils {
|
||||
* @return LocalDateTime
|
||||
*/
|
||||
public static Date of(LocalDateTime date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
// 将此日期时间与时区相结合以创建 ZonedDateTime
|
||||
ZonedDateTime zonedDateTime = date.atZone(ZoneId.systemDefault());
|
||||
// 本地时间线 LocalDateTime 到即时时间线 Instant 时间戳
|
||||
@ -51,6 +54,9 @@ public class DateUtils {
|
||||
* @return LocalDateTime
|
||||
*/
|
||||
public static LocalDateTime of(Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
// 转为时间戳
|
||||
Instant instant = date.toInstant();
|
||||
// UTC时间(世界协调时间,UTC + 00:00)转北京(北京,UTC + 8:00)时间
|
||||
|
@ -17,7 +17,7 @@ import java.lang.annotation.*;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(
|
||||
validatedBy = InEnumValidator.class
|
||||
validatedBy = {InEnumValidator.class, InEnumCollectionValidator.class}
|
||||
)
|
||||
public @interface InEnum {
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.framework.common.validation;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class InEnumCollectionValidator implements ConstraintValidator<InEnum, Collection<Integer>> {
|
||||
|
||||
private List<Integer> values;
|
||||
|
||||
@Override
|
||||
public void initialize(InEnum annotation) {
|
||||
IntArrayValuable[] values = annotation.value().getEnumConstants();
|
||||
if (values.length == 0) {
|
||||
this.values = Collections.emptyList();
|
||||
} else {
|
||||
this.values = Arrays.stream(values[0].array()).boxed().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Collection<Integer> list, ConstraintValidatorContext context) {
|
||||
// 校验通过
|
||||
if (CollUtil.containsAll(values, list)) {
|
||||
return true;
|
||||
}
|
||||
// 校验不通过,自定义提示语句(因为,注解上的 value 是枚举类,无法获得枚举类的实际值)
|
||||
context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值
|
||||
context.buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate()
|
||||
.replaceAll("\\{value}", CollUtil.join(list, ","))).addConstraintViolation(); // 重新添加错误提示语句
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFactory;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||
import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport;
|
||||
@ -508,6 +507,9 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
|
||||
// 单条规则的条件
|
||||
String tableName = MyBatisUtils.getTableName(table);
|
||||
Expression oneExpress = rule.getExpression(tableName, table.getAlias());
|
||||
if (oneExpress == null){
|
||||
continue;
|
||||
}
|
||||
// 拼接到 allExpression 中
|
||||
allExpression = allExpression == null ? oneExpress
|
||||
: new AndExpression(allExpression, oneExpress);
|
||||
|
@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule;
|
||||
import cn.iocoder.yudao.framework.expression.OrExpressionX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
@ -17,10 +16,8 @@ import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespD
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.expression.Alias;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import net.sf.jsqlparser.expression.NullValue;
|
||||
import net.sf.jsqlparser.expression.*;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
|
||||
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
|
||||
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
|
||||
import net.sf.jsqlparser.expression.operators.relational.InExpression;
|
||||
@ -144,7 +141,7 @@ public class DeptDataPermissionRule implements DataPermissionRule {
|
||||
return deptExpression;
|
||||
}
|
||||
// 目前,如果有指定部门 + 可查看自己,采用 OR 条件。即,WHERE (dept_id IN ? OR user_id = ?)
|
||||
return new OrExpressionX(deptExpression, userExpression);
|
||||
return new Parenthesis(new OrExpression(deptExpression, userExpression));
|
||||
}
|
||||
|
||||
private Expression buildDeptExpression(String tableName, Alias tableAlias, Set<Long> deptIds) {
|
||||
|
@ -1,63 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.pay.core.client.impl.delegate;
|
||||
|
||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// TODO @jason:其它模块,主要是无法 pay client 初始化存在问题,所以我感觉,是不是可以搞个 PayClientInitializer 接口。这样,PayClientFactory 去 get 这个支付模式对应的 PayClientInitializer,通过它来创建。具体注入的地方,可以在 PayChannel init 方法那;
|
||||
/**
|
||||
* 代理支付 Client 的抽象类。
|
||||
*
|
||||
* 用于支付 Client 由其它模块实现,例如钱包支付
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public abstract class DelegatePayClient<Config extends PayClientConfig> extends AbstractPayClient<PayClientConfig> {
|
||||
|
||||
private final DelegatePayClient<Config> delegate;
|
||||
|
||||
public DelegatePayClient(Long channelId, String channelCode, PayClientConfig config) {
|
||||
super(channelId, channelCode, config);
|
||||
delegate = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() {
|
||||
delegate.doInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayOrderRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) {
|
||||
return delegate.doUnifiedOrder(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayOrderRespDTO doGetOrder(String outTradeNo) {
|
||||
return delegate.doGetOrder(outTradeNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayRefundRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) {
|
||||
return delegate.doUnifiedRefund(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayRefundRespDTO doGetRefund(String outTradeNo, String outRefundNo) {
|
||||
return delegate.doGetRefund(outTradeNo, outRefundNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayRefundRespDTO doParseRefundNotify(Map<String,String> params, String body) {
|
||||
return delegate.doParseRefundNotify(params, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PayOrderRespDTO doParseOrderNotify(Map<String,String> params, String body) {
|
||||
return delegate.doParseOrderNotify(params, body);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDT
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -17,11 +18,11 @@ import java.util.Map;
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public class MockPayClient extends AbstractPayClient<MockPayClientConfig> {
|
||||
public class MockPayClient extends AbstractPayClient<NonePayClientConfig> {
|
||||
|
||||
private static final String MOCK_RESP_SUCCESS_DATA = "MOCK_SUCCESS";
|
||||
|
||||
public MockPayClient(Long channelId, MockPayClientConfig config) {
|
||||
public MockPayClient(Long channelId, NonePayClientConfig config) {
|
||||
super(channelId, PayChannelEnum.MOCK.getCode(), config);
|
||||
}
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.pay.core.client.impl.mock;
|
||||
|
||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Validator;
|
||||
|
||||
/**
|
||||
* 模拟支付的 PayClientConfig 实现类
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class MockPayClientConfig implements PayClientConfig {
|
||||
|
||||
/**
|
||||
* 配置名称
|
||||
*
|
||||
* 如果不加任何属性,JsonUtils.parseObject2 解析会报错,所以暂时加个名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public void validate(Validator validator) {
|
||||
// 模拟支付配置无需校验
|
||||
}
|
||||
|
||||
}
|
@ -56,7 +56,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
protected void doInit(String tradeType) {
|
||||
// 创建 config 配置
|
||||
WxPayConfig payConfig = new WxPayConfig();
|
||||
BeanUtil.copyProperties(config, payConfig, "keyContent");
|
||||
BeanUtil.copyProperties(config, payConfig, "keyContent", "privateKeyContent", "privateCertContent");
|
||||
payConfig.setTradeType(tradeType);
|
||||
// weixin-pay-java 无法设置内容,只允许读取文件,所以这里要创建临时文件来解决
|
||||
if (Base64.isBase64(config.getKeyContent())) {
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClientConfig;
|
||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@ -30,7 +29,7 @@ public enum PayChannelEnum {
|
||||
ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class),
|
||||
ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class),
|
||||
|
||||
MOCK("mock", "模拟支付", MockPayClientConfig.class),
|
||||
MOCK("mock", "模拟支付", NonePayClientConfig.class),
|
||||
|
||||
WALLET("wallet", "钱包支付", NonePayClientConfig.class);
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.expression;
|
||||
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||
|
||||
/**
|
||||
* AndExpression 的扩展类(会在原有表达式两端加上括号)
|
||||
*/
|
||||
public class AndExpressionX extends AndExpression {
|
||||
|
||||
public AndExpressionX() {
|
||||
}
|
||||
|
||||
public AndExpressionX(Expression leftExpression, Expression rightExpression) {
|
||||
this.setLeftExpression(leftExpression);
|
||||
this.setRightExpression(rightExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + super.toString() + ")";
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.expression;
|
||||
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
|
||||
|
||||
/**
|
||||
* OrExpression 的扩展类(会在原有表达式两端加上括号)
|
||||
*/
|
||||
public class OrExpressionX extends OrExpression {
|
||||
|
||||
public OrExpressionX() {
|
||||
}
|
||||
|
||||
public OrExpressionX(Expression leftExpression, Expression rightExpression) {
|
||||
this.setLeftExpression(leftExpression);
|
||||
this.setRightExpression(rightExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + super.toString() + ")";
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.mybatis.core.mapper;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -17,8 +19,11 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 在 MyBatis Plus 的 BaseMapper 的基础上拓展,提供更多的能力
|
||||
*
|
||||
* 1. {@link BaseMapper} 为 MyBatis Plus 的基础接口,提供基础的 CRUD 能力
|
||||
* 2. {@link MPJBaseMapper} 为 MyBatis Plus Join 的基础接口,提供连表 Join 能力
|
||||
*/
|
||||
public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
|
||||
default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
|
||||
// MyBatis Plus 查询
|
||||
@ -75,10 +80,16 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
}
|
||||
|
||||
default List<T> selectList(String field, Collection<?> values) {
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return selectList(new QueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
default List<T> selectList(SFunction<T, ?> field, Collection<?> values) {
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return selectList(new LambdaQueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.web.core.util;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||
@ -89,10 +88,10 @@ public class WebFrameworkUtils {
|
||||
return userType;
|
||||
}
|
||||
// 2. 其次,基于 URL 前缀的约定
|
||||
if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix())) {
|
||||
if (request.getServletPath().startsWith(properties.getAdminApi().getPrefix())) {
|
||||
return UserTypeEnum.ADMIN.getValue();
|
||||
}
|
||||
if (request.getRequestURI().startsWith(properties.getAppApi().getPrefix())) {
|
||||
if (request.getServletPath().startsWith(properties.getAppApi().getPrefix())) {
|
||||
return UserTypeEnum.MEMBER.getValue();
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user