Compare commits
10 Commits
25ada3932d
...
217b0e6c87
Author | SHA1 | Date |
---|---|---|
|
217b0e6c87 | |
|
810b36b9db | |
|
247196734f | |
|
383519a2d7 | |
|
3febf38dc4 | |
|
1f6c718fed | |
|
2d2b0541ff | |
|
48e58bea7c | |
|
8296126d9f | |
|
88de15ced1 |
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -138,6 +138,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,216 @@
|
||||||
|
package com.muyu.common.core.web.domain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.muyu.common.core.constant.HttpStatus;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作消息提醒
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class AjaxResult extends HashMap<String, Object>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 状态码 */
|
||||||
|
public static final String CODE_TAG = "code";
|
||||||
|
|
||||||
|
/** 返回内容 */
|
||||||
|
public static final String MSG_TAG = "msg";
|
||||||
|
|
||||||
|
/** 数据对象 */
|
||||||
|
public static final String DATA_TAG = "data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||||
|
*/
|
||||||
|
public AjaxResult()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
*/
|
||||||
|
public AjaxResult(int code, String msg)
|
||||||
|
{
|
||||||
|
super.put(CODE_TAG, code);
|
||||||
|
super.put(MSG_TAG, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
*/
|
||||||
|
public AjaxResult(int code, String msg, Object data)
|
||||||
|
{
|
||||||
|
super.put(CODE_TAG, code);
|
||||||
|
super.put(MSG_TAG, msg);
|
||||||
|
if (StringUtils.isNotNull(data))
|
||||||
|
{
|
||||||
|
super.put(DATA_TAG, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success()
|
||||||
|
{
|
||||||
|
return AjaxResult.success("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功数据
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(Object data)
|
||||||
|
{
|
||||||
|
return AjaxResult.success("操作成功", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult warn(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.warn(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult warn(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.WARN, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error()
|
||||||
|
{
|
||||||
|
return AjaxResult.error("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(int code, String msg)
|
||||||
|
{
|
||||||
|
return new AjaxResult(code, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为成功消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isSuccess()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为警告消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isWarn()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为错误消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isError()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方便链式调用
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult put(String key, Object value)
|
||||||
|
{
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class RedisService {
|
public class RedisService {
|
||||||
@Autowired
|
@Autowired
|
||||||
public RedisTemplate redisTemplate;
|
public RedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存基本的对象,Integer、String、实体类等
|
* 缓存基本的对象,Integer、String、实体类等
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,4 +27,6 @@
|
||||||
muyu-common通用模块
|
muyu-common通用模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -25,4 +25,5 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,7 +3,9 @@ package com.muyu.product.domain.DTO;
|
||||||
import com.muyu.common.core.domain.BaseEntity;
|
import com.muyu.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
@ -13,29 +15,34 @@ import javax.validation.constraints.NotNull;
|
||||||
* @Date: 2024/3/29 16:57
|
* @Date: 2024/3/29 16:57
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@ApiModel(description = "产品实体类")
|
@ApiModel(description = "产品实体类")
|
||||||
public class Product extends BaseEntity {
|
public class Product extends BaseEntity {
|
||||||
|
|
||||||
@ApiModelProperty(value = "id")
|
@ApiModelProperty(value = "id")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "名称")
|
@ApiModelProperty(value = "名称",required = true)
|
||||||
@NotEmpty(message = "名称不能为空")
|
@NotEmpty(message = "名称不能为空")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "货号")
|
@ApiModelProperty(value = "货号",required = true)
|
||||||
@NotNull(message = "货号不能为空")
|
@NotNull(message = "货号不能为空")
|
||||||
private Integer productNumber;
|
private String productNumber;
|
||||||
|
|
||||||
@ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)")
|
@ApiModelProperty(value = "审核状态 (1:通过, 2:驳回)")
|
||||||
private Integer productExamine;
|
private Integer productExamine;
|
||||||
|
|
||||||
@ApiModelProperty(value = "品牌")
|
@ApiModelProperty(value = "分类",required = true)
|
||||||
|
@NotNull(message = "分类不能不选择")
|
||||||
|
private Integer categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "品牌",required = true)
|
||||||
@NotNull(message = "品牌不能不选择")
|
@NotNull(message = "品牌不能不选择")
|
||||||
private Integer brandId;
|
private Integer brandId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品类型")
|
@ApiModelProperty(value = "商品类型",required = true)
|
||||||
@NotNull(message = "商品类型不能不选择")
|
|
||||||
private Integer typeId;
|
private Integer typeId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "副标题")
|
@ApiModelProperty(value = "副标题")
|
||||||
|
@ -51,10 +58,10 @@ public class Product extends BaseEntity {
|
||||||
private Double productWeight;
|
private Double productWeight;
|
||||||
|
|
||||||
@ApiModelProperty(value = "排序")
|
@ApiModelProperty(value = "排序")
|
||||||
private String productSort;
|
private Integer productSort;
|
||||||
|
|
||||||
@ApiModelProperty(value = "促销表id")
|
@ApiModelProperty(value = "市场价")
|
||||||
private Integer promotionId;
|
private Integer marketPrice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "积分")
|
@ApiModelProperty(value = "积分")
|
||||||
private Integer productPoints;
|
private Integer productPoints;
|
||||||
|
@ -102,5 +109,6 @@ public class Product extends BaseEntity {
|
||||||
@ApiModelProperty(value = "PC端信息")
|
@ApiModelProperty(value = "PC端信息")
|
||||||
private String pcInformation;
|
private String pcInformation;
|
||||||
|
|
||||||
|
private Integer sales;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ProductSkuAttr extends BaseEntity {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "SKU ID")
|
@ApiModelProperty(value = "SKU ID")
|
||||||
private BigInteger skuId;
|
private long skuId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "属性ID")
|
@ApiModelProperty(value = "属性ID")
|
||||||
private Integer attrId;
|
private Integer attrId;
|
||||||
|
|
|
@ -57,13 +57,11 @@ public class ProductTypeAttr extends BaseEntity {
|
||||||
@ApiModelProperty(value = "手动新增:0-是,1-否")
|
@ApiModelProperty(value = "手动新增:0-是,1-否")
|
||||||
private Integer manualOperation;
|
private Integer manualOperation;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "类型名称")
|
@ApiModelProperty(value = "类型名称")
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "类型集合")
|
@ApiModelProperty(value = "类型集合")
|
||||||
private List<TypeAttrs> typeAttrs;
|
private List<TypeAttrs> typeAttrs;
|
||||||
|
|
||||||
@ApiModelProperty(value = "tavId")
|
|
||||||
private Integer tavId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,19 @@ package com.muyu.product.domain.DTO;
|
||||||
import com.muyu.common.core.domain.BaseEntity;
|
import com.muyu.common.core.domain.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wangxinyuan
|
* @Author: wangxinyuan
|
||||||
* @Date: 2024/3/29 16:59
|
* @Date: 2024/3/29 16:59
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@ApiModel(value = "ProductTypeAttrValue", description = "产品类型属性值信息")
|
@ApiModel(value = "ProductTypeAttrValue", description = "产品类型属性值信息")
|
||||||
public class ProductTypeAttrValue extends BaseEntity {
|
public class ProductTypeAttrValue extends BaseEntity {
|
||||||
|
|
||||||
|
@ -20,9 +26,17 @@ public class ProductTypeAttrValue extends BaseEntity {
|
||||||
private Integer typeAttrId;
|
private Integer typeAttrId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "属性值详情")
|
@ApiModelProperty(value = "属性值详情")
|
||||||
private Integer typeAttrValue;
|
private String typeAttrValue;
|
||||||
|
|
||||||
@ApiModelProperty(value = "录入方式:0-自动,1-手动")
|
@ApiModelProperty(value = "录入方式:0-自动,1-手动")
|
||||||
private Integer inputMethod;
|
private Integer inputMethod;
|
||||||
|
|
||||||
|
|
||||||
|
// 添加集合属性及其getter方法
|
||||||
|
private List<ProductTypeAttrValue> productTypeAttrValueList;
|
||||||
|
|
||||||
|
public List<ProductTypeAttrValue> getProductTypeAttrValueList() {
|
||||||
|
return productTypeAttrValueList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,4 +51,6 @@ public class ProductReq {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ public class QueryProductReq {
|
||||||
private Integer pageNum = 1;
|
private Integer pageNum = 1;
|
||||||
|
|
||||||
@ApiModelProperty(value = "分页参数")
|
@ApiModelProperty(value = "分页参数")
|
||||||
private Integer pageSize = 5;
|
private Integer pageSize = 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.muyu.product.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: wangxinyuan
|
||||||
|
* @Date: 2024/4/10 下午8:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "ProductVo")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ProductVo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品名称")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品信息")
|
||||||
|
private String productInformation;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "详情标题")
|
||||||
|
private String detailsTitle;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "详情信息")
|
||||||
|
private String detailsInformation;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "品牌名称")
|
||||||
|
private String brandName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "销售价格")
|
||||||
|
private Double salePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "促销价格")
|
||||||
|
private Double promotionPrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片链接")
|
||||||
|
private String imagesUrl;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "服务名称")
|
||||||
|
private String serviceName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "类型名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import com.muyu.product.domain.Resp.ProductResp;
|
||||||
import com.muyu.product.domain.req.ProductReq;
|
import com.muyu.product.domain.req.ProductReq;
|
||||||
import com.muyu.product.domain.req.QueryProductReq;
|
import com.muyu.product.domain.req.QueryProductReq;
|
||||||
import com.muyu.common.core.domain.R;
|
import com.muyu.common.core.domain.R;
|
||||||
|
import com.muyu.product.domain.vo.ProductVo;
|
||||||
import com.muyu.product.service.ProductService;
|
import com.muyu.product.service.ProductService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
@ -50,9 +51,10 @@ public class ProductController {
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("添加商品")
|
@ApiOperation("添加商品")
|
||||||
@PostMapping("/productInsert")
|
@PostMapping("/productInsert")
|
||||||
public R<Product>productInsert(@Valid @RequestBody ProductReq productReq){
|
public R productInsert(@Valid @RequestBody ProductReq productReq){
|
||||||
productService.productInsert(productReq);
|
productService.productInsert(productReq);
|
||||||
return R.ok(null,"添加成功");
|
return R.ok(null,"添加成功");
|
||||||
}
|
}
|
||||||
|
@ -95,4 +97,11 @@ public class ProductController {
|
||||||
}
|
}
|
||||||
return error("上传图片异常,请联系管理员");
|
return error("上传图片异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("测试商品信息")
|
||||||
|
@GetMapping("/queryProductDetails/{id}")
|
||||||
|
public R<ProductVo> queryProductDetails(@PathVariable Integer id){
|
||||||
|
ProductVo productVo = productService.queryProductDetails(id);
|
||||||
|
return R.ok(productVo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.muyu.product.mapper;
|
||||||
|
|
||||||
import com.muyu.product.domain.DTO.Product;
|
import com.muyu.product.domain.DTO.Product;
|
||||||
import com.muyu.product.domain.Resp.ProductResp;
|
import com.muyu.product.domain.Resp.ProductResp;
|
||||||
import com.muyu.product.domain.req.ProductReq;
|
|
||||||
import com.muyu.product.domain.req.QueryProductReq;
|
import com.muyu.product.domain.req.QueryProductReq;
|
||||||
|
import com.muyu.product.domain.vo.ProductVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,11 +15,14 @@ public interface ProductMapper {
|
||||||
|
|
||||||
List<ProductResp> queryProduct(QueryProductReq productReq);
|
List<ProductResp> queryProduct(QueryProductReq productReq);
|
||||||
|
|
||||||
void insertProduct(Product product);
|
Integer insertProduct(Product product);
|
||||||
|
|
||||||
void updateMothodId(Integer id);
|
void updateMothodId(Integer id);
|
||||||
|
|
||||||
Integer findProductNumber(ProductReq productReq);
|
Integer findProductNumber(String productNumber);
|
||||||
|
|
||||||
|
|
||||||
Integer deleteProduct(Integer id);
|
Integer deleteProduct(Integer id);
|
||||||
|
|
||||||
|
ProductVo queryProductDetails(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
||||||
import com.muyu.product.domain.DTO.ProductSku;
|
import com.muyu.product.domain.DTO.ProductSku;
|
||||||
import com.muyu.product.domain.DTO.ProductSkuAttr;
|
import com.muyu.product.domain.DTO.ProductSkuAttr;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -12,10 +13,11 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ProductSkuMapper {
|
public interface ProductSkuMapper {
|
||||||
void insertProductSku(List<ProductSku> productSkuList);
|
|
||||||
|
|
||||||
void insertProductSkuAttr(List<ProductSkuAttr> productSkuAttrs);
|
void insertProductSkuAttr(@Param("productSkuAttrs") List<ProductSkuAttr> productSkuAttrs);
|
||||||
|
|
||||||
Integer findSkuId(List<ProductSku> productSkus);
|
void insertProductSku(@Param("productSkus") List<ProductSku> productSkus, @Param("id") Integer id, @Param("createBy") String createBy);
|
||||||
|
|
||||||
|
Integer findSkuId(@Param("productSkus") List<ProductSku> productSkus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.product.mapper;
|
package com.muyu.product.mapper;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -11,5 +12,5 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ServicesMapper {
|
public interface ServicesMapper {
|
||||||
|
|
||||||
int insertProductServicep(Integer productId, List<Integer> serviceIds);
|
int insertProductService(@Param("id") Integer id, @Param("serviceIds") List<Integer> serviceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,23 +18,24 @@ import java.util.List;
|
||||||
public interface TypeMapper {
|
public interface TypeMapper {
|
||||||
|
|
||||||
|
|
||||||
List<ProductTypeResp> queryTypeAll();
|
|
||||||
|
|
||||||
List<ProductTypeAttr> queryType(@Param("flag") Integer flag, @Param("id") Integer id);
|
List<ProductTypeAttr> queryType(@Param("flag") Integer flag, @Param("id") Integer id);
|
||||||
|
|
||||||
|
List<ProductTypeResp> queryTypeAll();
|
||||||
|
|
||||||
Integer deleteType(@Param("typeId") Integer typeId, @Param("name") String name);
|
Integer deleteType(@Param("typeId") Integer typeId, @Param("name") String name);
|
||||||
|
|
||||||
void deleteTypeAttrValue(Integer typeId);
|
|
||||||
|
|
||||||
Integer deleteTypeAttr(Integer typeId);
|
|
||||||
|
|
||||||
Integer insertType(ProductType productType);
|
Integer insertType(ProductType productType);
|
||||||
|
|
||||||
Integer updateType(ProductType productType);
|
Integer updateType(ProductType productType);
|
||||||
|
|
||||||
Integer insertTypeAttr(ProductTypeAttrReq productTypeAttrReq);
|
Integer insertTypeAttr(ProductTypeAttrReq productTypeAttrReq);
|
||||||
|
|
||||||
void insertTypeValue(@Param("productTypeAttrValueList") List<ProductTypeAttrValue> productTypeAttrValueList);
|
|
||||||
|
Integer deleteTypeAttr(Integer id);
|
||||||
|
|
||||||
Integer updateAttr(ProductTypeAttrReq productTypeAttrReq);
|
Integer updateAttr(ProductTypeAttrReq productTypeAttrReq);
|
||||||
|
|
||||||
|
void deleteTypeAttrValue(Integer typeId);
|
||||||
|
|
||||||
|
void insertTypeValue(ProductTypeAttrValue productTypeAttrValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.product.domain.DTO.ProductSkuAttr;
|
||||||
import com.muyu.product.domain.Resp.ProductResp;
|
import com.muyu.product.domain.Resp.ProductResp;
|
||||||
import com.muyu.product.domain.req.ProductReq;
|
import com.muyu.product.domain.req.ProductReq;
|
||||||
import com.muyu.product.domain.req.QueryProductReq;
|
import com.muyu.product.domain.req.QueryProductReq;
|
||||||
|
import com.muyu.product.domain.vo.ProductVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: wangxinyuan
|
* @Author: wangxinyuan
|
||||||
|
@ -21,4 +22,6 @@ public interface ProductService {
|
||||||
Integer deleteProduct(Integer id);
|
Integer deleteProduct(Integer id);
|
||||||
|
|
||||||
void productUpdate(ProductReq productReq);
|
void productUpdate(ProductReq productReq);
|
||||||
|
|
||||||
|
ProductVo queryProductDetails(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,6 @@ import java.util.List;
|
||||||
* @Date: 2024/3/29 17:05
|
* @Date: 2024/3/29 17:05
|
||||||
*/
|
*/
|
||||||
public interface ServiceService {
|
public interface ServiceService {
|
||||||
int insertProductService(Integer id, List<Integer> serviceIds);
|
|
||||||
|
int insertProductService(Integer productId,List<Integer> serviceIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
import com.alibaba.fastjson.JSONObject; // 导入 FastJSON 的 JSONObject 类
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.github.pagehelper.PageHelper; // 导入 PageHelper 类
|
import com.github.pagehelper.PageHelper; // 导入 PageHelper 类
|
||||||
import com.github.pagehelper.PageInfo; // 导入 PageInfo 类
|
import com.github.pagehelper.PageInfo; // 导入 PageInfo 类
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
@ -10,7 +10,9 @@ import com.muyu.product.domain.DTO.*;
|
||||||
import com.muyu.product.domain.DTO.Number;
|
import com.muyu.product.domain.DTO.Number;
|
||||||
import com.muyu.product.domain.Resp.ProductResp;
|
import com.muyu.product.domain.Resp.ProductResp;
|
||||||
import com.muyu.product.domain.req.ProductReq;
|
import com.muyu.product.domain.req.ProductReq;
|
||||||
|
import com.muyu.product.domain.req.ProductSkuNew;
|
||||||
import com.muyu.product.domain.req.QueryProductReq;
|
import com.muyu.product.domain.req.QueryProductReq;
|
||||||
|
import com.muyu.product.domain.vo.ProductVo;
|
||||||
import com.muyu.product.mapper.ProductMapper;
|
import com.muyu.product.mapper.ProductMapper;
|
||||||
import com.muyu.product.mapper.ProductSkuMapper;
|
import com.muyu.product.mapper.ProductSkuMapper;
|
||||||
import com.muyu.product.mapper.PromotionMapper;
|
import com.muyu.product.mapper.PromotionMapper;
|
||||||
|
@ -34,10 +36,6 @@ import java.util.concurrent.Executors;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class ProductServiceImpl implements ProductService {
|
public class ProductServiceImpl implements ProductService {
|
||||||
|
|
||||||
private final Integer min = 0;
|
|
||||||
|
|
||||||
private final Integer max = 5;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductMapper productMapper;
|
private ProductMapper productMapper;
|
||||||
|
|
||||||
|
@ -53,33 +51,51 @@ public class ProductServiceImpl implements ProductService {
|
||||||
private ExecutorService executor = Executors.newFixedThreadPool(3);
|
private ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||||
|
|
||||||
|
|
||||||
public void checkProductParams(ProductReq productReq){
|
// 检查产品参数
|
||||||
CompletableFuture<ValidationResult>methodTypeFuture =
|
public void checkProductParams(ProductReq productReq) {
|
||||||
CompletableFuture.supplyAsync(() -> checkMethodType(productReq),executor);
|
|
||||||
CompletableFuture<ValidationResult>skuIdFuture =
|
|
||||||
CompletableFuture.supplyAsync(() -> findSkuId(productReq),executor);
|
|
||||||
CompletableFuture<ValidationResult>productNumberFuture =
|
|
||||||
CompletableFuture.supplyAsync(() -> checkProductNumber(productReq),executor);
|
|
||||||
CompletableFuture<String>allValidFuture =
|
|
||||||
methodTypeFuture.thenCombine(skuIdFuture,
|
|
||||||
(methodTypeResult,skuIdResult)->
|
|
||||||
methodTypeResult.isValid()&& skuIdResult.isValid())
|
|
||||||
.thenCombine(productNumberFuture,(previousResult,productNumberResult)
|
|
||||||
->previousResult&&productNumberResult.isValid())
|
|
||||||
.thenApply(allValid->allValid ? "所有检查通过":"存在检查未通过")
|
|
||||||
.exceptionally(throwable -> "检验过程发送异常" + throwable.getMessage());
|
|
||||||
|
|
||||||
allValidFuture.thenAccept(System.out::println);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ValidationResult checkProductNumber(ProductReq productReq) {
|
try {
|
||||||
Integer productNumber = productMapper.findProductNumber(productReq);
|
// 异步执行方法类型检查
|
||||||
if(productNumber>=Integer.valueOf(Number.zero.getValue())){
|
CompletableFuture<ValidationResult> methodTypeFuture =
|
||||||
return new ValidationResult(false,"productNumber不能重复");
|
CompletableFuture.supplyAsync(() -> checkMethodType(productReq), executor);
|
||||||
|
// 异步执行查找skuId检查
|
||||||
|
CompletableFuture<ValidationResult> skuIdFuture =
|
||||||
|
CompletableFuture.supplyAsync(() -> findSkuId(productReq), executor);
|
||||||
|
// 异步执行产品编号检查
|
||||||
|
CompletableFuture<ValidationResult> productNumberFuture =
|
||||||
|
CompletableFuture.supplyAsync(() -> checkProductNumber(productReq), executor);
|
||||||
|
|
||||||
|
// 组合所有的异步任务,判断是否所有检查通过
|
||||||
|
CompletableFuture<String> allValidFuture =
|
||||||
|
CompletableFuture.allOf(methodTypeFuture, skuIdFuture, productNumberFuture)
|
||||||
|
.thenApply(ignored -> {
|
||||||
|
boolean allValid = methodTypeFuture.join().isValid()
|
||||||
|
&& skuIdFuture.join().isValid()
|
||||||
|
&& productNumberFuture.join().isValid();
|
||||||
|
return allValid ? "所有检查通过" : "存在检查未通过";
|
||||||
|
})
|
||||||
|
.exceptionally(throwable -> "校验过程发生异常: " + throwable.getMessage());
|
||||||
|
|
||||||
|
// 输出结果
|
||||||
|
allValidFuture.thenAccept(System.out::println);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("校验过程发生异常: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return new ValidationResult(true,"通过");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查产品编号
|
||||||
|
private ValidationResult checkProductNumber(ProductReq productReq) {
|
||||||
|
try {
|
||||||
|
Integer productNumber = productMapper.findProductNumber(String.valueOf(productReq.getProduct().getProductNumber()));
|
||||||
|
if (productNumber < Integer.valueOf(Number.zero.getValue())) {
|
||||||
|
return new ValidationResult(false, "productNumber不能重复");
|
||||||
|
}
|
||||||
|
return new ValidationResult(true, "productNumber检查通过");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new ValidationResult(false, "检查产品编号时发生异常:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
private ValidationResult findSkuId(ProductReq productReq) {
|
private ValidationResult findSkuId(ProductReq productReq) {
|
||||||
Integer skuId = productSkuMapper.findSkuId(productReq.getProductSkus());
|
Integer skuId = productSkuMapper.findSkuId(productReq.getProductSkus());
|
||||||
if(skuId>=Integer.valueOf(Number.zero.getValue())){
|
if(skuId>=Integer.valueOf(Number.zero.getValue())){
|
||||||
|
@ -117,7 +133,7 @@ public class ProductServiceImpl implements ProductService {
|
||||||
|
|
||||||
insertProductPromotion(productReq);
|
insertProductPromotion(productReq);
|
||||||
|
|
||||||
insertProductSku(productReq);
|
// insertProductSku(productReq);
|
||||||
|
|
||||||
log.info("耗时:{}",(System.currentTimeMillis()-start));
|
log.info("耗时:{}",(System.currentTimeMillis()-start));
|
||||||
|
|
||||||
|
@ -134,36 +150,41 @@ public class ProductServiceImpl implements ProductService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductVo queryProductDetails(Integer id) {
|
||||||
|
return productMapper.queryProductDetails(id);
|
||||||
|
}
|
||||||
|
|
||||||
private void insertProductSku(ProductReq productReq) {
|
private void insertProductSku(ProductReq productReq) {
|
||||||
List<ProductSku> productSkuList = productReq.getProductSkus();
|
List<ProductSku> productSkuList = productReq.getProductSkus();
|
||||||
int productId = productReq.getProduct().getId();
|
String createBy = SecurityUtils.getUsername();
|
||||||
|
//批量添加
|
||||||
// 设置商品ID
|
productSkuMapper.insertProductSku(productSkuList,productReq.getProduct().getId(),createBy);
|
||||||
productSkuList.forEach(productSku -> productSku.setProductId(productId));
|
//添加skuAttr除实体类以外的字段
|
||||||
|
ArrayList<ProductSkuAttr> productSkuAttrs = new ArrayList<>();
|
||||||
// 批量添加 productSku
|
productSkuList.forEach(productSkusReq -> {
|
||||||
productSkuMapper.insertProductSku(productSkuList);
|
//获取id
|
||||||
|
//productSkusReq.setProductId(productReq.getProduct().getId());
|
||||||
// 添加 skuAttr
|
//获取map的属性值
|
||||||
List<ProductSkuAttr> productSkuAttrs = new ArrayList<>();
|
ProductSkuNew productSkuNew = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(productSkusReq), ProductSkuNew.class);
|
||||||
productSkuList.forEach(productSku -> {
|
HashMap hashMap = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(productSkuNew), HashMap.class);
|
||||||
// 获取 sku 的属性值
|
Set skuReq = productSkusReq.keySet();
|
||||||
Map<String, Integer> attributes = productSku.getAttributes();
|
Set sku = hashMap.keySet();
|
||||||
|
//添加一个新的set
|
||||||
// 构造 ProductSkuAttr 对象
|
Set set = skuReq;
|
||||||
attributes.forEach((key, value) -> {
|
//去重
|
||||||
|
set.removeAll(sku);
|
||||||
|
//格属性赋值
|
||||||
|
set.forEach(key ->{
|
||||||
ProductSkuAttr productSkuAttr = new ProductSkuAttr();
|
ProductSkuAttr productSkuAttr = new ProductSkuAttr();
|
||||||
productSkuAttr.setSkuId(productSku.getId());
|
productSkuAttr.setSkuId(productSkuNew.getId());
|
||||||
productSkuAttr.setAttrId(Integer.valueOf(key));
|
productSkuAttr.setAttrId(Integer.valueOf(key.toString()));
|
||||||
productSkuAttr.setAttrValueId(value);
|
productSkuAttr.setAttrValueId(Integer.valueOf(productSkusReq.get(key).toString()));
|
||||||
productSkuAttr.setFlag(Integer.valueOf(Number.zero.getValue()));
|
productSkuAttr.setFlag(Integer.valueOf(Number.zero.getValue()));
|
||||||
productSkuAttrs.add(productSkuAttr);
|
productSkuAttrs.add(productSkuAttr);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
//批量添加productSkuAttr
|
||||||
log.info("productSkuAttrs 中的数据为:{}", JSONObject.toJSONString(productSkuAttrs));
|
|
||||||
|
|
||||||
// 批量添加 productSkuAttr
|
|
||||||
productSkuMapper.insertProductSkuAttr(productSkuAttrs);
|
productSkuMapper.insertProductSkuAttr(productSkuAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +235,7 @@ public class ProductServiceImpl implements ProductService {
|
||||||
serviceService.insertProductService(id,serviceIds);
|
serviceService.insertProductService(id,serviceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void insertProduct(Product product) {
|
private void insertProduct(Product product) {
|
||||||
product.setCreateBy(SecurityUtils.getUsername());
|
product.setCreateBy(SecurityUtils.getUsername());
|
||||||
productMapper.insertProduct(product);
|
productMapper.insertProduct(product);
|
||||||
|
|
|
@ -18,6 +18,6 @@ public class ServiceServiceImpl implements ServiceService {
|
||||||
private ServicesMapper servicesMapper;
|
private ServicesMapper servicesMapper;
|
||||||
@Override
|
@Override
|
||||||
public int insertProductService(Integer productId, List<Integer> serviceIds) {
|
public int insertProductService(Integer productId, List<Integer> serviceIds) {
|
||||||
return servicesMapper.insertProductServicep(productId,serviceIds);
|
return servicesMapper.insertProductService(productId,serviceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,13 @@ public class TypeServiceImpl implements TypeService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProductTypeAttr> queryType(Integer flag, Integer id) {
|
public List<ProductTypeAttr> queryType(Integer flag, Integer id) {
|
||||||
return typeMapper.queryType(flag,id);
|
return typeMapper.queryType(flag, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deleteType(Integer typeId) {
|
public Integer deleteType(Integer typeId) {
|
||||||
String name = SecurityUtils.getUsername();
|
String name = SecurityUtils.getUsername();
|
||||||
return typeMapper.deleteType(typeId,name);
|
return typeMapper.deleteType(typeId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,13 +62,18 @@ public class TypeServiceImpl implements TypeService {
|
||||||
public Integer insertTypeAttr(ProductTypeAttrReq productTypeAttrReq) {
|
public Integer insertTypeAttr(ProductTypeAttrReq productTypeAttrReq) {
|
||||||
productTypeAttrReq.setCreateBy(SecurityUtils.getUsername());
|
productTypeAttrReq.setCreateBy(SecurityUtils.getUsername());
|
||||||
Integer res = typeMapper.insertTypeAttr(productTypeAttrReq);
|
Integer res = typeMapper.insertTypeAttr(productTypeAttrReq);
|
||||||
if(res >0 && productTypeAttrReq.getProductTypeAttrValueList().size()>0){
|
|
||||||
|
String[] split = productTypeAttrReq.getProductTypeAttrValueList().split(",");
|
||||||
|
|
||||||
|
if (res > 0) {
|
||||||
Integer typeAttrId = productTypeAttrReq.getId();
|
Integer typeAttrId = productTypeAttrReq.getId();
|
||||||
for (ProductTypeAttrValue productTypeAttrValue : productTypeAttrReq.getProductTypeAttrValueList()) {
|
ProductTypeAttrValue productTypeAttrValue = new ProductTypeAttrValue();
|
||||||
|
for (String s : split) {
|
||||||
productTypeAttrValue.setCreateBy(SecurityUtils.getUsername());
|
productTypeAttrValue.setCreateBy(SecurityUtils.getUsername());
|
||||||
productTypeAttrValue.setTypeAttrId(typeAttrId);
|
productTypeAttrValue.setTypeAttrId(typeAttrId);
|
||||||
|
productTypeAttrValue.setTypeAttrValue(s);
|
||||||
|
typeMapper.insertTypeValue(productTypeAttrValue);
|
||||||
}
|
}
|
||||||
typeMapper.insertTypeValue(productTypeAttrReq.getProductTypeAttrValueList());
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -78,12 +83,16 @@ public class TypeServiceImpl implements TypeService {
|
||||||
productTypeAttrReq.setCreateBy(SecurityUtils.getUsername());
|
productTypeAttrReq.setCreateBy(SecurityUtils.getUsername());
|
||||||
typeMapper.deleteTypeAttrValue(productTypeAttrReq.getId());
|
typeMapper.deleteTypeAttrValue(productTypeAttrReq.getId());
|
||||||
Integer res = typeMapper.updateAttr(productTypeAttrReq);
|
Integer res = typeMapper.updateAttr(productTypeAttrReq);
|
||||||
if(res >0 && productTypeAttrReq.getProductTypeAttrValueList().size()>0){
|
String[] split = productTypeAttrReq.getProductTypeAttrValueList().split(",");
|
||||||
for (ProductTypeAttrValue productTypeAttrValue : productTypeAttrReq.getProductTypeAttrValueList()) {
|
if (res > 0) {
|
||||||
|
Integer typeAttrId = productTypeAttrReq.getId();
|
||||||
|
ProductTypeAttrValue productTypeAttrValue = new ProductTypeAttrValue();
|
||||||
|
for (String s : split) {
|
||||||
productTypeAttrValue.setCreateBy(SecurityUtils.getUsername());
|
productTypeAttrValue.setCreateBy(SecurityUtils.getUsername());
|
||||||
productTypeAttrValue.setTypeAttrId(productTypeAttrReq.getId());
|
productTypeAttrValue.setTypeAttrId(typeAttrId);
|
||||||
|
productTypeAttrValue.setTypeAttrValue(s);
|
||||||
|
typeMapper.insertTypeValue(productTypeAttrValue);
|
||||||
}
|
}
|
||||||
typeMapper.insertTypeValue(productTypeAttrReq.getProductTypeAttrValueList());
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ server:
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: muyu-product
|
name: muyu-product-wxy
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
@ -14,10 +14,13 @@ spring:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 43.142.117.78:8848
|
||||||
|
namespace: 9facbf7b-873b-4e11-b54f-00627208906d
|
||||||
|
ip: 111.231.174.71
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
product_recommended,details_title,details_information,details_key_word,details_remark,
|
product_recommended,details_title,details_information,details_key_word,details_remark,
|
||||||
method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price,images_url,sales
|
method_type,t_product_brand.brand_name,t_product_type.type_name,sale_price,images_url,sales
|
||||||
</sql>
|
</sql>
|
||||||
|
<insert id="insertProduct" useGeneratedKeys="true" keyProperty="id">
|
||||||
<insert id="insertProduct">
|
INSERT INTO `t_product` (
|
||||||
INSERT INTO `product`.`t_Product` (
|
|
||||||
`product_name`,
|
`product_name`,
|
||||||
`product_number`,
|
`product_number`,
|
||||||
`brand_id`,
|
`brand_id`,
|
||||||
`type_id`,
|
`type_id`,
|
||||||
`product_subheading`,
|
`product_subheading`,
|
||||||
|
`product_examine`,
|
||||||
`product_information`,
|
`product_information`,
|
||||||
`product_unit`,
|
`product_unit`,
|
||||||
`product_weight`,
|
`product_weight`,
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
`product_growth`,
|
`product_growth`,
|
||||||
`product_max_points`,
|
`product_max_points`,
|
||||||
`product_foreknow`,
|
`product_foreknow`,
|
||||||
`product_staus`,
|
`product_status`,
|
||||||
`product_new`,
|
`product_new`,
|
||||||
`product_recommended`,
|
`product_recommended`,
|
||||||
`details_title`,
|
`details_title`,
|
||||||
|
@ -37,13 +37,15 @@
|
||||||
`details_remark`,
|
`details_remark`,
|
||||||
`method_type`,
|
`method_type`,
|
||||||
`create_by`,
|
`create_by`,
|
||||||
`create_time`
|
`create_time`,
|
||||||
|
`sales`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{productName},
|
#{productName},
|
||||||
#{productNumber},
|
#{productNumber},
|
||||||
#{brandId},
|
#{brandId},
|
||||||
#{typeId},
|
#{typeId},
|
||||||
#{productSubheading},
|
#{productSubheading},
|
||||||
|
#{productExamine},
|
||||||
#{productInformation},
|
#{productInformation},
|
||||||
#{productUnit},
|
#{productUnit},
|
||||||
#{productWeight},
|
#{productWeight},
|
||||||
|
@ -61,12 +63,12 @@
|
||||||
#{detailsRemark},
|
#{detailsRemark},
|
||||||
#{methodType},
|
#{methodType},
|
||||||
#{createBy},
|
#{createBy},
|
||||||
NOW()
|
NOW(),
|
||||||
);
|
#{sales}
|
||||||
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<update id="updateMothodId">
|
<update id="updateMothodId">
|
||||||
update t_product set method_id =#{methodId} where id = #{id}
|
update t_product set method_id =#{methodId} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
@ -105,13 +107,29 @@
|
||||||
</where>
|
</where>
|
||||||
order by product_sort
|
order by product_sort
|
||||||
</select>
|
</select>
|
||||||
<select id="findProductNumber" resultType="java.lang.Integer">
|
|
||||||
|
|
||||||
|
<select id="findProductNumber" resultType="java.lang.Integer">
|
||||||
|
select count(id) from t_product where id_delete = 1 and product_number = #{productNumber}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryProductDetails" resultType="com.muyu.product.domain.vo.ProductVo">
|
||||||
|
SELECT
|
||||||
|
p.id,
|
||||||
|
product_name,
|
||||||
|
p.product_information,
|
||||||
|
details_title,
|
||||||
|
details_information,
|
||||||
|
brand_name,
|
||||||
|
sale_price,
|
||||||
|
promotion_price,
|
||||||
|
images_url,
|
||||||
|
GROUP_CONCAT( service_name ) service_name ,
|
||||||
|
type_name
|
||||||
|
FROM
|
||||||
|
t_product p
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -9,9 +9,16 @@
|
||||||
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
||||||
|
|
||||||
<insert id="insertProductSku">
|
<insert id="insertProductSku">
|
||||||
|
insert t_product_sku (
|
||||||
insert t_product_sku (id,sale_price,promotion_price,stock,stock_alert
|
id,
|
||||||
,product_id,bg_img,create_time,create_by)
|
sale_price,
|
||||||
|
promotion_price,
|
||||||
|
stock,
|
||||||
|
stock_alert,
|
||||||
|
product_id,
|
||||||
|
bg_img,
|
||||||
|
create_time
|
||||||
|
)
|
||||||
values
|
values
|
||||||
<foreach collection="productSkus" item="productSku" separator=",">
|
<foreach collection="productSkus" item="productSku" separator=",">
|
||||||
(
|
(
|
||||||
|
@ -20,17 +27,16 @@
|
||||||
#{productSku.promotionPrice},
|
#{productSku.promotionPrice},
|
||||||
#{productSku.stock},
|
#{productSku.stock},
|
||||||
#{productSku.stockAlert},
|
#{productSku.stockAlert},
|
||||||
#{productSku.productId},
|
${id},
|
||||||
#{productSku.bgImg},
|
#{productSku.bgImg},
|
||||||
#{productSku.createTime},
|
now()
|
||||||
#{productSku.createBy}
|
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertProductSkuAttr">
|
<insert id="insertProductSkuAttr">
|
||||||
INSERT INTO `product`.`t_product_sku_attr` (
|
INSERT INTO `t_product_sku_attr` (
|
||||||
`sku_id`, `attr_id`, `attr_value_id`, `attr_value`, `flag`, `create_time`, `create_by`
|
`sku_id`, `attr_id`, `attr_value_id`, `attr_value`, `flag`, `create_time`, `create_by`
|
||||||
) VALUES
|
) VALUES
|
||||||
<foreach collection="productSkuAttrs" separator="," item="productSkuAttr">
|
<foreach collection="productSkuAttrs" separator="," item="productSkuAttr">
|
||||||
|
@ -45,12 +51,14 @@
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="findSkuId" resultType="java.lang.Integer">
|
<select id="findSkuId" resultType="java.lang.Integer">
|
||||||
select count(id) from t_product_sku where id in
|
select count(id) from t_product_sku where id_delete = 1 and id in
|
||||||
<foreach collection="productSkus" separator="," open="(" close=")" item="id">
|
<foreach collection="productSkus" separator="," open="(" close=")" item="id">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="querySku" resultType="com.muyu.product.domain.DTO.ProductSku">
|
<select id="querySku" resultType="com.muyu.product.domain.DTO.ProductSku">
|
||||||
select * from t_product_sku
|
select * from t_product_sku
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
( #{memberGold},#{memberSilver},#{memberDiamond},now(),#{createBy} )
|
( #{memberGold},#{memberSilver},#{memberDiamond},now(),#{createBy} )
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertLadder">
|
<insert id="insertLadder">
|
||||||
|
INSERT INTO `t_product_ladder` ( `ladder_num`, `ladder_discount`, `create_time`, `create_by` )
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
#{ladderNum},
|
||||||
|
#{ladderDiscount},
|
||||||
|
now(),
|
||||||
|
#{createBy}
|
||||||
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertPrice">
|
<insert id="insertPrice">
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
|
|
||||||
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
<!-- 添加其他操作方法如插入、更新、删除等 -->
|
||||||
|
|
||||||
<insert id="insertProductServicep">
|
|
||||||
insert t_product_service_middle(product_id,service_id)
|
<insert id="insertProductService">
|
||||||
values
|
insert into t_product_service_middle(product_id, service_id) values (1, 2);
|
||||||
<foreach collection="serviceIds" item="ids" separator=",">
|
|
||||||
(#{id},#{ids})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.product.mapper.TypeMapper">
|
<mapper namespace="com.muyu.product.mapper.TypeMapper">
|
||||||
|
|
||||||
<insert id="insertType">
|
<insert id="insertType">
|
||||||
insert t_product_type(type_name,create_by,create_time) value (#{typeName},#{createBy},now())
|
insert t_product_type(type_name,create_by,create_time) value (#{typeName},#{createBy},now())
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertTypeAttr" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertTypeAttr" useGeneratedKeys="true" keyProperty="id">
|
||||||
INSERT INTO `product`.`t_product_type_attr` (
|
INSERT INTO `product`.`t_product_type_attr` (
|
||||||
`product_type_id`,
|
`product_type_id`,
|
||||||
|
@ -29,7 +31,7 @@
|
||||||
#{productTypeId},
|
#{productTypeId},
|
||||||
#{attrName},
|
#{attrName},
|
||||||
#{multipleChoice},
|
#{multipleChoice},
|
||||||
#{inputMethod},
|
#{input},
|
||||||
#{sort},
|
#{sort},
|
||||||
#{flag},
|
#{flag},
|
||||||
#{screen},
|
#{screen},
|
||||||
|
@ -46,22 +48,23 @@
|
||||||
<insert id="insertTypeValue">
|
<insert id="insertTypeValue">
|
||||||
INSERT INTO `product`.`t_product_type_attr_value` ( `type_attr_id`, `type_attr_value`, `input_method`, `create_time`, `create_by` )
|
INSERT INTO `product`.`t_product_type_attr_value` ( `type_attr_id`, `type_attr_value`, `input_method`, `create_time`, `create_by` )
|
||||||
VALUES
|
VALUES
|
||||||
<foreach collection="productTypeAttrValueList" separator="," item="productTypeAttrValue">
|
|
||||||
(
|
(
|
||||||
#{productTypeAttrValue.typeAttrId},
|
#{typeAttrId},
|
||||||
#{productTypeAttrValue.typeAttrValue},
|
#{typeAttrValue},
|
||||||
#{productTypeAttrValue.inputMethod},
|
#{inputMethod},
|
||||||
now(),
|
now(),
|
||||||
#{productTypeAttrValue.createBy}
|
#{createBy}
|
||||||
)
|
)
|
||||||
</foreach>
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="deleteType">
|
<update id="deleteType">
|
||||||
update t_product_type set id_delete = 0,update_time = now(),create_by=#{name} where id = #{typeId}
|
update t_product_type set id_delete = 0,update_time = now(),create_by=#{name} where id = #{typeId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateType">
|
<update id="updateType">
|
||||||
update t_product_type set type_name = #{typeName},update_time = now(),create_by=#{createBy} where id = #{id}
|
update t_product_type set type_name = #{typeName},update_time = now(),create_by=#{createBy} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateAttr">
|
<update id="updateAttr">
|
||||||
UPDATE `product`.`t_product_type_attr`
|
UPDATE `product`.`t_product_type_attr`
|
||||||
SET `product_type_id` = #{productTypeId},
|
SET `product_type_id` = #{productTypeId},
|
||||||
|
@ -136,6 +139,7 @@
|
||||||
INNER JOIN t_product_type_attr_value tav ON tav.type_attr_id = ta.id
|
INNER JOIN t_product_type_attr_value tav ON tav.type_attr_id = ta.id
|
||||||
where ta.id_delete=1 and ta.flag = #{flag} and t.id = #{id}
|
where ta.id_delete=1 and ta.flag = #{flag} and t.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryTypeAll" resultType="com.muyu.product.domain.Resp.ProductTypeResp">
|
<select id="queryTypeAll" resultType="com.muyu.product.domain.Resp.ProductTypeResp">
|
||||||
SELECT
|
SELECT
|
||||||
t.id,
|
t.id,
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<module>muyu-product-commo</module>
|
<module>muyu-product-commo</module>
|
||||||
<module>muyu-product-remote</module>
|
<module>muyu-product-remote</module>
|
||||||
<module>muyu-product-server</module>
|
<module>muyu-product-server</module>
|
||||||
<module>muyu-product-server</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<artifactId>muyu-rabbit</artifactId>
|
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
|
||||||
<version>5.8.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-test</artifactId>
|
|
||||||
<version>2.7.5</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-test</artifactId>
|
|
||||||
<version>5.3.23</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
|
||||||
<artifactId>nacos-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.rabbit.Consumer;
|
|
||||||
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
||||||
import org.springframework.messaging.handler.annotation.Payload;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: wangxinyuan
|
|
||||||
* @Date: 2024/4/8 21:02
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class MessageReceiver {
|
|
||||||
|
|
||||||
|
|
||||||
@RabbitListener(queues = "DxQueue")
|
|
||||||
public void receiveMessage(@Payload String message) {
|
|
||||||
try {
|
|
||||||
// 手动添加异常代码,模拟消费时的异常情况
|
|
||||||
if (message.contains("error")) {
|
|
||||||
throw new RuntimeException("Simulated error");
|
|
||||||
}
|
|
||||||
System.out.println("Received message: " + message);
|
|
||||||
// 模拟消费成功,打印ack成功日志
|
|
||||||
System.out.println("ACK: Message processed successfully");
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 消费异常,打印失败日志
|
|
||||||
System.err.println("Failed to process message: " + e.getMessage());
|
|
||||||
// 可以选择进行消息的重试或者将消息进行持久化等操作
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.rabbit.Consumer;
|
|
||||||
|
|
||||||
import org.springframework.amqp.core.AmqpTemplate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: wangxinyuan
|
|
||||||
* @Date: 2024/4/8 21:02
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class MessageSender {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AmqpTemplate amqpTemplate;
|
|
||||||
|
|
||||||
public void sendMessage(String message){
|
|
||||||
amqpTemplate.convertAndSend("exchange", "routingKey", message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.muyu.rabbit;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: wangxinyuan
|
|
||||||
* @Date: 2024/4/8 15:06
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class RabbitApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(RabbitApplication.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
package com.muyu.rabbit.util;
|
|
||||||
|
|
||||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RabbitAdmin是RabbitMQ的一个Java客户端库,它提供了管理RabbitMQ资源的功能。它是通过与RabbitMQ服务器进行交互来执行管理操作的。
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class RabbitAdminConfig {
|
|
||||||
|
|
||||||
@Value("${spring.rabbitmq.host}")
|
|
||||||
private String host;
|
|
||||||
@Value("${spring.rabbitmq.username}")
|
|
||||||
private String username;
|
|
||||||
@Value("${spring.rabbitmq.password}")
|
|
||||||
private String password;
|
|
||||||
@Value("${spring.rabbitmq.virtualhost}")
|
|
||||||
private String virtualhost;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建 RabbitMQ的连接工厂
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public ConnectionFactory connectionFactory() {
|
|
||||||
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
|
|
||||||
connectionFactory.setAddresses(host);
|
|
||||||
connectionFactory.setUsername(username);
|
|
||||||
connectionFactory.setPassword(password);
|
|
||||||
connectionFactory.setVirtualHost(virtualhost);
|
|
||||||
// 配置发送确认回调时,次配置必须配置,否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
|
|
||||||
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
|
|
||||||
connectionFactory.setPublisherReturns(true);
|
|
||||||
return connectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自己初始化 RabbitAdmin
|
|
||||||
* @param connectionFactory
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
|
|
||||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
|
||||||
rabbitAdmin.setAutoStartup(true);
|
|
||||||
return rabbitAdmin;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
package com.muyu.rabbit.util.config;
|
|
||||||
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.amqp.core.*;
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @CLassName MqConfig
|
|
||||||
* @Description 描述
|
|
||||||
* @Author Meng.Wang
|
|
||||||
* @Date 2023/11/24 21:15
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@Log4j2
|
|
||||||
public class MqConfig implements RabbitTemplate.ReturnsCallback,RabbitTemplate.ConfirmCallback{
|
|
||||||
public static final String DXQUEUE = "DxQueue";
|
|
||||||
public static final String DXEXCHANGE = "DxExchange";
|
|
||||||
public static final String ROUTINGKEY = "RoutingKey";
|
|
||||||
|
|
||||||
private RabbitTemplate rabbitTemplate;
|
|
||||||
|
|
||||||
//创建消息转换器
|
|
||||||
@Bean
|
|
||||||
public MessageConverter messageConverter(){
|
|
||||||
return new Jackson2JsonMessageConverter();
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建队列
|
|
||||||
@Bean
|
|
||||||
public Queue queue(){
|
|
||||||
return new Queue(DXQUEUE,true);
|
|
||||||
}
|
|
||||||
//创建交换机
|
|
||||||
@Primary
|
|
||||||
@Bean
|
|
||||||
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory){
|
|
||||||
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
|
|
||||||
this.rabbitTemplate = rabbitTemplate;
|
|
||||||
rabbitTemplate.setMessageConverter(messageConverter());
|
|
||||||
rabbitTemplate();
|
|
||||||
return rabbitTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("DxExchange")
|
|
||||||
public DirectExchange directExchange(){
|
|
||||||
return new DirectExchange(DXEXCHANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rabbitTemplate(){
|
|
||||||
rabbitTemplate.setConfirmCallback(this);
|
|
||||||
rabbitTemplate.setReturnsCallback(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Binding binding(){
|
|
||||||
return BindingBuilder.bind(queue()).to(directExchange()).with(ROUTINGKEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void confirm(CorrelationData correlationData, boolean b, String s) {
|
|
||||||
if(b){
|
|
||||||
log.info("{}消息到达交换机",correlationData.getId());
|
|
||||||
}else {
|
|
||||||
log.error("{}消息丢失",correlationData.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void returnedMessage(ReturnedMessage returnedMessage) {
|
|
||||||
log.error("{}消息未到达队列",returnedMessage.getMessage().getMessageProperties().getMessageId());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.rabbit.util.config;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.amqp.core.AmqpTemplate;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: wangxinyuan
|
|
||||||
* @Date: 2024/4/8 20:23
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableRabbit
|
|
||||||
public class RabbitConfig {
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AmqpTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
|
|
||||||
return new RabbitTemplate(connectionFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.muyu.rabbit.util.config;
|
|
||||||
|
|
||||||
import org.springframework.amqp.core.Queue;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: wangxinyuan
|
|
||||||
* @Date: 2024/4/8 21:00
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class RabbitMQConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Queue queue() {
|
|
||||||
return new Queue("queue");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
server:
|
|
||||||
port: 9197
|
|
||||||
spring:
|
|
||||||
datasource:
|
|
||||||
druid:
|
|
||||||
stat-view-servlet:
|
|
||||||
enabled: true
|
|
||||||
loginUsername: admin
|
|
||||||
loginPassword: 123456
|
|
||||||
dynamic:
|
|
||||||
druid:
|
|
||||||
initial-size: 5
|
|
||||||
min-idle: 5
|
|
||||||
maxActive: 20
|
|
||||||
maxWait: 60000
|
|
||||||
timeBetweenEvictionRunsMillis: 60000
|
|
||||||
minEvictableIdleTimeMillis: 300000
|
|
||||||
validationQuery: SELECT 1 FROM DUAL
|
|
||||||
testWhileIdle: true
|
|
||||||
testOnBorrow: false
|
|
||||||
testOnReturn: false
|
|
||||||
poolPreparedStatements: true
|
|
||||||
maxPoolPreparedStatementPerConnectionSize: 20
|
|
||||||
filters: stat,slf4j
|
|
||||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
|
||||||
datasource:
|
|
||||||
# 主库数据源
|
|
||||||
master:
|
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
url: jdbc:mysql://111.231.174.71:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
|
||||||
username: root
|
|
||||||
password: wxy@123
|
|
||||||
# 从库数据源
|
|
||||||
# slave:
|
|
||||||
# username:
|
|
||||||
# password:
|
|
||||||
# url:
|
|
||||||
# driver-class-name:
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
application:
|
|
||||||
name: muyu-rabbit
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
serverAddr: 111.231.174.71:8848
|
|
||||||
config:
|
|
||||||
serverAddr: 111.231.174.71:8848
|
|
||||||
fileExtension: yml
|
|
||||||
shared-configs:
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
rabbitmq:
|
|
||||||
username: guest
|
|
||||||
password: guest
|
|
||||||
virtualHost: /
|
|
||||||
port: 5672
|
|
||||||
host: 111.231.174.71
|
|
||||||
listener:
|
|
||||||
simple:
|
|
||||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
|
||||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
|
||||||
publisher-returns: true #确认消息已发送到队列(Queue)
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
<module>muyu-gen</module>
|
<module>muyu-gen</module>
|
||||||
<module>muyu-job</module>
|
<module>muyu-job</module>
|
||||||
<module>muyu-file</module>
|
<module>muyu-file</module>
|
||||||
|
<module>muyu-product</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
<artifactId>muyu-modules</artifactId>
|
<artifactId>muyu-modules</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@ -22,4 +24,6 @@
|
||||||
muyu-modules业务模块
|
muyu-modules业务模块
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 111.231.174.71:8848
|
server-addr: 111.231.174.71:8848
|
||||||
|
namespace: addbe994-b6ee-4b87-bde0-76f34d2681bd
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
21
pom.xml
21
pom.xml
|
@ -215,8 +215,6 @@
|
||||||
<module>muyu-visual</module>
|
<module>muyu-visual</module>
|
||||||
<module>muyu-modules</module>
|
<module>muyu-modules</module>
|
||||||
<module>muyu-common</module>
|
<module>muyu-common</module>
|
||||||
<module>muyu-modules/muyu-product</module>
|
|
||||||
<module>muyu-modules/muyu-rabbit</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@ -255,22 +253,7 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- 要将源码放上去,需要加入这个插件 -->
|
<!-- 要将源码放上去,需要加入这个插件 -->
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>3.0.1</version>
|
|
||||||
<configuration>
|
|
||||||
<attach>true</attach>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
@ -308,4 +291,6 @@
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue