修改商城内容
This commit is contained in:
parent
cc03351620
commit
81e5b80f64
@ -32,6 +32,11 @@ captcha:
|
||||
# 字符验证码长度
|
||||
charLength: 4
|
||||
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
|
@ -15,6 +15,7 @@
|
||||
ruoyi-common-core 核心模块
|
||||
</description>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring框架基本的核心工具 -->
|
||||
<dependency>
|
||||
@ -93,7 +94,49 @@
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>0.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>0.11.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.11.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
<version>0.2.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -0,0 +1,124 @@
|
||||
package org.dromara.common.core.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "ruoyi")
|
||||
public class RuoYiConfig
|
||||
{
|
||||
/** 项目名称 */
|
||||
private String name;
|
||||
|
||||
/** 版本 */
|
||||
private String version;
|
||||
|
||||
/** 版权年份 */
|
||||
private String copyrightYear;
|
||||
|
||||
/** 实例演示开关 */
|
||||
private boolean demoEnabled;
|
||||
|
||||
/** 上传路径 */
|
||||
private static String profile;
|
||||
|
||||
/** 获取地址开关 */
|
||||
private static boolean addressEnabled;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getCopyrightYear()
|
||||
{
|
||||
return copyrightYear;
|
||||
}
|
||||
|
||||
public void setCopyrightYear(String copyrightYear)
|
||||
{
|
||||
this.copyrightYear = copyrightYear;
|
||||
}
|
||||
|
||||
public boolean isDemoEnabled()
|
||||
{
|
||||
return demoEnabled;
|
||||
}
|
||||
|
||||
public void setDemoEnabled(boolean demoEnabled)
|
||||
{
|
||||
this.demoEnabled = demoEnabled;
|
||||
}
|
||||
|
||||
public static String getProfile()
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile)
|
||||
{
|
||||
RuoYiConfig.profile = profile;
|
||||
}
|
||||
|
||||
public static boolean isAddressEnabled()
|
||||
{
|
||||
return addressEnabled;
|
||||
}
|
||||
|
||||
public void setAddressEnabled(boolean addressEnabled)
|
||||
{
|
||||
RuoYiConfig.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入上传路径
|
||||
*/
|
||||
public static String getImportPath()
|
||||
{
|
||||
return getProfile() + "/import";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取头像上传路径
|
||||
*/
|
||||
public static String getAvatarPath()
|
||||
{
|
||||
return getProfile() + "/avatar";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*/
|
||||
public static String getDownloadPath()
|
||||
{
|
||||
return getProfile() + "/download/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传路径
|
||||
*/
|
||||
public static String getUploadPath()
|
||||
{
|
||||
return getProfile() + "/upload";
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package org.dromara.common.core.domain;
|
||||
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public abstract class BaseEntity extends BaseAudit implements Serializable, IQuery {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Override
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.dromara.common.core.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IQuery {
|
||||
/**
|
||||
* @return 搜索值
|
||||
*/
|
||||
String getSearchValue();
|
||||
|
||||
/**
|
||||
* @return 所有参数
|
||||
*/
|
||||
Map<String, Object> getParams();
|
||||
}
|
@ -0,0 +1,263 @@
|
||||
package org.dromara.common.core.domain.event;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Constants
|
||||
{
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
public static final String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* GBK 字符集
|
||||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 通用成功标识
|
||||
*/
|
||||
public static final String SUCCESS = "0";
|
||||
|
||||
/**
|
||||
* 通用失败标识
|
||||
*/
|
||||
public static final String FAIL = "1";
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS = "Success";
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static final String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public static final String REGISTER = "Register";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 登录用户 redis key
|
||||
*/
|
||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
public static final String LOGIN_MEMBER_TOKEN_KEY = "login_member_tokens:";
|
||||
public static final String MEMBER_INFO = "member_info";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||
|
||||
/**
|
||||
* 限流 redis key
|
||||
*/
|
||||
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final Integer CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
public static final String LOGIN_MEMBER_KEY = "login_member_key";
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
public static final String JWT_USERID = "userid";
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
public static final String JWT_AVATAR = "avatar";
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
public static final String JWT_CREATED = "created";
|
||||
|
||||
/**
|
||||
* 用户权限
|
||||
*/
|
||||
public static final String JWT_AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
public static final String INTEGRAL_RULE_KEY = "activity-integral-income-set-key";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi://";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap://";
|
||||
|
||||
public static final String SPAN_ID = "spanId";
|
||||
|
||||
/**
|
||||
* 会员账号状态
|
||||
*/
|
||||
public static class MEMBER_ACCOUNT_STATUS {
|
||||
public static final Integer FORBIDDEN = 0;
|
||||
public static final Integer NORMAL = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录提示信息
|
||||
*/
|
||||
public static class LOGIN_INFO {
|
||||
public static final String WRONG = "账号或密码错误";
|
||||
public static final String FORBIDDEN = "您的账号被禁用,请联系管理员";
|
||||
public static final String SUCCESS = "登录成功";
|
||||
public static final String TO_REGISTER = "请先注册";
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码相关提示信息
|
||||
*/
|
||||
public static class VERIFY_CODE_INFO {
|
||||
public static final String EXPIRED = "验证码已过期";
|
||||
public static final String WRONG = "验证码错误";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上架状态:0->下架;1->上架
|
||||
*/
|
||||
public static class PublishStatus {
|
||||
public static final Integer GROUNDING = 1;
|
||||
public static final Integer UNDERCARRIAGE = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0->未支付;1->支付宝;2->微信
|
||||
*/
|
||||
public static class PayType {
|
||||
public static final Integer NO_PAY = 0;
|
||||
public static final Integer ALIPAY = 1;
|
||||
public static final Integer WECHAT = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单来源 购物车:cart
|
||||
*/
|
||||
public static class OrderFrom {
|
||||
public static final String CART = "cart";
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态 0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
||||
*/
|
||||
public static class OrderStatus {
|
||||
public static final Integer NOTPAID = 0;
|
||||
public static final Integer SEND = 1;
|
||||
public static final Integer GET = 2;
|
||||
public static final Integer CONFIRM = 3;
|
||||
public static final Integer CLOSED = 4;
|
||||
public static final Integer UNVAILD = 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* H5订单查询状态
|
||||
* -1->全部 0->待付款;1->待发货;2->待收货;3->已完成;4->已关闭;5->无效订单 -2->售后单
|
||||
*/
|
||||
public static class H5OrderStatus{
|
||||
public static final Integer ALL = -1;
|
||||
public static final Integer UN_PAY = 0;
|
||||
public static final Integer NOT_DELIVERED = 1;
|
||||
public static final Integer DELIVERED = 2;
|
||||
public static final Integer COMPLETED = 3;
|
||||
public static final Integer CLOSED = 4;
|
||||
public static final Integer INVALID = 5;
|
||||
public static final Integer REFUND = -2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易类型(1为支付 2为提现 3为退款)
|
||||
*/
|
||||
public static class PaymentOpType {
|
||||
public static final Integer PAY = 1;
|
||||
public static final Integer WITHDRAWAL = 2;
|
||||
public static final Integer REFUND = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(0:未完成交易 1:完成关键交易)
|
||||
*/
|
||||
public static class PaymentStatus {
|
||||
public static final Integer INCOMPLETE = 0;
|
||||
public static final Integer COMPLETE = 1;
|
||||
}
|
||||
|
||||
public static class OptType {
|
||||
public static final Integer AGREE = 1;
|
||||
public static final Integer REFUSE = 2;
|
||||
public static final Integer GIVING = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||
*/
|
||||
public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi","com.cyl" };
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package org.dromara.common.core.domain.event;
|
||||
|
||||
/**
|
||||
* 用户常量信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class UserConstants
|
||||
{
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
|
||||
/** 正常状态 */
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/** 异常状态 */
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/** 用户封禁状态 */
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/** 角色封禁状态 */
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/** 部门正常状态 */
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/** 部门停用状态 */
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/** 字典正常状态 */
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/** 是否为系统默认(是) */
|
||||
public static final String YES = "Y";
|
||||
|
||||
/** 是否菜单外链(是) */
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/** 是否菜单外链(否) */
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/** 菜单类型(目录) */
|
||||
public static final String TYPE_DIR = "M";
|
||||
|
||||
/** 菜单类型(菜单) */
|
||||
public static final String TYPE_MENU = "C";
|
||||
|
||||
/** 菜单类型(按钮) */
|
||||
public static final String TYPE_BUTTON = "F";
|
||||
|
||||
/** Layout组件标识 */
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/** ParentView组件标识 */
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/** InnerLink组件标识 */
|
||||
public final static String INNER_LINK = "InnerLink";
|
||||
|
||||
/** 校验返回结果码 */
|
||||
public final static String UNIQUE = "0";
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
|
||||
/**
|
||||
* 用户名长度限制
|
||||
*/
|
||||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
*/
|
||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.dromara.common.core.domain.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class BaseAudit {
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.domain.dto.PostDTO;
|
||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@ -132,6 +133,11 @@ public class LoginUser implements Serializable {
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private SysUser user;
|
||||
|
||||
/**
|
||||
* 获取登录id
|
||||
*/
|
||||
@ -145,4 +151,9 @@ public class LoginUser implements Serializable {
|
||||
return userType + ":" + userId;
|
||||
}
|
||||
|
||||
public SysUser getUser()
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,176 @@
|
||||
package org.dromara.common.core.entity;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.dromara.common.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.domain.event.UserConstants;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 字典数据表 sys_dict_data
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysDictData extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典编码 */
|
||||
@Excel(name = "字典编码", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long dictCode;
|
||||
|
||||
/** 字典排序 */
|
||||
@Excel(name = "字典排序", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long dictSort;
|
||||
|
||||
/** 字典标签 */
|
||||
@Excel(name = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/** 字典键值 */
|
||||
@Excel(name = "字典键值")
|
||||
private String dictValue;
|
||||
|
||||
/** 字典类型 */
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/** 样式属性(其他样式扩展) */
|
||||
private String cssClass;
|
||||
|
||||
/** 表格字典样式 */
|
||||
private String listClass;
|
||||
|
||||
/** 是否默认(Y是 N否) */
|
||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
||||
private String isDefault;
|
||||
|
||||
/** 状态(0正常 1停用) */
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
public Long getDictCode()
|
||||
{
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(Long dictCode)
|
||||
{
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public Long getDictSort()
|
||||
{
|
||||
return dictSort;
|
||||
}
|
||||
|
||||
public void setDictSort(Long dictSort)
|
||||
{
|
||||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel()
|
||||
{
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel)
|
||||
{
|
||||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue()
|
||||
{
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
public void setDictValue(String dictValue)
|
||||
{
|
||||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType()
|
||||
{
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType)
|
||||
{
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass()
|
||||
{
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass)
|
||||
{
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass()
|
||||
{
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass)
|
||||
{
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public boolean getDefault()
|
||||
{
|
||||
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
||||
}
|
||||
|
||||
public String getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictCode", getDictCode())
|
||||
.append("dictSort", getDictSort())
|
||||
.append("dictLabel", getDictLabel())
|
||||
.append("dictValue", getDictValue())
|
||||
.append("dictType", getDictType())
|
||||
.append("cssClass", getCssClass())
|
||||
.append("listClass", getListClass())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,343 @@
|
||||
package org.dromara.common.core.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.dromara.common.core.domain.BaseEntity;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.excel.annotation.Excels;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRole;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysUser extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户ID */
|
||||
@Excel(name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/** 部门ID */
|
||||
@Excel(name = "部门编号", type = Excel.Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
/** 用户账号 */
|
||||
@Excel(name = "登录名称")
|
||||
private String userName;
|
||||
|
||||
/** 用户昵称 */
|
||||
@Excel(name = "用户名称")
|
||||
private String nickName;
|
||||
|
||||
/** 用户邮箱 */
|
||||
@Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/** 手机号码 */
|
||||
@Excel(name = "手机号码")
|
||||
private String phonenumber;
|
||||
|
||||
/** 用户性别 */
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
/** 用户头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
/** 盐加密 */
|
||||
private String salt;
|
||||
|
||||
/** 帐号状态(0正常 1停用) */
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 最后登录IP */
|
||||
@Excel(name = "最后登录IP", type = Excel.Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
/** 最后登录时间 */
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
/** 部门对象 */
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
|
||||
})
|
||||
private SysDept dept;
|
||||
|
||||
/** 角色对象 */
|
||||
private List<SysRole> roles;
|
||||
|
||||
/** 角色组 */
|
||||
private Long[] roleIds;
|
||||
|
||||
/** 岗位组 */
|
||||
private Long[] postIds;
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
public SysUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SysUser(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long userId)
|
||||
{
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId)
|
||||
{
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
public String getNickName()
|
||||
{
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName)
|
||||
{
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||
public String getUserName()
|
||||
{
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName)
|
||||
{
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
||||
public String getPhonenumber()
|
||||
{
|
||||
return phonenumber;
|
||||
}
|
||||
|
||||
public void setPhonenumber(String phonenumber)
|
||||
{
|
||||
this.phonenumber = phonenumber;
|
||||
}
|
||||
|
||||
public String getSex()
|
||||
{
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex)
|
||||
{
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAvatar()
|
||||
{
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar)
|
||||
{
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSalt()
|
||||
{
|
||||
return salt;
|
||||
}
|
||||
|
||||
public void setSalt(String salt)
|
||||
{
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getLoginIp()
|
||||
{
|
||||
return loginIp;
|
||||
}
|
||||
|
||||
public void setLoginIp(String loginIp)
|
||||
{
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
public Date getLoginDate()
|
||||
{
|
||||
return loginDate;
|
||||
}
|
||||
|
||||
public void setLoginDate(Date loginDate)
|
||||
{
|
||||
this.loginDate = loginDate;
|
||||
}
|
||||
|
||||
public SysDept getDept()
|
||||
{
|
||||
return dept;
|
||||
}
|
||||
|
||||
public void setDept(SysDept dept)
|
||||
{
|
||||
this.dept = dept;
|
||||
}
|
||||
|
||||
public List<SysRole> getRoles()
|
||||
{
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<SysRole> roles)
|
||||
{
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public Long[] getRoleIds()
|
||||
{
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(Long[] roleIds)
|
||||
{
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public Long[] getPostIds()
|
||||
{
|
||||
return postIds;
|
||||
}
|
||||
|
||||
public void setPostIds(Long[] postIds)
|
||||
{
|
||||
this.postIds = postIds;
|
||||
}
|
||||
|
||||
public Long getRoleId()
|
||||
{
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId)
|
||||
{
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
.append("userName", getUserName())
|
||||
.append("nickName", getNickName())
|
||||
.append("email", getEmail())
|
||||
.append("phonenumber", getPhonenumber())
|
||||
.append("sex", getSex())
|
||||
.append("avatar", getAvatar())
|
||||
.append("password", getPassword())
|
||||
.append("salt", getSalt())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("loginIp", getLoginIp())
|
||||
.append("loginDate", getLoginDate())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("dept", getDept())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.dromara.common.core.enums;
|
||||
|
||||
/**
|
||||
* 售后状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum AftersaleStatus
|
||||
{
|
||||
APPLY(0, "待处理"),
|
||||
WAIT(1, "退货中"),
|
||||
SUCCESS(2, "已完成"),
|
||||
REJECT(3, "已拒绝"),
|
||||
CANCEL(4,"用户取消");
|
||||
|
||||
private final Integer type;
|
||||
private final String msg;
|
||||
|
||||
private AftersaleStatus(Integer type, String msg) {
|
||||
this.type = type;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package org.dromara.common.core.enums;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum OrderRefundStatus
|
||||
{
|
||||
NO_REFUND(1, "无售后"),
|
||||
APPLY(2, "申请中"),
|
||||
WAIT(3, "退款中"),
|
||||
SUCCESS(4, "退款成功"),
|
||||
FAIL(5,"退款失败");
|
||||
|
||||
private final Integer type;
|
||||
private final String msg;
|
||||
|
||||
private OrderRefundStatus(Integer type, String msg) {
|
||||
this.type = type;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
|
||||
/**
|
||||
* aes加密工具
|
||||
*/
|
||||
public class AesCryptoUtils {
|
||||
|
||||
public static String encrypt(String key, String content){
|
||||
SecureUtil.disableBouncyCastle();
|
||||
if (StringUtils.isBlank(key) || StringUtils.isBlank(content)){
|
||||
throw new RuntimeException("错误");
|
||||
}
|
||||
AES aes = SecureUtil.aes(key.getBytes());
|
||||
byte[] encrypt = aes.encrypt(content);
|
||||
return aes.encryptHex(content);
|
||||
}
|
||||
|
||||
public static String decrypt(String key, String content){
|
||||
SecureUtil.disableBouncyCastle();
|
||||
if (StringUtils.isBlank(key) || StringUtils.isBlank(content)){
|
||||
throw new RuntimeException("错误");
|
||||
}
|
||||
AES aes = SecureUtil.aes(key.getBytes());
|
||||
return aes.decryptStr(content, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
}
|
@ -1,287 +1,184 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.dromara.common.core.enums.FormatsType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
private static final String[] PARSE_PATTERNS = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
@Deprecated
|
||||
private DateUtils() {
|
||||
}
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
||||
/**
|
||||
* 获取当前日期和时间
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return 当前日期和时间的 Date 对象表示
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate() {
|
||||
public static Date getNowDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期的字符串表示,格式为YYYY-MM-DD
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return 当前日期的字符串表示
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate() {
|
||||
return dateTimeNow(FormatsType.YYYY_MM_DD);
|
||||
public static String getDate()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期的字符串表示,格式为yyyyMMdd
|
||||
*
|
||||
* @return 当前日期的字符串表示
|
||||
*/
|
||||
public static String getCurrentDate() {
|
||||
return DateFormatUtils.format(new Date(), FormatsType.YYYYMMDD.getTimeFormat());
|
||||
public static final String getTime()
|
||||
{
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期的路径格式字符串,格式为"yyyy/MM/dd"
|
||||
*
|
||||
* @return 当前日期的路径格式字符串
|
||||
*/
|
||||
public static String datePath() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, FormatsType.YYYY_MM_DD_SLASH.getTimeFormat());
|
||||
public static final String dateTimeNow()
|
||||
{
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间的字符串表示,格式为YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @return 当前时间的字符串表示
|
||||
*/
|
||||
public static String getTime() {
|
||||
return dateTimeNow(FormatsType.YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间的字符串表示,格式为 "HH:MM:SS"
|
||||
*
|
||||
* @return 当前时间的字符串表示,格式为 "HH:MM:SS"
|
||||
*/
|
||||
public static String getTimeWithHourMinuteSecond() {
|
||||
return dateTimeNow(FormatsType.HH_MM_SS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期和时间的字符串表示,格式为YYYYMMDDHHMMSS
|
||||
*
|
||||
* @return 当前日期和时间的字符串表示
|
||||
*/
|
||||
public static String dateTimeNow() {
|
||||
return dateTimeNow(FormatsType.YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期和时间的指定格式的字符串表示
|
||||
*
|
||||
* @param format 日期时间格式,例如"YYYY-MM-DD HH:MM:SS"
|
||||
* @return 当前日期和时间的字符串表示
|
||||
*/
|
||||
public static String dateTimeNow(final FormatsType format) {
|
||||
public static final String dateTimeNow(final String format)
|
||||
{
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定日期格式化为 YYYY-MM-DD 格式的字符串
|
||||
*
|
||||
* @param date 要格式化的日期对象
|
||||
* @return 格式化后的日期字符串
|
||||
*/
|
||||
public static String formatDate(final Date date) {
|
||||
return parseDateToStr(FormatsType.YYYY_MM_DD, date);
|
||||
public static final String dateTime(final Date date)
|
||||
{
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定日期格式化为 YYYY-MM-DD HH:MM:SS 格式的字符串
|
||||
*
|
||||
* @param date 要格式化的日期对象
|
||||
* @return 格式化后的日期时间字符串
|
||||
*/
|
||||
public static String formatDateTime(final Date date) {
|
||||
return parseDateToStr(FormatsType.YYYY_MM_DD_HH_MM_SS, date);
|
||||
public static final String parseDateToStr(final String format, final Date date)
|
||||
{
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定日期按照指定格式进行格式化
|
||||
*
|
||||
* @param format 要使用的日期时间格式,例如"YYYY-MM-DD HH:MM:SS"
|
||||
* @param date 要格式化的日期对象
|
||||
* @return 格式化后的日期时间字符串
|
||||
*/
|
||||
public static String parseDateToStr(final FormatsType format, final Date date) {
|
||||
return new SimpleDateFormat(format.getTimeFormat()).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定格式的日期时间字符串转换为 Date 对象
|
||||
*
|
||||
* @param format 要解析的日期时间格式,例如"YYYY-MM-DD HH:MM:SS"
|
||||
* @param ts 要解析的日期时间字符串
|
||||
* @return 解析后的 Date 对象
|
||||
* @throws RuntimeException 如果解析过程中发生异常
|
||||
*/
|
||||
public static Date parseDateTime(final FormatsType format, final String ts) {
|
||||
try {
|
||||
return new SimpleDateFormat(format.getTimeFormat()).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
public static final Date dateTime(final String format, final String ts)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转换为日期对象
|
||||
*
|
||||
* @param str 要转换的对象,通常是字符串
|
||||
* @return 转换后的日期对象,如果转换失败或输入为null,则返回null
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static Date parseDate(Object str) {
|
||||
if (str == null) {
|
||||
public static final String datePath()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime()
|
||||
{
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDate(Object str)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), PARSE_PATTERNS);
|
||||
} catch (ParseException e) {
|
||||
try
|
||||
{
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*
|
||||
* @return 服务器启动时间的 Date 对象表示
|
||||
*/
|
||||
public static Date getServerStartDate() {
|
||||
public static Date getServerStartDate()
|
||||
{
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个日期之间的天数差(以毫秒为单位)
|
||||
*
|
||||
* @param date1 第一个日期
|
||||
* @param date2 第二个日期
|
||||
* @return 两个日期之间的天数差的绝对值
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static int differentDaysByMillisecond(Date date1, Date date2) {
|
||||
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||
public static String getDatePoor(Date endDate, Date nowDate)
|
||||
{
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个日期之间的时间差,并以天、小时和分钟的格式返回
|
||||
*
|
||||
* @param endDate 结束日期
|
||||
* @param nowDate 当前日期
|
||||
* @return 表示时间差的字符串,格式为"天 小时 分钟"
|
||||
* 获取2个时间间隔天数
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public static String getDatePoor(Date endDate, Date nowDate) {
|
||||
long diffInMillis = endDate.getTime() - nowDate.getTime();
|
||||
long day = TimeUnit.MILLISECONDS.toDays(diffInMillis);
|
||||
long hour = TimeUnit.MILLISECONDS.toHours(diffInMillis) % 24;
|
||||
long min = TimeUnit.MILLISECONDS.toMinutes(diffInMillis) % 60;
|
||||
return String.format("%d天 %d小时 %d分钟", day, hour, min);
|
||||
public static Long betweenDay(LocalDateTime beginTime, LocalDateTime endTime){
|
||||
return ChronoUnit.DAYS.between(beginTime.toLocalDate().atStartOfDay(),endTime.toLocalDate().atStartOfDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间点的差值(天、小时、分钟、秒),当值为0时不显示该单位
|
||||
*
|
||||
* @param endDate 结束时间
|
||||
* @param nowDate 当前时间
|
||||
* @return 时间差字符串,格式为 "x天 x小时 x分钟 x秒",若为 0 则不显示
|
||||
*/
|
||||
public static String getTimeDifference(Date endDate, Date nowDate) {
|
||||
long diffInMillis = endDate.getTime() - nowDate.getTime();
|
||||
long day = TimeUnit.MILLISECONDS.toDays(diffInMillis);
|
||||
long hour = TimeUnit.MILLISECONDS.toHours(diffInMillis) % 24;
|
||||
long min = TimeUnit.MILLISECONDS.toMinutes(diffInMillis) % 60;
|
||||
long sec = TimeUnit.MILLISECONDS.toSeconds(diffInMillis) % 60;
|
||||
// 构建时间差字符串,条件是值不为0才显示
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (day > 0) {
|
||||
result.append(String.format("%d天 ", day));
|
||||
}
|
||||
if (hour > 0) {
|
||||
result.append(String.format("%d小时 ", hour));
|
||||
}
|
||||
if (min > 0) {
|
||||
result.append(String.format("%d分钟 ", min));
|
||||
}
|
||||
if (sec > 0) {
|
||||
result.append(String.format("%d秒", sec));
|
||||
}
|
||||
return result.length() > 0 ? result.toString().trim() : "0秒";
|
||||
public static List<LocalDateTime> getTimeDiff(int days){
|
||||
// 获取当前日期
|
||||
LocalDate current = LocalDate.now();
|
||||
|
||||
// 获取第一天
|
||||
LocalDate firstDayOfLastMonth = current.minusMonths(days).withDayOfMonth(1);
|
||||
// 获取上个月最后一天
|
||||
LocalDate lastDayOfLastMonth = firstDayOfLastMonth.plusMonths(1).withDayOfMonth(1).minusDays(1);
|
||||
|
||||
return Arrays.asList(LocalDateTime.of(firstDayOfLastMonth, LocalTime.MIN),LocalDateTime.of(lastDayOfLastMonth, LocalTime.MAX));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 LocalDateTime 对象转换为 Date 对象
|
||||
*
|
||||
* @param temporalAccessor 要转换的 LocalDateTime 对象
|
||||
* @return 转换后的 Date 对象
|
||||
*/
|
||||
public static Date toDate(LocalDateTime temporalAccessor) {
|
||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 LocalDate 对象转换为 Date 对象
|
||||
*
|
||||
* @param temporalAccessor 要转换的 LocalDate 对象
|
||||
* @return 转换后的 Date 对象
|
||||
*/
|
||||
public static Date toDate(LocalDate temporalAccessor) {
|
||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验日期范围
|
||||
*
|
||||
* @param startDate 开始日期
|
||||
* @param endDate 结束日期
|
||||
* @param maxValue 最大时间跨度的限制值
|
||||
* @param unit 时间跨度的单位,可选择 "DAYS"、"HOURS" 或 "MINUTES"
|
||||
*/
|
||||
public static void validateDateRange(Date startDate, Date endDate, int maxValue, TimeUnit unit) {
|
||||
// 校验结束日期不能早于开始日期
|
||||
if (endDate.before(startDate)) {
|
||||
throw new ServiceException("结束日期不能早于开始日期");
|
||||
}
|
||||
|
||||
// 计算时间跨度
|
||||
long diffInMillis = endDate.getTime() - startDate.getTime();
|
||||
|
||||
// 根据单位转换时间跨度
|
||||
long diff = switch (unit) {
|
||||
case DAYS -> TimeUnit.MILLISECONDS.toDays(diffInMillis);
|
||||
case HOURS -> TimeUnit.MILLISECONDS.toHours(diffInMillis);
|
||||
case MINUTES -> TimeUnit.MILLISECONDS.toMinutes(diffInMillis);
|
||||
default -> throw new IllegalArgumentException("不支持的时间单位");
|
||||
};
|
||||
|
||||
// 校验时间跨度不超过最大限制
|
||||
if (diff > maxValue) {
|
||||
throw new ServiceException("最大时间跨度为 " + maxValue + " " + unit.toString().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,184 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DictUtils
|
||||
{
|
||||
/**
|
||||
* 分隔符
|
||||
*/
|
||||
public static final String SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 设置字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param dictDatas 字典数据列表
|
||||
*/
|
||||
public static void setDictCache(String key, List<SysDictData> dictDatas)
|
||||
{
|
||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static List<SysDictData> getDictCache(String key)
|
||||
{
|
||||
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(cacheObj))
|
||||
{
|
||||
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典值获取字典标签
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String getDictLabel(String dictType, String dictValue)
|
||||
{
|
||||
return getDictLabel(dictType, dictValue, SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典标签获取字典值
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String getDictValue(String dictType, String dictLabel)
|
||||
{
|
||||
return getDictValue(dictType, dictLabel, SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典值获取字典标签
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @param separator 分隔符
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String getDictLabel(String dictType, String dictValue, String separator)
|
||||
{
|
||||
StringBuilder propertyString = new StringBuilder();
|
||||
List<SysDictData> datas = getDictCache(dictType);
|
||||
|
||||
if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas))
|
||||
{
|
||||
for (SysDictData dict : datas)
|
||||
{
|
||||
for (String value : dictValue.split(separator))
|
||||
{
|
||||
if (value.equals(dict.getDictValue()))
|
||||
{
|
||||
propertyString.append(dict.getDictLabel() + separator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SysDictData dict : datas)
|
||||
{
|
||||
if (dictValue.equals(dict.getDictValue()))
|
||||
{
|
||||
return dict.getDictLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典标签获取字典值
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @param separator 分隔符
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String getDictValue(String dictType, String dictLabel, String separator)
|
||||
{
|
||||
StringBuilder propertyString = new StringBuilder();
|
||||
List<SysDictData> datas = getDictCache(dictType);
|
||||
|
||||
if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
|
||||
{
|
||||
for (SysDictData dict : datas)
|
||||
{
|
||||
for (String label : dictLabel.split(separator))
|
||||
{
|
||||
if (label.equals(dict.getDictLabel()))
|
||||
{
|
||||
propertyString.append(dict.getDictValue() + separator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SysDictData dict : datas)
|
||||
{
|
||||
if (dictLabel.equals(dict.getDictLabel()))
|
||||
{
|
||||
return dict.getDictValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定字典缓存
|
||||
*
|
||||
* @param key 字典键
|
||||
*/
|
||||
public static void removeDictCache(String key)
|
||||
{
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
public static void clearDictCache()
|
||||
{
|
||||
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey(String configKey)
|
||||
{
|
||||
return Constants.SYS_DICT_KEY + configKey;
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Created by yangyincong on 15/8/16.
|
||||
* ID生成器 workId (1~4)
|
||||
*/
|
||||
public class IDGenerator {
|
||||
private final static Logger logger = LoggerFactory.getLogger(IDGenerator.class);
|
||||
private final static long twepoch = 1361753741828L;
|
||||
private final static long workerIdBits = 4L;
|
||||
private final static long maxWorkerId = -1L ^ -1L << workerIdBits;
|
||||
private final static long sequenceBits = 10L;
|
||||
private long workerId;
|
||||
private long sequence = 0L;
|
||||
|
||||
private final static long workerIdShift = sequenceBits;
|
||||
private final static long timestampLeftShift = sequenceBits + workerIdBits;
|
||||
private final static long sequenceMask = -1L ^ -1L << sequenceBits;
|
||||
|
||||
private long lastTimestamp = -1L;
|
||||
|
||||
private IDGenerator(final long workerId) {
|
||||
super();
|
||||
this.workerId = workerId;
|
||||
}
|
||||
|
||||
public static long generateMinId(int wid, long time) {
|
||||
return (time - twepoch << timestampLeftShift) | (wid << workerIdShift);
|
||||
}
|
||||
|
||||
public synchronized long nextId() {
|
||||
long timestamp = this.timeGen();
|
||||
if (this.lastTimestamp == timestamp) {
|
||||
this.sequence = (this.sequence + 1) & sequenceMask;
|
||||
if (this.sequence == 0) {
|
||||
timestamp = this.tilNextMillis(this.lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
this.sequence = 0;
|
||||
}
|
||||
if (timestamp < this.lastTimestamp) {
|
||||
try {
|
||||
throw new Exception(
|
||||
String.format(
|
||||
"Clock moved backwards. Refusing to generate id for %d milliseconds",
|
||||
this.lastTimestamp - timestamp));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
this.lastTimestamp = timestamp;
|
||||
long nextId = ((timestamp - twepoch << timestampLeftShift))
|
||||
| (this.workerId << workerIdShift) | (this.sequence);
|
||||
return nextId;
|
||||
}
|
||||
|
||||
public static long generateMaxId(long wid, long time) {
|
||||
return (time - twepoch << timestampLeftShift) | (wid << workerIdShift) | sequenceMask;
|
||||
}
|
||||
|
||||
private long tilNextMillis(final long lastTimestamp) {
|
||||
long timestamp = this.timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = this.timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
private long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private static IDGenerator generator;
|
||||
|
||||
public static synchronized void init(Long workerId) throws Exception {
|
||||
workerId = workerId % maxWorkerId;
|
||||
logger.info("程序中init的workid为:{}", workerId);
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"worker Id can't be greater than %d or less than 0",
|
||||
IDGenerator.maxWorkerId));
|
||||
}
|
||||
generator = new IDGenerator(workerId);
|
||||
}
|
||||
|
||||
public static Long generateId() {
|
||||
if (null == generator) {
|
||||
synchronized (IDGenerator.class) {
|
||||
if (null == generator) {
|
||||
try {
|
||||
init(2L);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return generator.nextId();
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.dromara.common.core.config.RuoYiConfig;
|
||||
import org.dromara.common.core.domain.event.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 图片处理工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class ImageUtils
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
|
||||
|
||||
public static byte[] getImage(String imagePath)
|
||||
{
|
||||
InputStream is = getFile(imagePath);
|
||||
try
|
||||
{
|
||||
return IOUtils.toByteArray(is);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("图片加载异常 {}", e);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
public static InputStream getFile(String imagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] result = readFile(imagePath);
|
||||
result = Arrays.copyOf(result, result.length);
|
||||
return new ByteArrayInputStream(result);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("获取图片异常 {}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件为字节数据
|
||||
*
|
||||
* @param key 地址
|
||||
* @return 字节数据
|
||||
*/
|
||||
public static byte[] readFile(String url)
|
||||
{
|
||||
InputStream in = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
try
|
||||
{
|
||||
if (url.startsWith("http"))
|
||||
{
|
||||
// 网络地址
|
||||
URL urlObj = new URL(url);
|
||||
URLConnection urlConnection = urlObj.openConnection();
|
||||
urlConnection.setConnectTimeout(30 * 1000);
|
||||
urlConnection.setReadTimeout(60 * 1000);
|
||||
urlConnection.setDoInput(true);
|
||||
in = urlConnection.getInputStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 本机地址
|
||||
String localPath = RuoYiConfig.getProfile();
|
||||
String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX);
|
||||
in = new FileInputStream(downloadPath);
|
||||
}
|
||||
return IOUtils.toByteArray(in);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("获取文件路径异常 {}", e);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(in);
|
||||
IOUtils.closeQuietly(baos);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
/**
|
||||
* 手机号工具类
|
||||
*/
|
||||
public class PhoneUtils {
|
||||
|
||||
public static String hidePhone(String phone){
|
||||
if (StringUtils.isEmpty(phone) || phone.length() < 11){
|
||||
throw new RuntimeException("手机号格式错误");
|
||||
}
|
||||
return phone.substring(0, 3) + "****" + phone.substring(7, 11);
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* 安全服务工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SecurityUtils
|
||||
{
|
||||
private static BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
/**
|
||||
* 用户ID
|
||||
**/
|
||||
public static Long getUserId()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
public static String getUsername()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
public static LoginUser getLoginUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (LoginUser) getAuthentication().getPrincipal();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Authentication
|
||||
*/
|
||||
public static Authentication getAuthentication()
|
||||
{
|
||||
return SecurityContextHolder.getContext().getAuthentication();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成BCryptPasswordEncoder密码
|
||||
*
|
||||
* @param password 密码
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encryptPassword(String password) {
|
||||
return passwordEncoder.encode(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断密码是否相同
|
||||
*
|
||||
* @param rawPassword 真实密码
|
||||
* @param encodedPassword 加密后字符
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean matchesPassword(String rawPassword, String encodedPassword)
|
||||
{
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为管理员
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isAdmin(Long userId)
|
||||
{
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
}
|
@ -62,6 +62,40 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
return StrUtil.trim(str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否为空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isNull(Object object)
|
||||
{
|
||||
return object == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否非空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotNull(Object object)
|
||||
{
|
||||
return !isNull(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||
*
|
||||
* @param object 对象
|
||||
* @return true:是数组 false:不是数组
|
||||
*/
|
||||
public static boolean isArray(Object object)
|
||||
{
|
||||
return isNotNull(object) && object.getClass().isArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
|
@ -0,0 +1,77 @@
|
||||
package org.dromara.common.core.utils.file;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 文件类型工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class FileTypeUtils
|
||||
{
|
||||
/**
|
||||
* 获取文件类型
|
||||
* <p>
|
||||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param file 文件名
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType(File file)
|
||||
{
|
||||
if (null == file)
|
||||
{
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return getFileType(file.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
* <p>
|
||||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType(String fileName)
|
||||
{
|
||||
int separatorIndex = fileName.lastIndexOf(".");
|
||||
if (separatorIndex < 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return fileName.substring(separatorIndex + 1).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*
|
||||
* @param photoByte 文件字节码
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileExtendName(byte[] photoByte)
|
||||
{
|
||||
String strFileExtendName = "JPG";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||
{
|
||||
strFileExtendName = "GIF";
|
||||
}
|
||||
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
|
||||
{
|
||||
strFileExtendName = "JPG";
|
||||
}
|
||||
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
|
||||
{
|
||||
strFileExtendName = "BMP";
|
||||
}
|
||||
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
|
||||
{
|
||||
strFileExtendName = "PNG";
|
||||
}
|
||||
return strFileExtendName;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package org.dromara.common.core.wechat;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "wechat")
|
||||
@Component("WechatPayData")
|
||||
public class WechatPayData {
|
||||
|
||||
/** 商户号 */
|
||||
public static String appId;
|
||||
public static String secret;
|
||||
public static String merchantId;
|
||||
/** 商户API私钥路径 */
|
||||
public static String privateKeyPath;
|
||||
/** 商户证书序列号 */
|
||||
public static String merchantSerialNumber;
|
||||
/** 商户APIV3密钥 */
|
||||
public static String apiV3key;
|
||||
public static String notifyUrl;
|
||||
|
||||
public static String miniProgramAppId;
|
||||
public static String miniProgramSecret;
|
||||
|
||||
public void setAppId(String appId) {
|
||||
WechatPayData.appId = appId;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
WechatPayData.secret = secret;
|
||||
}
|
||||
|
||||
public void setMerchantId(String merchantId) {
|
||||
WechatPayData.merchantId = merchantId;
|
||||
}
|
||||
|
||||
public void setPrivateKeyPath(String privateKeyPath) {
|
||||
WechatPayData.privateKeyPath = privateKeyPath;
|
||||
}
|
||||
|
||||
public void setMerchantSerialNumber(String merchantSerialNumber) {
|
||||
WechatPayData.merchantSerialNumber = merchantSerialNumber;
|
||||
}
|
||||
|
||||
public void setApiV3key(String apiV3key) {
|
||||
WechatPayData.apiV3key = apiV3key;
|
||||
}
|
||||
|
||||
public void setNotifyUrl(String notifyUrl) {
|
||||
WechatPayData.notifyUrl = notifyUrl;
|
||||
}
|
||||
|
||||
public void setMiniProgramAppId(String miniProgramAppId) {
|
||||
WechatPayData.miniProgramAppId = miniProgramAppId;
|
||||
}
|
||||
|
||||
public void setMiniProgramSecret(String miniProgramSecret) {
|
||||
WechatPayData.miniProgramSecret = miniProgramSecret;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.dromara.common.core.wechat;
|
||||
|
||||
import com.wechat.pay.java.service.payments.jsapi.JsapiService;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse;
|
||||
import com.wechat.pay.java.service.refund.RefundService;
|
||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ConditionalOnProperty(prefix = "wechat", name = "enabled", havingValue = "true")
|
||||
public class WechatPayService {
|
||||
|
||||
@Autowired
|
||||
private JsapiService service;
|
||||
|
||||
@Autowired
|
||||
private RefundService refundService;
|
||||
|
||||
/**
|
||||
* jsapi下单
|
||||
* @param orderNo 订单号
|
||||
* @param desc 订单描述
|
||||
* @param totalAmount 总金额,单位:分
|
||||
* @param openId 用户openid
|
||||
* @return prepay_id
|
||||
*/
|
||||
public String jsapiPay(String orderNo,String desc,Integer totalAmount,String openId, Long memberId,String appId){
|
||||
PrepayRequest prepayRequest = new PrepayRequest();
|
||||
prepayRequest.setAppid(appId);
|
||||
prepayRequest.setMchid(WechatPayData.merchantId);
|
||||
prepayRequest.setDescription(desc);
|
||||
prepayRequest.setOutTradeNo(orderNo);
|
||||
prepayRequest.setAttach(String.valueOf(memberId));
|
||||
prepayRequest.setNotifyUrl(WechatPayData.notifyUrl);
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(totalAmount);
|
||||
prepayRequest.setAmount(amount);
|
||||
Payer payer = new Payer();
|
||||
payer.setOpenid(openId);
|
||||
prepayRequest.setPayer(payer);
|
||||
PrepayResponse response = service.prepay(prepayRequest);
|
||||
return response.getPrepayId();
|
||||
}
|
||||
|
||||
public Refund refundPay(String refundId,String payId,String notifyUrl,Long refundAmount, Long totalAmount,String reason) {
|
||||
//请求参数
|
||||
CreateRequest request = new CreateRequest();
|
||||
request.setReason(reason);
|
||||
//设置退款金额 根据自己的实际业务自行填写
|
||||
AmountReq amountReq = new AmountReq();
|
||||
amountReq.setRefund(refundAmount);
|
||||
amountReq.setTotal(totalAmount);
|
||||
amountReq.setCurrency("CNY");
|
||||
request.setAmount(amountReq);
|
||||
//支付成功后回调回来的transactionId 按照实际情况填写
|
||||
request.setOutTradeNo(payId);
|
||||
//支付成功后回调回来的transactionId 按照实际情况填写
|
||||
request.setOutRefundNo(refundId);
|
||||
//退款成功的回调地址
|
||||
request.setNotifyUrl(notifyUrl);
|
||||
//发起请求,申请退款
|
||||
return refundService.create(request);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.common.excel.annotation;
|
||||
|
||||
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
|
||||
|
||||
import org.dromara.common.excel.utils.ExcelHandlerAdapter;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -0,0 +1,19 @@
|
||||
package org.dromara.common.excel.utils;
|
||||
|
||||
/**
|
||||
* Excel数据格式处理适配器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ExcelHandlerAdapter
|
||||
{
|
||||
/**
|
||||
* 格式化
|
||||
*
|
||||
* @param value 单元格数据值
|
||||
* @param args excel注解args参数组
|
||||
*
|
||||
* @return 处理后的值
|
||||
*/
|
||||
Object format(Object value, String[] args);
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package org.dromara.common.excel.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
@ -14,27 +16,122 @@ import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||
import org.dromara.common.core.config.RuoYiConfig;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.DictUtils;
|
||||
import org.dromara.common.core.utils.ImageUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileTypeUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
import org.dromara.common.excel.annotation.Excels;
|
||||
import org.dromara.common.excel.convert.ExcelBigNumberConvert;
|
||||
import org.dromara.common.excel.core.*;
|
||||
import org.dromara.common.excel.handler.DataWriteHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ExcelUtil {
|
||||
@Slf4j
|
||||
//@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ExcelUtil<T> {
|
||||
|
||||
/**
|
||||
* Excel sheet最大行数,默认65536
|
||||
*/
|
||||
public static final int sheetSize = 65536;
|
||||
|
||||
/**
|
||||
* 统计列表
|
||||
*/
|
||||
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
||||
|
||||
/**
|
||||
* 数字格式
|
||||
*/
|
||||
private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00");
|
||||
/**
|
||||
* 导入导出数据列表
|
||||
*/
|
||||
private List<T> list;
|
||||
|
||||
/**
|
||||
* 工作表名称
|
||||
*/
|
||||
private String sheetName;
|
||||
|
||||
/**
|
||||
* 导出类型(EXPORT:导出数据;IMPORT:导入模板)
|
||||
*/
|
||||
private Excel.Type type;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 注解列表
|
||||
*/
|
||||
private List<Object[]> fields;
|
||||
|
||||
|
||||
/**
|
||||
* 工作薄对象
|
||||
*/
|
||||
private Workbook wb;
|
||||
|
||||
/**
|
||||
* 工作表对象
|
||||
*/
|
||||
private Sheet sheet;
|
||||
|
||||
/**
|
||||
* 样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> styles;
|
||||
|
||||
/**
|
||||
* 当前行号
|
||||
*/
|
||||
private int rownum;
|
||||
|
||||
/**
|
||||
* 最大高度
|
||||
*/
|
||||
private short maxHeight;
|
||||
|
||||
|
||||
/**
|
||||
* 实体对象
|
||||
*/
|
||||
public Class<T> clazz;
|
||||
|
||||
|
||||
public ExcelUtil(Class<T> clazz)
|
||||
{
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步导入(适用于小数据量)
|
||||
@ -430,6 +527,16 @@ public class ExcelUtil {
|
||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到所有定义字段
|
||||
*/
|
||||
private void createExcelField()
|
||||
{
|
||||
this.fields = getFields();
|
||||
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
|
||||
this.maxHeight = getRowHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码文件名
|
||||
*/
|
||||
@ -437,4 +544,651 @@ public class ExcelUtil {
|
||||
return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx";
|
||||
}
|
||||
|
||||
public String writeExcel(List<T> list, String sheetName)
|
||||
{
|
||||
this.init(list, sheetName, title, Excel.Type.EXPORT);
|
||||
return exportExcel();
|
||||
}
|
||||
|
||||
public void init(List<T> list, String sheetName, String title, Excel.Type type)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = new ArrayList<T>();
|
||||
}
|
||||
this.list = list;
|
||||
this.sheetName = sheetName;
|
||||
this.type = type;
|
||||
this.title = title;
|
||||
createExcelField();
|
||||
createWorkbook();
|
||||
createTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段注解信息
|
||||
*/
|
||||
public List<Object[]> getFields()
|
||||
{
|
||||
List<Object[]> fields = new ArrayList<Object[]>();
|
||||
List<Field> tempFields = new ArrayList<>();
|
||||
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||
for (Field field : tempFields)
|
||||
{
|
||||
// 单注解
|
||||
if (field.isAnnotationPresent(Excel.class))
|
||||
{
|
||||
Excel attr = field.getAnnotation(Excel.class);
|
||||
if (attr != null && (attr.type() == Excel.Type.ALL || attr.type() == type))
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
}
|
||||
|
||||
// 多注解
|
||||
if (field.isAnnotationPresent(Excels.class))
|
||||
{
|
||||
Excels attrs = field.getAnnotation(Excels.class);
|
||||
Excel[] excels = attrs.value();
|
||||
for (Excel attr : excels)
|
||||
{
|
||||
if (attr != null && (attr.type() == Excel.Type.ALL || attr.type() == type))
|
||||
{
|
||||
field.setAccessible(true);
|
||||
fields.add(new Object[] { field, attr });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个工作簿
|
||||
*/
|
||||
public void createWorkbook()
|
||||
{
|
||||
this.wb = new SXSSFWorkbook(500);
|
||||
this.sheet = wb.createSheet();
|
||||
wb.setSheetName(0, sheetName);
|
||||
this.styles = createStyles(wb);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表格样式
|
||||
*
|
||||
* @param wb 工作薄对象
|
||||
* @return 样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> createStyles(Workbook wb)
|
||||
{
|
||||
// 写入各条记录,每条记录对应excel表中的一行
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
Font titleFont = wb.createFont();
|
||||
titleFont.setFontName("Arial");
|
||||
titleFont.setFontHeightInPoints((short) 16);
|
||||
titleFont.setBold(true);
|
||||
style.setFont(titleFont);
|
||||
styles.put("title", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
Font dataFont = wb.createFont();
|
||||
dataFont.setFontName("Arial");
|
||||
dataFont.setFontHeightInPoints((short) 10);
|
||||
style.setFont(dataFont);
|
||||
styles.put("data", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
Font headerFont = wb.createFont();
|
||||
headerFont.setFontName("Arial");
|
||||
headerFont.setFontHeightInPoints((short) 10);
|
||||
headerFont.setBold(true);
|
||||
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
||||
style.setFont(headerFont);
|
||||
styles.put("header", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
Font totalFont = wb.createFont();
|
||||
totalFont.setFontName("Arial");
|
||||
totalFont.setFontHeightInPoints((short) 10);
|
||||
style.setFont(totalFont);
|
||||
styles.put("total", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(HorizontalAlignment.LEFT);
|
||||
styles.put("data1", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
styles.put("data2", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(HorizontalAlignment.RIGHT);
|
||||
styles.put("data3", style);
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建excel第一行标题
|
||||
*/
|
||||
public void createTitle()
|
||||
{
|
||||
if (StringUtils.isNotEmpty(title))
|
||||
{
|
||||
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
||||
titleRow.setHeightInPoints(30);
|
||||
Cell titleCell = titleRow.createCell(0);
|
||||
titleCell.setCellStyle(styles.get("title"));
|
||||
titleCell.setCellValue(title);
|
||||
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(),
|
||||
this.fields.size() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据注解获取最大行高
|
||||
*/
|
||||
public short getRowHeight()
|
||||
{
|
||||
double maxHeight = 0;
|
||||
for (Object[] os : this.fields)
|
||||
{
|
||||
Excel excel = (Excel) os[1];
|
||||
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
||||
}
|
||||
return (short) (maxHeight * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对list数据源将其里面的数据导入到excel表单
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public String exportExcel()
|
||||
{
|
||||
OutputStream out = null;
|
||||
try
|
||||
{
|
||||
writeSheet();
|
||||
String filename = encodingFilename(sheetName);
|
||||
out = new FileOutputStream(getAbsoluteFile(filename));
|
||||
wb.write(out);
|
||||
return filename;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("导出Excel异常{}", e.getMessage());
|
||||
throw new UtilException("导出Excel失败,请联系网站管理员!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(wb);
|
||||
IOUtils.closeQuietly(out);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 创建写入数据到Sheet
|
||||
*/
|
||||
public void writeSheet()
|
||||
{
|
||||
// 取出一共有多少个sheet.
|
||||
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
|
||||
for (int index = 0; index < sheetNo; index++)
|
||||
{
|
||||
createSheet(sheetNo, index);
|
||||
|
||||
// 产生一行
|
||||
Row row = sheet.createRow(rownum);
|
||||
int column = 0;
|
||||
// 写入各个字段的列头名称
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Excel excel = (Excel) os[1];
|
||||
this.createCell(excel, row, column++);
|
||||
}
|
||||
if (Excel.Type.EXPORT.equals(type))
|
||||
{
|
||||
fillExcelData(index, row);
|
||||
addStatisticsRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建统计行
|
||||
*/
|
||||
public void addStatisticsRow()
|
||||
{
|
||||
if (statistics.size() > 0)
|
||||
{
|
||||
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||
Set<Integer> keys = statistics.keySet();
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellStyle(styles.get("total"));
|
||||
cell.setCellValue("合计");
|
||||
|
||||
for (Integer key : keys)
|
||||
{
|
||||
cell = row.createCell(key);
|
||||
cell.setCellStyle(styles.get("total"));
|
||||
cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
|
||||
}
|
||||
statistics.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 填充excel数据
|
||||
*
|
||||
* @param index 序号
|
||||
* @param row 单元格行
|
||||
*/
|
||||
public void fillExcelData(int index, Row row)
|
||||
{
|
||||
int startNo = index * sheetSize;
|
||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
||||
for (int i = startNo; i < endNo; i++)
|
||||
{
|
||||
row = sheet.createRow(i + 1 + rownum - startNo);
|
||||
// 得到导出对象.
|
||||
T vo = (T) list.get(i);
|
||||
int column = 0;
|
||||
for (Object[] os : fields)
|
||||
{
|
||||
Field field = (Field) os[0];
|
||||
Excel excel = (Excel) os[1];
|
||||
this.addCell(excel, row, vo, field, column++);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 添加单元格
|
||||
*/
|
||||
public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
|
||||
{
|
||||
Cell cell = null;
|
||||
try
|
||||
{
|
||||
// 设置行高
|
||||
row.setHeight(maxHeight);
|
||||
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
|
||||
if (attr.isExport())
|
||||
{
|
||||
// 创建cell
|
||||
cell = row.createCell(column);
|
||||
int align = attr.align().value();
|
||||
cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
||||
|
||||
// 用于读取对象中的属性
|
||||
Object value = getTargetValue(vo, field, attr);
|
||||
String dateFormat = attr.dateFormat();
|
||||
String readConverterExp = attr.readConverterExp();
|
||||
String separator = attr.separator();
|
||||
String dictType = attr.dictType();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
|
||||
}
|
||||
else if (value instanceof BigDecimal && -1 != attr.scale())
|
||||
{
|
||||
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
|
||||
}
|
||||
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
||||
{
|
||||
cell.setCellValue(dataFormatHandlerAdapter(value, attr));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 设置列类型
|
||||
setCellVo(value, attr, cell);
|
||||
}
|
||||
addStatisticsData(column, Convert.toStr(value), attr);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("导出Excel失败{}", e);
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合计统计信息
|
||||
*/
|
||||
private void addStatisticsData(Integer index, String text, Excel entity)
|
||||
{
|
||||
if (entity != null && entity.isStatistics())
|
||||
{
|
||||
Double temp = 0D;
|
||||
if (!statistics.containsKey(index))
|
||||
{
|
||||
statistics.put(index, temp);
|
||||
}
|
||||
try
|
||||
{
|
||||
temp = Double.valueOf(text);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
}
|
||||
statistics.put(index, statistics.get(index) + temp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单元格信息
|
||||
*
|
||||
* @param value 单元格值
|
||||
* @param attr 注解相关
|
||||
* @param cell 单元格信息
|
||||
*/
|
||||
public void setCellVo(Object value, Excel attr, Cell cell)
|
||||
{
|
||||
if (Excel.ColumnType.STRING == attr.cellType())
|
||||
{
|
||||
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
||||
}
|
||||
else if (Excel.ColumnType.NUMERIC == attr.cellType())
|
||||
{
|
||||
if (StringUtils.isNotNull(value))
|
||||
{
|
||||
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
|
||||
}
|
||||
}
|
||||
else if (Excel.ColumnType.IMAGE == attr.cellType())
|
||||
{
|
||||
ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1);
|
||||
String imagePath = Convert.toStr(value);
|
||||
if (StringUtils.isNotEmpty(imagePath))
|
||||
{
|
||||
byte[] data = ImageUtils.getImage(imagePath);
|
||||
getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
|
||||
cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片类型,设置图片插入类型
|
||||
*/
|
||||
public int getImageType(byte[] value)
|
||||
{
|
||||
String type = FileTypeUtils.getFileExtendName(value);
|
||||
if ("JPG".equalsIgnoreCase(type))
|
||||
{
|
||||
return Workbook.PICTURE_TYPE_JPEG;
|
||||
}
|
||||
else if ("PNG".equalsIgnoreCase(type))
|
||||
{
|
||||
return Workbook.PICTURE_TYPE_PNG;
|
||||
}
|
||||
return Workbook.PICTURE_TYPE_JPEG;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取画布
|
||||
*/
|
||||
public static Drawing<?> getDrawingPatriarch(Sheet sheet)
|
||||
{
|
||||
if (sheet.getDrawingPatriarch() == null)
|
||||
{
|
||||
sheet.createDrawingPatriarch();
|
||||
}
|
||||
return sheet.getDrawingPatriarch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据处理器
|
||||
*
|
||||
* @param value 数据值
|
||||
* @param excel 数据注解
|
||||
* @return
|
||||
*/
|
||||
public String dataFormatHandlerAdapter(Object value, Excel excel)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object instance = excel.handler().newInstance();
|
||||
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class });
|
||||
value = formatMethod.invoke(instance, value, excel.args());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("不能格式化数据 " + excel.handler(), e.getMessage());
|
||||
}
|
||||
return Convert.toStr(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析字典值
|
||||
*
|
||||
* @param dictValue 字典值
|
||||
* @param dictType 字典类型
|
||||
* @param separator 分隔符
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String convertDictByExp(String dictValue, String dictType, String separator)
|
||||
{
|
||||
return DictUtils.getDictLabel(dictType, dictValue, separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取bean中的属性值
|
||||
*
|
||||
* @param vo 实体对象
|
||||
* @param field 字段
|
||||
* @param excel 注解
|
||||
* @return 最终的属性值
|
||||
* @throws Exception
|
||||
*/
|
||||
private Object getTargetValue(T vo, Field field, Excel excel) throws Exception
|
||||
{
|
||||
Object o = field.get(vo);
|
||||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||
{
|
||||
String target = excel.targetAttr();
|
||||
if (target.indexOf(".") > -1)
|
||||
{
|
||||
String[] targets = target.split("[.]");
|
||||
for (String name : targets)
|
||||
{
|
||||
o = getValue(o, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
o = getValue(o, target);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以类的属性的get方法方法形式获取值
|
||||
*
|
||||
* @param o
|
||||
* @param name
|
||||
* @return value
|
||||
* @throws Exception
|
||||
*/
|
||||
private Object getValue(Object o, String name) throws Exception
|
||||
{
|
||||
if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name))
|
||||
{
|
||||
Class<?> clazz = o.getClass();
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
o = field.get(o);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建工作表
|
||||
*
|
||||
* @param sheetNo sheet数量
|
||||
* @param index 序号
|
||||
*/
|
||||
public void createSheet(int sheetNo, int index)
|
||||
{
|
||||
// 设置工作表的名称.
|
||||
if (sheetNo > 1 && index > 0)
|
||||
{
|
||||
this.sheet = wb.createSheet();
|
||||
this.createTitle();
|
||||
wb.setSheetName(index, sheetName + index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*
|
||||
* @param filename 文件名称
|
||||
*/
|
||||
public String getAbsoluteFile(String filename)
|
||||
{
|
||||
String downloadPath = RuoYiConfig.getDownloadPath() + filename;
|
||||
File desc = new File(downloadPath);
|
||||
if (!desc.getParentFile().exists())
|
||||
{
|
||||
desc.getParentFile().mkdirs();
|
||||
}
|
||||
return downloadPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建单元格
|
||||
*/
|
||||
public Cell createCell(Excel attr, Row row, int column)
|
||||
{
|
||||
// 创建列
|
||||
Cell cell = row.createCell(column);
|
||||
// 写入列信息
|
||||
cell.setCellValue(attr.name());
|
||||
setDataValidation(attr, row, column);
|
||||
cell.setCellStyle(styles.get("header"));
|
||||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表格样式
|
||||
*/
|
||||
public void setDataValidation(Excel attr, Row row, int column)
|
||||
{
|
||||
if (attr.name().indexOf("注:") >= 0)
|
||||
{
|
||||
sheet.setColumnWidth(column, 6000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 设置列宽
|
||||
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
||||
}
|
||||
// 如果设置了提示信息则鼠标放上去提示.
|
||||
if (StringUtils.isNotEmpty(attr.prompt()))
|
||||
{
|
||||
// 这里默认设了2-101列提示.
|
||||
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
|
||||
}
|
||||
// 如果设置了combo属性则本列只能选择不能输入
|
||||
if (attr.combo().length > 0)
|
||||
{
|
||||
// 这里默认设了2-101列只能选择不能输入.
|
||||
setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 POI XSSFSheet 单元格提示
|
||||
*
|
||||
* @param sheet 表单
|
||||
* @param promptTitle 提示标题
|
||||
* @param promptContent 提示内容
|
||||
* @param firstRow 开始行
|
||||
* @param endRow 结束行
|
||||
* @param firstCol 开始列
|
||||
* @param endCol 结束列
|
||||
*/
|
||||
public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
|
||||
int firstCol, int endCol)
|
||||
{
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
|
||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
||||
dataValidation.createPromptBox(promptTitle, promptContent);
|
||||
dataValidation.setShowPromptBox(true);
|
||||
sheet.addValidationData(dataValidation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置某些列的值只能输入预制的数据,显示下拉框.
|
||||
*
|
||||
* @param sheet 要设置的sheet.
|
||||
* @param textlist 下拉框显示的内容
|
||||
* @param firstRow 开始行
|
||||
* @param endRow 结束行
|
||||
* @param firstCol 开始列
|
||||
* @param endCol 结束列
|
||||
* @return 设置好的sheet.
|
||||
*/
|
||||
public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol)
|
||||
{
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
// 加载下拉列表内容
|
||||
DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
|
||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||
// 数据有效性对象
|
||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
||||
// 处理Excel兼容性问题
|
||||
if (dataValidation instanceof XSSFDataValidation)
|
||||
{
|
||||
dataValidation.setSuppressDropDownArrow(true);
|
||||
dataValidation.setShowErrorBox(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataValidation.setSuppressDropDownArrow(false);
|
||||
}
|
||||
|
||||
sheet.addValidationData(dataValidation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package org.dromara.common.oss.core;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.oss.constant.OssConstant;
|
||||
|
@ -0,0 +1,231 @@
|
||||
package org.dromara.common.redis.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
**/
|
||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||
@Component
|
||||
public class RedisCache
|
||||
{
|
||||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value)
|
||||
{
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
* @param timeUnit 时间颗粒度
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
|
||||
{
|
||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout)
|
||||
{
|
||||
return expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout, final TimeUnit unit)
|
||||
{
|
||||
return redisTemplate.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject(final String key)
|
||||
{
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject(final String key)
|
||||
{
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
* @return
|
||||
*/
|
||||
public long deleteObject(final Collection collection)
|
||||
{
|
||||
return redisTemplate.delete(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存List数据
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
* @return 缓存的对象
|
||||
*/
|
||||
public <T> long setCacheList(final String key, final List<T> dataList)
|
||||
{
|
||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList(final String key)
|
||||
{
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
||||
{
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
Iterator<T> it = dataSet.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Set<T> getCacheSet(final String key)
|
||||
{
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
* @param key
|
||||
* @param dataMap
|
||||
*/
|
||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
|
||||
{
|
||||
if (dataMap != null) {
|
||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap(final String key)
|
||||
{
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 往Hash中存入数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @param value 值
|
||||
*/
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
|
||||
{
|
||||
redisTemplate.opsForHash().put(key, hKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return Hash中的对象
|
||||
*/
|
||||
public <T> T getCacheMapValue(final String key, final String hKey)
|
||||
{
|
||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||
return opsForHash.get(key, hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键集合
|
||||
* @return Hash对象集合
|
||||
*/
|
||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
|
||||
{
|
||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys(final String pattern)
|
||||
{
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package org.dromara.common.redis.redis;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RedisService {
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
public void setMatchList(Long userId, List<Long> userIds) {
|
||||
String key = RedisKeys.MATCH_LIST_OF + userId;
|
||||
redisCache.setCacheList(key, userIds);
|
||||
redisCache.expire(key, 7, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
public List<Long> getMatchList(Long userId) {
|
||||
String key = RedisKeys.MATCH_LIST_OF + userId;
|
||||
return redisCache.getCacheList(key);
|
||||
}
|
||||
|
||||
public String getAddressList() {
|
||||
String key = RedisKeys.ADDRESS_LIST_KEY;
|
||||
return redisCache.getCacheObject(key);
|
||||
}
|
||||
|
||||
public void setAddressList(String list) {
|
||||
String key = RedisKeys.ADDRESS_LIST_KEY;
|
||||
redisCache.setCacheObject(key,list);
|
||||
}
|
||||
|
||||
public void setVerifyCode(String code) {
|
||||
String key = RedisKeys.VERIFY_CODE + code;
|
||||
redisCache.setCacheObject(key, code);
|
||||
redisCache.expire(key, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public void deleteVerifyCode(String code) {
|
||||
redisCache.deleteObject(RedisKeys.VERIFY_CODE + code);
|
||||
}
|
||||
|
||||
public String getVerifyCode(String code) {
|
||||
return redisCache.getCacheObject(RedisKeys.VERIFY_CODE + code);
|
||||
}
|
||||
|
||||
public String getWechatToken() {
|
||||
return redisCache.getCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
public void setWechatToken(String token) {
|
||||
redisCache.setCacheObject(RedisKeys.WECHAT_ACCESS_TOKEN, token, 100, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public void setQrCode(String code, String scene) {
|
||||
redisCache.setCacheObject(RedisKeys.WECHAT_QR_CODE + scene, code, 30, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
public String getQrCode(String scene) {
|
||||
return redisCache.getCacheObject(RedisKeys.WECHAT_QR_CODE + scene);
|
||||
}
|
||||
|
||||
interface RedisKeys {
|
||||
String MATCH_LIST_OF = "MATCH_LIST_OF_";
|
||||
String ADDRESS_LIST_KEY = "ADDRESS_LIST_KEY_";
|
||||
|
||||
String WECHAT_ACCESS_TOKEN = "WECHAT_ACCESS_TOKEN_";
|
||||
String WECHAT_QR_CODE = "WECHAT_QR_CODE_";
|
||||
String VERIFY_CODE = "VERIFY_CODE:";
|
||||
}
|
||||
|
||||
/**
|
||||
* redis实现分布式锁 --- 上锁
|
||||
*
|
||||
* @param key
|
||||
* @param jobInfo
|
||||
* @param lockSecond
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public void lock(String key, String jobInfo, Integer lockSecond) throws Exception {
|
||||
String existJobInfo = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(existJobInfo)) {
|
||||
log.info("获取锁失败: redisKey: {}, existJobInfo: {}", key, existJobInfo);
|
||||
throw new Exception("请不要反复提交订单!");
|
||||
}
|
||||
redisCache.setCacheObject(key, jobInfo, lockSecond, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* redis实现分布式锁 --- 解锁
|
||||
*
|
||||
* @param key
|
||||
* @param jobInfo
|
||||
* @throws Exception
|
||||
*/
|
||||
public void unLock(String key, String jobInfo) throws Exception {
|
||||
String existJobInfo = redisCache.getCacheObject(key);
|
||||
if (jobInfo.equals(existJobInfo)) {
|
||||
redisCache.deleteObject(key);
|
||||
} else {
|
||||
throw new Exception(String.format("释放锁异常: redisKey: %s, existJobInfo: %s, jobInfo: %s", key, existJobInfo, jobInfo));
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import org.dromara.generator.constant.GenConstants;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
|
@ -97,6 +97,18 @@
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.6</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,9 +1,19 @@
|
||||
package com.wzj.soopin.goods.controller;
|
||||
|
||||
|
||||
import com.wzj.soopin.goods.convert.BrandConvert;
|
||||
import com.wzj.soopin.goods.domain.entity.Brand;
|
||||
import com.wzj.soopin.goods.domain.query.BrandQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.BrandVO;
|
||||
import com.wzj.soopin.goods.service.BrandService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -26,38 +36,33 @@ public class BrandController extends BaseController {
|
||||
private BrandConvert convert;
|
||||
|
||||
@ApiOperation("查询品牌管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<Brand>> list(@RequestBody BrandQuery query, Pageable page) {
|
||||
List<Brand> list = service.selectList(query, page);
|
||||
return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
|
||||
}
|
||||
@ApiOperation("所有品牌管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:list')")
|
||||
@PostMapping("/all")
|
||||
public ResponseEntity<List<Brand>> all(@RequestBody BrandQuery query) {
|
||||
return ResponseEntity.ok(service.selectList(query, null));
|
||||
}
|
||||
|
||||
@ApiOperation("导出品牌管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:export')")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(BrandQuery query) {
|
||||
List<Brand> list = service.selectList(query, null);
|
||||
ExcelUtil<BrandVO> util = new ExcelUtil<>(BrandVO.class);
|
||||
ExcelUtil<BrandVO> util = new ExcelUtil(BrandVO.class);
|
||||
return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "品牌管理数据"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取品牌管理详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<Brand> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增品牌管理")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:add')")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody Brand brand) {
|
||||
@ -65,7 +70,6 @@ public class BrandController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改品牌管理")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:edit')")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody Brand brand) {
|
||||
@ -73,7 +77,6 @@ public class BrandController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除品牌管理")
|
||||
@PreAuthorize("@ss.hasPermi('pms:brand:remove')")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.wzj.soopin.goods.controller;
|
||||
|
||||
import com.cyl.manager.pms.convert.ProductCategoryConvert;
|
||||
import com.cyl.manager.pms.domain.entity.ProductCategory;
|
||||
import com.cyl.manager.pms.domain.query.ProductCategoryQuery;
|
||||
import com.cyl.manager.pms.domain.vo.ProductCategoryVO;
|
||||
import com.cyl.manager.pms.service.ProductCategoryService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.wzj.soopin.goods.convert.ProductCategoryConvert;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.query.ProductCategoryQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.goods.service.ProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,7 +32,6 @@ public class ProductCategoryController extends BaseController {
|
||||
private ProductCategoryConvert convert;
|
||||
|
||||
@ApiOperation("查询商品分类列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:productCategory:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<List<ProductCategoryVO>> list(@RequestBody ProductCategoryQuery query) {
|
||||
List<ProductCategoryVO> list = service.selectList(query, null);
|
||||
@ -41,14 +39,12 @@ public class ProductCategoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取商品分类详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:productCategory:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<ProductCategory> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增商品分类")
|
||||
@PreAuthorize("@ss.hasPermi('pms:productCategory:add')")
|
||||
@Log(title = "商品分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody ProductCategory productCategory) {
|
||||
@ -56,7 +52,6 @@ public class ProductCategoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品分类")
|
||||
@PreAuthorize("@ss.hasPermi('pms:productCategory:edit')")
|
||||
@Log(title = "商品分类", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody ProductCategory productCategory) {
|
||||
@ -64,7 +59,6 @@ public class ProductCategoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品分类")
|
||||
@PreAuthorize("@ss.hasPermi('pms:productCategory:remove')")
|
||||
@Log(title = "商品分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,22 @@
|
||||
package com.wzj.soopin.goods.controller;
|
||||
|
||||
import com.cyl.manager.pms.convert.ProductConvert;
|
||||
import com.cyl.manager.pms.domain.entity.Product;
|
||||
import com.cyl.manager.pms.domain.query.ProductQuery;
|
||||
import com.cyl.manager.pms.domain.vo.ProductVO;
|
||||
import com.cyl.manager.pms.service.ProductService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
|
||||
import com.wzj.soopin.goods.convert.ProductConvert;
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.query.ProductQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductVO;
|
||||
import com.wzj.soopin.goods.service.ProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +36,6 @@ public class ProductController extends BaseController {
|
||||
private ProductConvert convert;
|
||||
|
||||
@ApiOperation("查询商品信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<Product>> list(@RequestBody ProductQuery query, Pageable page) {
|
||||
List<Product> list = service.selectList(query, page);
|
||||
@ -44,24 +43,21 @@ public class ProductController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出商品信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:export')")
|
||||
@Log(title = "商品信息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(ProductQuery query) {
|
||||
List<Product> list = service.selectList(query, null);
|
||||
ExcelUtil<ProductVO> util = new ExcelUtil<>(ProductVO.class);
|
||||
ExcelUtil<ProductVO> util = new ExcelUtil(ProductVO.class);
|
||||
return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "商品信息数据"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取商品信息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<ProductVO> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增商品信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:add')")
|
||||
@Log(title = "商品信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody ProductVO product) {
|
||||
@ -69,7 +65,6 @@ public class ProductController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:edit')")
|
||||
@Log(title = "商品信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody ProductVO product) {
|
||||
@ -77,7 +72,6 @@ public class ProductController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:product:remove')")
|
||||
@Log(title = "商品信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.wzj.soopin.goods.controller;
|
||||
|
||||
import com.cyl.manager.pms.convert.SkuConvert;
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.cyl.manager.pms.domain.query.SkuQuery;
|
||||
import com.cyl.manager.pms.domain.vo.SkuVO;
|
||||
import com.cyl.manager.pms.service.SkuService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.wzj.soopin.goods.convert.SkuConvert;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import com.wzj.soopin.goods.domain.query.SkuQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.SkuVO;
|
||||
import com.wzj.soopin.goods.service.SkuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +35,6 @@ public class SkuController extends BaseController {
|
||||
private SkuConvert convert;
|
||||
|
||||
@ApiOperation("查询sku信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<Sku>> list(@RequestBody SkuQuery query, Pageable page) {
|
||||
List<Sku> list = service.selectList(query, page);
|
||||
@ -44,7 +42,6 @@ public class SkuController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出sku信息列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:export')")
|
||||
@Log(title = "sku信息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(SkuQuery query) {
|
||||
@ -54,14 +51,12 @@ public class SkuController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取sku信息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<Sku> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增sku信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:add')")
|
||||
@Log(title = "sku信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody Sku sku) {
|
||||
@ -69,7 +64,6 @@ public class SkuController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改sku信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:edit')")
|
||||
@Log(title = "sku信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody Sku sku) {
|
||||
@ -77,7 +71,6 @@ public class SkuController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除sku信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:sku:remove')")
|
||||
@Log(title = "sku信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.convert;
|
||||
|
||||
import com.cyl.manager.pms.domain.entity.Brand;
|
||||
import com.cyl.manager.pms.domain.vo.BrandVO;
|
||||
import com.wzj.soopin.goods.domain.entity.Brand;
|
||||
import com.wzj.soopin.goods.domain.vo.BrandVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wzj.soopin.goods.convert;
|
||||
|
||||
import com.cyl.h5.domain.dto.CategoryDTO;
|
||||
import com.cyl.manager.pms.domain.entity.ProductCategory;
|
||||
import com.cyl.manager.pms.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.goods.domain.dto.CategoryDTO;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.wzj.soopin.goods.convert;
|
||||
|
||||
import com.cyl.h5.domain.vo.H5ProductVO;
|
||||
import com.cyl.manager.pms.domain.entity.Product;
|
||||
import com.cyl.manager.pms.domain.vo.ProductVO;
|
||||
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.vo.H5ProductVO;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductVO;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.convert;
|
||||
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.cyl.manager.pms.domain.vo.SkuVO;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import com.wzj.soopin.goods.domain.vo.SkuVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.wzj.soopin.goods.domain.dto;
|
||||
|
||||
import com.wzj.soopin.goods.domain.vo.H5ProductVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CategoryDTO {
|
||||
private Long id;
|
||||
private Integer sort;
|
||||
private String name;
|
||||
private String icon;
|
||||
private List<H5ProductVO> productList;
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package com.wzj.soopin.goods.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 品牌管理对象 pms_brand
|
||||
*
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.wzj.soopin.goods.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.wzj.soopin.goods.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 商品分类对象 pms_product_category
|
||||
*
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.wzj.soopin.goods.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 品牌管理 数据视图对象
|
||||
*
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class H5ProductVO {
|
||||
private Long id;
|
||||
private String pic;
|
||||
private String name;
|
||||
private BigDecimal price;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import com.wzj.soopin.goods.domain.entity.Brand;
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ProductDetailVO {
|
||||
private Product product;
|
||||
private List<Sku> skus;
|
||||
private Brand brand;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.wzj.soopin.goods.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.pms.domain.entity.Brand;
|
||||
import com.wzj.soopin.goods.domain.entity.Brand;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.pms.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.pms.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.goods.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.wzj.soopin.goods.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cyl.manager.pms.domain.entity.Brand;
|
||||
import com.cyl.manager.pms.domain.query.BrandQuery;
|
||||
import com.cyl.manager.pms.mapper.BrandMapper;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.wzj.soopin.goods.domain.entity.Brand;
|
||||
import com.wzj.soopin.goods.domain.query.BrandQuery;
|
||||
import com.wzj.soopin.goods.mapper.BrandMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -5,18 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.cyl.h5.domain.dto.CategoryDTO;
|
||||
import com.cyl.manager.pms.convert.ProductCategoryConvert;
|
||||
import com.cyl.manager.pms.convert.ProductConvert;
|
||||
import com.cyl.manager.pms.domain.entity.Product;
|
||||
import com.cyl.manager.pms.domain.entity.ProductCategory;
|
||||
import com.cyl.manager.pms.domain.query.ProductCategoryQuery;
|
||||
import com.cyl.manager.pms.domain.vo.ProductCategoryVO;
|
||||
import com.cyl.manager.pms.mapper.ProductCategoryMapper;
|
||||
import com.cyl.manager.pms.mapper.ProductMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.exception.base.BaseException;
|
||||
import com.wzj.soopin.goods.convert.ProductCategoryConvert;
|
||||
import com.wzj.soopin.goods.convert.ProductConvert;
|
||||
import com.wzj.soopin.goods.domain.dto.CategoryDTO;
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.query.ProductCategoryQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.goods.mapper.ProductCategoryMapper;
|
||||
import com.wzj.soopin.goods.mapper.ProductMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.common.core.exception.base.BaseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -4,19 +4,19 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cyl.h5.domain.vo.ProductDetailVO;
|
||||
import com.cyl.manager.pms.convert.ProductConvert;
|
||||
import com.cyl.manager.pms.domain.entity.Product;
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.cyl.manager.pms.domain.query.ProductQuery;
|
||||
import com.cyl.manager.pms.domain.vo.ProductVO;
|
||||
import com.cyl.manager.pms.mapper.BrandMapper;
|
||||
import com.cyl.manager.pms.mapper.ProductMapper;
|
||||
import com.cyl.manager.pms.mapper.SkuMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.wzj.soopin.goods.convert.ProductConvert;
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import com.wzj.soopin.goods.domain.query.ProductQuery;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductDetailVO;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductVO;
|
||||
import com.wzj.soopin.goods.mapper.BrandMapper;
|
||||
import com.wzj.soopin.goods.mapper.ProductMapper;
|
||||
import com.wzj.soopin.goods.mapper.SkuMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.common.core.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.wzj.soopin.goods.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cyl.manager.pms.domain.entity.Sku;
|
||||
import com.cyl.manager.pms.domain.query.SkuQuery;
|
||||
import com.cyl.manager.pms.mapper.SkuMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import com.wzj.soopin.goods.domain.query.SkuQuery;
|
||||
import com.wzj.soopin.goods.mapper.SkuMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.member.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.ums.domain.entity.Member;
|
||||
import com.wzj.soopin.member.domain.po.Member;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.member.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.cyl.manager.ums.domain.entity.MemberWechat;
|
||||
import com.wzj.soopin.member.domain.po.MemberWechat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -0,0 +1,249 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.wzj.soopin.member.mapper.MemberMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户领券记录Service业务层处理
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
public class MemberCouponService {
|
||||
@Autowired
|
||||
private MemberCouponMapper memberCouponMapper;
|
||||
@Autowired
|
||||
private MemberMapper memberMapper;
|
||||
|
||||
/**
|
||||
* 查询用户领券记录
|
||||
*
|
||||
* @param id 用户领券记录主键
|
||||
* @return 用户领券记录
|
||||
*/
|
||||
public MemberCoupon selectById(Long id) {
|
||||
return memberCouponMapper.selectById(id);
|
||||
}
|
||||
|
||||
public MemberCoupon selectValidCoupon(Long id) {
|
||||
MemberCoupon coupon = memberCouponMapper.selectById(id);
|
||||
if (coupon == null) {
|
||||
return null;
|
||||
}
|
||||
if (Objects.equals(coupon.getUseStatus(), 1)) {
|
||||
throw new RuntimeException("优惠券已使用");
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (coupon.getBeginTime().isAfter(now)) {
|
||||
throw new RuntimeException("优惠券未到开始使用日期");
|
||||
}
|
||||
if (coupon.getEndTime().isBefore(now)) {
|
||||
throw new RuntimeException("优惠券已过期");
|
||||
}
|
||||
return coupon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户领券记录列表
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @param page 分页条件
|
||||
* @return 用户领券记录
|
||||
*/
|
||||
public Page<MemberCouponVO> selectList(MemberCouponQuery query, Pageable page) {
|
||||
|
||||
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
||||
QueryWrapper<MemberCoupon> qw = new QueryWrapper<>();
|
||||
Long couponActivityId = query.getCouponActivityId();
|
||||
if (couponActivityId != null) {
|
||||
qw.eq("coupon_activity_id", couponActivityId);
|
||||
}
|
||||
Long memberId = query.getMemberId();
|
||||
if (memberId != null) {
|
||||
qw.eq("member_id", memberId);
|
||||
}
|
||||
Integer useStatus = query.getUseStatus();
|
||||
if (useStatus != null) {
|
||||
qw.eq("use_status", useStatus);
|
||||
}
|
||||
List<MemberCoupon> list = memberCouponMapper.selectList(qw);
|
||||
|
||||
long total = ((com.github.pagehelper.Page) list).getTotal();
|
||||
if (total < 1) {
|
||||
return new PageImpl<>(Collections.emptyList(), page, total);
|
||||
}
|
||||
List<MemberCouponVO> resList = new ArrayList<>();
|
||||
Set<Long> memberIds = list.stream().map(it -> it.getMemberId()).collect(Collectors.toSet());
|
||||
Map<Long, Member> memberMap = memberMapper.selectList(new QueryWrapper<Member>().in("id", memberIds))
|
||||
.stream().collect(Collectors.toMap(it -> it.getId(), it -> it));
|
||||
for (MemberCoupon it : list) {
|
||||
MemberCouponVO vo = new MemberCouponVO();
|
||||
BeanUtils.copyProperties(it, vo);
|
||||
Member member = memberMap.get(it.getMemberId());
|
||||
if (member != null) {
|
||||
vo.setNickname(member.getNickname());
|
||||
vo.setPhone(member.getPhoneHidden());
|
||||
vo.setAvatar(member.getAvatar());
|
||||
}
|
||||
resList.add(vo);
|
||||
}
|
||||
|
||||
return new PageImpl<>(resList, page, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户领券记录
|
||||
*
|
||||
* @param memberCoupon 用户领券记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert(MemberCoupon memberCoupon) {
|
||||
memberCoupon.setCreateTime(LocalDateTime.now());
|
||||
return memberCouponMapper.insert(memberCoupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户领券记录
|
||||
*
|
||||
* @param memberCoupon 用户领券记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int update(MemberCoupon memberCoupon) {
|
||||
return memberCouponMapper.updateById(memberCoupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户领券记录信息
|
||||
*
|
||||
* @param id 用户领券记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteById(Long id) {
|
||||
return memberCouponMapper.deleteById(id);
|
||||
}
|
||||
|
||||
public Page<MemberCoupon> selectListByH5(MemberCouponQuery query, Pageable page) {
|
||||
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
||||
QueryWrapper<MemberCoupon> qw = new QueryWrapper<>();
|
||||
qw.eq("member_id", SecurityUtil.getLocalMember().getId());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (query.getType() != null) {
|
||||
switch (query.getType()) {
|
||||
case 1:
|
||||
//已领取
|
||||
qw.eq("use_status", 0)
|
||||
.ge("end_time", now)
|
||||
.le("begin_time", now);
|
||||
break;
|
||||
case 2:
|
||||
//已使用
|
||||
qw.eq("use_status", 1);
|
||||
break;
|
||||
case 3:
|
||||
//已过期
|
||||
qw.eq("use_status", 0);
|
||||
qw.and(it -> it.le("end_time", now).or().ge("begin_time", now));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<MemberCoupon> list = memberCouponMapper.selectList(qw);
|
||||
return new PageImpl<>(list, page, ((com.github.pagehelper.Page) list).getTotal());
|
||||
}
|
||||
|
||||
public List<MemberCoupon> getCanUseList(Collection<Product> products) {
|
||||
//先获取我的未过期的优惠券
|
||||
QueryWrapper<MemberCoupon> queryWrapper = new QueryWrapper<>();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
queryWrapper.eq("member_id", SecurityUtil.getLocalMember().getId())
|
||||
.eq("use_status", 0)
|
||||
.ge("end_time", now)
|
||||
.le("begin_time", now);
|
||||
List<MemberCoupon> list = memberCouponMapper.selectList(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return list;
|
||||
}
|
||||
List<MemberCoupon> matchList = new ArrayList<>();
|
||||
list.forEach(item -> {
|
||||
if (judgeCouponCanUse(item, products)) {
|
||||
matchList.add(item);
|
||||
}
|
||||
});
|
||||
return matchList;
|
||||
}
|
||||
|
||||
public Boolean judgeCouponCanUse(MemberCoupon item, Collection<Product> products) {
|
||||
//判断是否满足菜品
|
||||
if (!Objects.equals(1, item.getUseScope())) {
|
||||
List<Long> couponProducts = Arrays.stream(item.getProductIds().split(",")).map(it -> Long.parseLong(it)).collect(Collectors.toList());
|
||||
if (Objects.equals(2, item.getUseScope()) && products.stream().noneMatch(it -> couponProducts.contains(it.getId()))) {
|
||||
//指定商品
|
||||
return false;
|
||||
}
|
||||
if (Objects.equals(3, item.getUseScope()) && products.stream().anyMatch(it -> couponProducts.contains(it.getId()))) {
|
||||
//指定商品不包括
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//计算金额是否满足
|
||||
if (item.getMinAmount() == null || item.getMinAmount().equals(BigDecimal.ZERO)) {
|
||||
//无门槛
|
||||
return true;
|
||||
}
|
||||
if (item.getMinAmount().compareTo(calcMinAmount(products, item)) <= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private BigDecimal calcMinAmount(Collection<Product> products, MemberCoupon coupon) {
|
||||
List<Long> ids;
|
||||
if (!Objects.equals(1, coupon.getUseScope())) {
|
||||
ids = Arrays.stream(coupon.getProductIds().split(",")).map(it -> Long.parseLong(it)).collect(Collectors.toList());
|
||||
} else {
|
||||
ids = new ArrayList<>();
|
||||
}
|
||||
switch (coupon.getUseScope()) {
|
||||
case 1:
|
||||
return products.stream().map(Product::getPrice).reduce(BigDecimal::add).get();
|
||||
case 2:
|
||||
return products.stream().filter(it -> ids.contains(it.getId())).map(Product::getPrice).reduce(BigDecimal::add).get();
|
||||
case 3:
|
||||
return products.stream().filter(it -> !ids.contains(it.getId())).map(Product::getPrice).reduce(BigDecimal::add).get();
|
||||
default:
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCouponStatus(Long memberCouponId, Long orderId) {
|
||||
UpdateWrapper<MemberCoupon> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", memberCouponId)
|
||||
.set("use_status", 1)
|
||||
.set("use_time", LocalDateTime.now())
|
||||
.set("order_id", orderId);
|
||||
memberCouponMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
public void backCoupon(List<Long> couponIdList) {
|
||||
UpdateWrapper<MemberCoupon> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.in("id", couponIdList)
|
||||
.set("use_status", 0)
|
||||
.set("use_time", null)
|
||||
.set("order_id", null);
|
||||
memberCouponMapper.update(null, updateWrapper);
|
||||
}
|
||||
}
|
@ -97,6 +97,34 @@
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.3.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-member</artifactId>
|
||||
<version>5.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-goods</artifactId>
|
||||
<version>5.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,6 +1,31 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
|
||||
import com.wzj.soopin.order.convert.AftersaleConvert;
|
||||
import com.wzj.soopin.order.domain.entity.Aftersale;
|
||||
import com.wzj.soopin.order.domain.form.DealWithAftersaleForm;
|
||||
import com.wzj.soopin.order.domain.form.ManagerAftersaleOrderForm;
|
||||
import com.wzj.soopin.order.domain.query.AftersaleQuery;
|
||||
import com.wzj.soopin.order.domain.vo.ManagerRefundOrderDetailVO;
|
||||
import com.wzj.soopin.order.domain.vo.ManagerRefundOrderVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderOperateHistoryVO;
|
||||
import com.wzj.soopin.order.service.AftersaleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.utils.SecurityUtils;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.redis.redis.RedisService;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -22,7 +47,6 @@ public class AftersaleController extends BaseController {
|
||||
private RedisService redisService;
|
||||
|
||||
@ApiOperation("查询订单售后列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<ManagerRefundOrderVO>> list(@RequestBody ManagerAftersaleOrderForm query, Pageable page) {
|
||||
List<ManagerRefundOrderVO> list = service.selectList(query, page);
|
||||
@ -30,7 +54,6 @@ public class AftersaleController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单售后列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:export')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(AftersaleQuery query) {
|
||||
@ -41,14 +64,12 @@ public class AftersaleController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单售后详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<ManagerRefundOrderDetailVO> getInfo(@PathVariable("id") Long orderId) {
|
||||
return ResponseEntity.ok(service.selectById(orderId));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:add')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody Aftersale aftersale) {
|
||||
@ -56,7 +77,6 @@ public class AftersaleController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:edit')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody Aftersale aftersale) {
|
||||
@ -64,7 +84,6 @@ public class AftersaleController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersale:remove')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,22 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.AftersaleItemConvert;
|
||||
import com.cyl.manager.oms.domain.entity.AftersaleItem;
|
||||
import com.cyl.manager.oms.domain.query.AftersaleItemQuery;
|
||||
import com.cyl.manager.oms.domain.vo.AftersaleItemVO;
|
||||
import com.cyl.manager.oms.service.AftersaleItemService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
|
||||
import com.wzj.soopin.order.convert.AftersaleItemConvert;
|
||||
import com.wzj.soopin.order.domain.entity.AftersaleItem;
|
||||
import com.wzj.soopin.order.domain.query.AftersaleItemQuery;
|
||||
import com.wzj.soopin.order.domain.vo.AftersaleItemVO;
|
||||
import com.wzj.soopin.order.service.AftersaleItemService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +36,6 @@ public class AftersaleItemController extends BaseController {
|
||||
private AftersaleItemConvert convert;
|
||||
|
||||
@ApiOperation("查询订单售后列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<AftersaleItem>> list(@RequestBody AftersaleItemQuery query, Pageable page) {
|
||||
List<AftersaleItem> list = service.selectList(query, page);
|
||||
@ -44,7 +43,6 @@ public class AftersaleItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单售后列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:export')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(AftersaleItemQuery query) {
|
||||
@ -54,14 +52,12 @@ public class AftersaleItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单售后详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<AftersaleItem> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:add')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody AftersaleItem aftersaleItem) {
|
||||
@ -69,7 +65,6 @@ public class AftersaleItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:edit')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody AftersaleItem aftersaleItem) {
|
||||
@ -77,7 +72,6 @@ public class AftersaleItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单售后")
|
||||
@PreAuthorize("@ss.hasPermi('oms:aftersaleItem:remove')")
|
||||
@Log(title = "订单售后", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,27 +1,27 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.OrderConvert;
|
||||
import com.cyl.manager.oms.domain.entity.Order;
|
||||
import com.cyl.manager.oms.domain.form.DeliverProductForm;
|
||||
import com.cyl.manager.oms.domain.form.ManagerOrderQueryForm;
|
||||
import com.cyl.manager.oms.domain.query.OrderQuery;
|
||||
import com.cyl.manager.oms.domain.vo.ManagerOrderDetailVO;
|
||||
import com.cyl.manager.oms.domain.vo.ManagerOrderVO;
|
||||
import com.cyl.manager.oms.domain.vo.OrderOperateHistoryVO;
|
||||
import com.cyl.manager.oms.service.OrderService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.redis.RedisService;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.wzj.soopin.order.convert.OrderConvert;
|
||||
import com.wzj.soopin.order.domain.entity.Order;
|
||||
import com.wzj.soopin.order.domain.form.DeliverProductForm;
|
||||
import com.wzj.soopin.order.domain.form.ManagerOrderQueryForm;
|
||||
import com.wzj.soopin.order.domain.query.OrderQuery;
|
||||
import com.wzj.soopin.order.domain.vo.ManagerOrderDetailVO;
|
||||
import com.wzj.soopin.order.domain.vo.ManagerOrderVO;
|
||||
import com.wzj.soopin.order.domain.vo.OrderOperateHistoryVO;
|
||||
import com.wzj.soopin.order.service.OrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.SecurityUtils;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.redis.redis.RedisService;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
@ -43,7 +43,6 @@ public class OrderController extends BaseController {
|
||||
private RedisService redisService;
|
||||
|
||||
@ApiOperation("查询订单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<ManagerOrderVO>> list(@RequestBody ManagerOrderQueryForm query, Pageable page) {
|
||||
return ResponseEntity.ok(service.selectList(query, page));
|
||||
@ -56,7 +55,6 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:export')")
|
||||
@Log(title = "订单表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(OrderQuery query) {
|
||||
@ -67,14 +65,12 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单表详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<ManagerOrderDetailVO> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:add')")
|
||||
@Log(title = "订单表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody Order order) {
|
||||
@ -82,7 +78,6 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:edit')")
|
||||
@Log(title = "订单表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody Order order) {
|
||||
@ -90,7 +85,6 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:remove')")
|
||||
@Log(title = "订单表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
@ -98,7 +92,6 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("添加备注")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:note:add')")
|
||||
@Log(title = "订单表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/merchantNote/add")
|
||||
public ResponseEntity<Integer> saveMerchantNote(@RequestBody Order order){
|
||||
@ -106,7 +99,6 @@ public class OrderController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("管理后台订单发货")
|
||||
@PreAuthorize("@ss.hasPermi('oms:order:delivery')")
|
||||
@PostMapping("/deliverProduct")
|
||||
public ResponseEntity<String> delivery(@RequestBody DeliverProductForm request){
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
@ -133,7 +125,6 @@ public class OrderController extends BaseController {
|
||||
return ResponseEntity.ok(service.log(orderId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin')")
|
||||
@ApiOperation("订单解密")
|
||||
@GetMapping("/decryptPhone/{orderId}")
|
||||
public ResponseEntity<String> decryptPhone(@PathVariable Long orderId){
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.OrderDeliveryHistoryConvert;
|
||||
import com.cyl.manager.oms.domain.entity.OrderDeliveryHistory;
|
||||
import com.cyl.manager.oms.domain.query.OrderDeliveryHistoryQuery;
|
||||
import com.cyl.manager.oms.domain.vo.OrderDeliveryHistoryVO;
|
||||
import com.cyl.manager.oms.service.OrderDeliveryHistoryService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.wzj.soopin.order.convert.OrderDeliveryHistoryConvert;
|
||||
import com.wzj.soopin.order.domain.entity.OrderDeliveryHistory;
|
||||
import com.wzj.soopin.order.domain.query.OrderDeliveryHistoryQuery;
|
||||
import com.wzj.soopin.order.domain.vo.OrderDeliveryHistoryVO;
|
||||
import com.wzj.soopin.order.service.OrderDeliveryHistoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +35,6 @@ public class OrderDeliveryHistoryController extends BaseController {
|
||||
private OrderDeliveryHistoryConvert convert;
|
||||
|
||||
@ApiOperation("查询订单发货记录列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<OrderDeliveryHistory>> list(@RequestBody OrderDeliveryHistoryQuery query, Pageable page) {
|
||||
List<OrderDeliveryHistory> list = service.selectList(query, page);
|
||||
@ -44,7 +42,6 @@ public class OrderDeliveryHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单发货记录列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:export')")
|
||||
@Log(title = "订单发货记录", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(OrderDeliveryHistoryQuery query) {
|
||||
@ -54,14 +51,12 @@ public class OrderDeliveryHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单发货记录详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<OrderDeliveryHistory> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单发货记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:add')")
|
||||
@Log(title = "订单发货记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody OrderDeliveryHistory orderDeliveryHistory) {
|
||||
@ -69,7 +64,6 @@ public class OrderDeliveryHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单发货记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:edit')")
|
||||
@Log(title = "订单发货记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody OrderDeliveryHistory orderDeliveryHistory) {
|
||||
@ -77,7 +71,6 @@ public class OrderDeliveryHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单发货记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderDeliveryHistory:remove')")
|
||||
@Log(title = "订单发货记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.OrderItemConvert;
|
||||
import com.cyl.manager.oms.domain.entity.OrderItem;
|
||||
import com.cyl.manager.oms.domain.query.OrderItemQuery;
|
||||
import com.cyl.manager.oms.domain.vo.OrderItemVO;
|
||||
import com.cyl.manager.oms.service.OrderItemService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.wzj.soopin.order.convert.OrderItemConvert;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import com.wzj.soopin.order.domain.query.OrderItemQuery;
|
||||
import com.wzj.soopin.order.domain.vo.OrderItemVO;
|
||||
import com.wzj.soopin.order.service.OrderItemService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +35,6 @@ public class OrderItemController extends BaseController {
|
||||
private OrderItemConvert convert;
|
||||
|
||||
@ApiOperation("查询订单中所包含的商品列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<OrderItem>> list(@RequestBody OrderItemQuery query, Pageable page) {
|
||||
List<OrderItem> list = service.selectList(query, page);
|
||||
@ -44,7 +42,6 @@ public class OrderItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单中所包含的商品列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:export')")
|
||||
@Log(title = "订单中所包含的商品", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(OrderItemQuery query) {
|
||||
@ -54,14 +51,12 @@ public class OrderItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单中所包含的商品详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<OrderItem> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单中所包含的商品")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:add')")
|
||||
@Log(title = "订单中所包含的商品", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody OrderItem orderItem) {
|
||||
@ -69,7 +64,6 @@ public class OrderItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单中所包含的商品")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:edit')")
|
||||
@Log(title = "订单中所包含的商品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody OrderItem orderItem) {
|
||||
@ -77,7 +71,6 @@ public class OrderItemController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单中所包含的商品")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderItem:remove')")
|
||||
@Log(title = "订单中所包含的商品", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.OrderOperateHistoryConvert;
|
||||
import com.cyl.manager.oms.domain.entity.OrderOperateHistory;
|
||||
import com.cyl.manager.oms.domain.query.OrderOperateHistoryQuery;
|
||||
import com.cyl.manager.oms.domain.vo.OrderOperateHistoryVO;
|
||||
import com.cyl.manager.oms.service.OrderOperateHistoryService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.wzj.soopin.order.convert.OrderOperateHistoryConvert;
|
||||
import com.wzj.soopin.order.domain.entity.OrderOperateHistory;
|
||||
import com.wzj.soopin.order.domain.query.OrderOperateHistoryQuery;
|
||||
import com.wzj.soopin.order.domain.vo.OrderOperateHistoryVO;
|
||||
import com.wzj.soopin.order.service.OrderOperateHistoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +35,6 @@ public class OrderOperateHistoryController extends BaseController {
|
||||
private OrderOperateHistoryConvert convert;
|
||||
|
||||
@ApiOperation("查询订单操作历史记录列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<OrderOperateHistory>> list(@RequestBody OrderOperateHistoryQuery query, Pageable page) {
|
||||
List<OrderOperateHistory> list = service.selectList(query, page);
|
||||
@ -44,7 +42,6 @@ public class OrderOperateHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出订单操作历史记录列表")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:export')")
|
||||
@Log(title = "订单操作历史记录", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(OrderOperateHistoryQuery query) {
|
||||
@ -54,14 +51,12 @@ public class OrderOperateHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取订单操作历史记录详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<OrderOperateHistory> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单操作历史记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:add')")
|
||||
@Log(title = "订单操作历史记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody OrderOperateHistory orderOperateHistory) {
|
||||
@ -69,7 +64,6 @@ public class OrderOperateHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单操作历史记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:edit')")
|
||||
@Log(title = "订单操作历史记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody OrderOperateHistory orderOperateHistory) {
|
||||
@ -77,7 +71,6 @@ public class OrderOperateHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单操作历史记录")
|
||||
@PreAuthorize("@ss.hasPermi('oms:orderOperateHistory:remove')")
|
||||
@Log(title = "订单操作历史记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,22 +1,21 @@
|
||||
package com.wzj.soopin.order.controller;
|
||||
|
||||
import com.cyl.manager.oms.convert.WechatPaymentHistoryConvert;
|
||||
import com.cyl.manager.oms.domain.entity.WechatPaymentHistory;
|
||||
import com.cyl.manager.oms.domain.query.WechatPaymentHistoryQuery;
|
||||
import com.cyl.manager.oms.domain.vo.WechatPaymentHistoryVO;
|
||||
import com.cyl.manager.oms.service.WechatPaymentHistoryService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.wzj.soopin.order.convert.WechatPaymentHistoryConvert;
|
||||
import com.wzj.soopin.order.domain.entity.WechatPaymentHistory;
|
||||
import com.wzj.soopin.order.domain.query.WechatPaymentHistoryQuery;
|
||||
import com.wzj.soopin.order.domain.vo.WechatPaymentHistoryVO;
|
||||
import com.wzj.soopin.order.service.WechatPaymentHistoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -36,7 +35,6 @@ public class WechatPaymentHistoryController extends BaseController {
|
||||
private WechatPaymentHistoryConvert convert;
|
||||
|
||||
@ApiOperation("查询微信订单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:list')")
|
||||
@PostMapping("/list")
|
||||
public ResponseEntity<Page<WechatPaymentHistory>> list(@RequestBody WechatPaymentHistoryQuery query, Pageable page) {
|
||||
List<WechatPaymentHistory> list = service.selectList(query, page);
|
||||
@ -44,7 +42,6 @@ public class WechatPaymentHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("导出微信订单表列表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:export')")
|
||||
@Log(title = "微信订单表", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public ResponseEntity<String> export(WechatPaymentHistoryQuery query) {
|
||||
@ -54,14 +51,12 @@ public class WechatPaymentHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("获取微信订单表详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<WechatPaymentHistory> getInfo(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(service.selectById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("新增微信订单表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:add')")
|
||||
@Log(title = "微信订单表", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public ResponseEntity<Integer> add(@RequestBody WechatPaymentHistory wechatPaymentHistory) {
|
||||
@ -69,7 +64,6 @@ public class WechatPaymentHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改微信订单表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:edit')")
|
||||
@Log(title = "微信订单表", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public ResponseEntity<Integer> edit(@RequestBody WechatPaymentHistory wechatPaymentHistory) {
|
||||
@ -77,7 +71,6 @@ public class WechatPaymentHistoryController extends BaseController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除微信订单表")
|
||||
@PreAuthorize("@ss.hasPermi('pms:omsWechatPaymentHistory:remove')")
|
||||
@Log(title = "微信订单表", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.Aftersale;
|
||||
import com.cyl.manager.oms.domain.vo.AftersaleVO;
|
||||
import com.wzj.soopin.order.domain.entity.Aftersale;
|
||||
import com.wzj.soopin.order.domain.vo.AftersaleVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.AftersaleItem;
|
||||
import com.cyl.manager.oms.domain.vo.AftersaleItemVO;
|
||||
import com.wzj.soopin.order.domain.entity.AftersaleItem;
|
||||
import com.wzj.soopin.order.domain.vo.AftersaleItemVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.Order;
|
||||
import com.cyl.manager.oms.domain.vo.OrderVO;
|
||||
|
||||
import com.wzj.soopin.order.domain.entity.Order;
|
||||
import com.wzj.soopin.order.domain.vo.OrderVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.OrderDeliveryHistory;
|
||||
import com.cyl.manager.oms.domain.vo.OrderDeliveryHistoryVO;
|
||||
import com.wzj.soopin.order.domain.entity.OrderDeliveryHistory;
|
||||
import com.wzj.soopin.order.domain.vo.OrderDeliveryHistoryVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.OrderItem;
|
||||
import com.cyl.manager.oms.domain.vo.OrderItemVO;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import com.wzj.soopin.order.domain.vo.OrderItemVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.OrderOperateHistory;
|
||||
import com.cyl.manager.oms.domain.vo.OrderOperateHistoryVO;
|
||||
|
||||
import com.wzj.soopin.order.domain.entity.OrderOperateHistory;
|
||||
import com.wzj.soopin.order.domain.vo.OrderOperateHistoryVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.wzj.soopin.order.convert;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.WechatPaymentHistory;
|
||||
import com.cyl.manager.oms.domain.vo.WechatPaymentHistoryVO;
|
||||
import com.wzj.soopin.order.domain.entity.WechatPaymentHistory;
|
||||
import com.wzj.soopin.order.domain.vo.WechatPaymentHistoryVO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.wzj.soopin.order.domain.dto;
|
||||
|
||||
import com.wzj.soopin.goods.domain.entity.Product;
|
||||
import com.wzj.soopin.goods.domain.entity.Sku;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 创建订单请求VO
|
||||
* @author Jinxin
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "创建订单请求VO")
|
||||
public class OrderProductListDTO {
|
||||
@ApiModelProperty(value = "商品skuId", required = true)
|
||||
@NotNull(message = "商品skuId不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@ApiModelProperty(value = "数量", required = true)
|
||||
@NotNull(message = "数量不能为空")
|
||||
@Min(value = 1, message = "数量不能小于1")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty(value = "消费金", hidden = true)
|
||||
private BigDecimal consumption;
|
||||
|
||||
@ApiModelProperty(value = "运费", hidden = true)
|
||||
private BigDecimal freightAmount;
|
||||
|
||||
@ApiModelProperty(value = "隐藏 业务过程中的数据", hidden = true)
|
||||
private Sku sku;
|
||||
|
||||
@ApiModelProperty(value = "隐藏 业务过程中的数据", hidden = true)
|
||||
private Product product;
|
||||
}
|
@ -3,11 +3,11 @@ package com.wzj.soopin.order.domain.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.wzj.soopin.order.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -3,11 +3,11 @@ package com.wzj.soopin.order.domain.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.wzj.soopin.order.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 订单发货记录对象 oms_order_delivery_history
|
||||
*
|
||||
|
@ -3,11 +3,11 @@ package com.wzj.soopin.order.domain.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.wzj.soopin.order.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 订单操作历史记录对象 oms_order_operate_history
|
||||
*
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.wzj.soopin.order.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 系统数据统计对象 aws_system_statistics
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@ApiModel(description="系统数据统计对象")
|
||||
@Data
|
||||
@TableName("aws_system_statistics")
|
||||
public class SystemStatistics {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("统计日期")
|
||||
@Excel(name = "统计日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime date;
|
||||
|
||||
@ApiModelProperty("登录用户数")
|
||||
@Excel(name = "登录用户数")
|
||||
private Integer loginMemberCount;
|
||||
|
||||
@ApiModelProperty("注册用户数")
|
||||
@Excel(name = "注册用户数")
|
||||
private Integer registerMemberCount;
|
||||
|
||||
@ApiModelProperty("加购用户数")
|
||||
@Excel(name = "加购用户数")
|
||||
private Integer addCartMemberCount;
|
||||
|
||||
@ApiModelProperty("下单用户数")
|
||||
@Excel(name = "下单用户数")
|
||||
private Integer createOrderMemberCount;
|
||||
|
||||
@ApiModelProperty("成交用户数")
|
||||
@Excel(name = "成交用户数")
|
||||
private Integer dealMemberCount;
|
||||
|
||||
@ApiModelProperty("下单数")
|
||||
@Excel(name = "下单数")
|
||||
private Integer orderCount;
|
||||
|
||||
@ApiModelProperty("成交数")
|
||||
@Excel(name = "成交数")
|
||||
private Integer dealCount;
|
||||
|
||||
@ApiModelProperty("成交金额")
|
||||
@Excel(name = "成交金额")
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
@ApiModelProperty("售后数")
|
||||
@Excel(name = "售后数")
|
||||
private Integer aftersaleCount;
|
||||
|
||||
@ApiModelProperty("售后金额")
|
||||
@Excel(name = "售后金额")
|
||||
private BigDecimal aftersaleAmount;
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package com.wzj.soopin.order.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.wzj.soopin.order.domain.form;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
@Data
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.wzj.soopin.order.domain.form;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.wzj.soopin.order.domain.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderH5Query {
|
||||
private Integer tab;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("统计订单数量VO")
|
||||
public class CountOrderVO {
|
||||
|
||||
@ApiModelProperty(value = "待付款订单数量", dataType = "Integer")
|
||||
private Integer unpaid;
|
||||
|
||||
@ApiModelProperty(value = "待发货订单数量", dataType = "Integer")
|
||||
private Integer nosend;
|
||||
|
||||
@ApiModelProperty(value = "待收货订单数量", dataType = "Integer")
|
||||
private Integer noget;
|
||||
|
||||
@ApiModelProperty(value = "售后订单数量", dataType = "Integer")
|
||||
private Integer aftersale;
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class H5OrderVO {
|
||||
|
||||
@ApiModelProperty("订单id")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("支付id")
|
||||
private Long payId;
|
||||
|
||||
@ApiModelProperty("订单编号")
|
||||
private String orderSn;
|
||||
|
||||
@ApiModelProperty("会员id")
|
||||
private Long memberId;
|
||||
|
||||
@ApiModelProperty("订单总金额")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@ApiModelProperty("应付金额")
|
||||
private BigDecimal payAmount;
|
||||
|
||||
private BigDecimal couponAmount;
|
||||
|
||||
@ApiModelProperty("订单状态 0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("售后状态")
|
||||
private Integer aftersaleStatus;
|
||||
|
||||
@ApiModelProperty("订单Item")
|
||||
private List<OrderItem> orderItemList;
|
||||
|
||||
@ApiModelProperty("订单备注")
|
||||
private String note;
|
||||
|
||||
@ApiModelProperty("物流单号")
|
||||
private String deliverySn;
|
||||
|
||||
@ApiModelProperty("下单时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("支付时间")
|
||||
private LocalDateTime paymentTime;
|
||||
|
||||
@ApiModelProperty("收货人姓名")
|
||||
private String receiverName;
|
||||
|
||||
@ApiModelProperty("收货人手机号")
|
||||
private String receiverPhone;
|
||||
|
||||
@ApiModelProperty("省份/直辖市")
|
||||
private String receiverProvince;
|
||||
|
||||
@ApiModelProperty("城市")
|
||||
private String receiverCity;
|
||||
|
||||
@ApiModelProperty("区")
|
||||
private String receiverDistrict;
|
||||
|
||||
@ApiModelProperty("详细地址")
|
||||
private String receiverDetailAddress;
|
||||
|
||||
@ApiModelProperty("支付倒计时")
|
||||
private Long timeToPay;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@ApiModel("会员下单数据统计对象")
|
||||
public class MemberDataStatisticsVO {
|
||||
@ApiModelProperty("购物车数")
|
||||
private Integer cartCount;
|
||||
@ApiModelProperty("订单数")
|
||||
private Integer orderCount;
|
||||
@ApiModelProperty("下单金额")
|
||||
private BigDecimal orderAmount;
|
||||
@ApiModelProperty("售后数")
|
||||
private Integer aftersaleCount;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class OrderAndAftersaleStatisticsVO {
|
||||
/** 待处理售后 */
|
||||
private Integer pendingAftersaleCount;
|
||||
/** 处理中售后 */
|
||||
private Integer processingAftersaleCount;
|
||||
/** 待发货 */
|
||||
private Integer waitDeliveredCount;
|
||||
/** 已发货 */
|
||||
private Integer todayHasDeliveredCount;
|
||||
/** 订单数 */
|
||||
private Integer todayOrderCount;
|
||||
/** 成交额 */
|
||||
private BigDecimal todayTransactionAmount;
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 订单发货记录 数据视图对象
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 订单操作历史记录 数据视图对象
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.cyl.manager.oms.domain.entity.OrderItem;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import com.wzj.soopin.order.domain.entity.OrderItem;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wzj.soopin.order.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseAudit;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
import org.dromara.common.excel.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user