From 9d61c8c06be586c3ebdc7f8713f95cc40961dabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E6=AC=A7=EF=BC=88=E6=9E=97=E5=B9=B3=E5=87=A1?= =?UTF-8?q?=EF=BC=89?= Date: Mon, 18 Aug 2025 15:30:02 +0800 Subject: [PATCH] 1 --- .../jarvis/FavoriteProductController.java | 188 ++++++++++ .../jarvis/domain/ErpProductRelation.java | 144 ++++++++ .../ruoyi/jarvis/domain/FavoriteProduct.java | 323 ++++++++++++++++++ .../jarvis/mapper/FavoriteProductMapper.java | 93 +++++ .../service/IFavoriteProductService.java | 136 ++++++++ 5 files changed, 884 insertions(+) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/jarvis/FavoriteProductController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/ErpProductRelation.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/FavoriteProduct.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/jarvis/mapper/FavoriteProductMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/jarvis/service/IFavoriteProductService.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/jarvis/FavoriteProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/jarvis/FavoriteProductController.java new file mode 100644 index 0000000..b6dce45 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/jarvis/FavoriteProductController.java @@ -0,0 +1,188 @@ +package com.ruoyi.web.controller.jarvis; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.jarvis.domain.FavoriteProduct; +import com.ruoyi.jarvis.service.IFavoriteProductService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 常用商品Controller + * + * @author ruoyi + * @date 2024-01-01 + */ +@RestController +@RequestMapping("/jarvis/favoriteProduct") +public class FavoriteProductController extends BaseController +{ + @Autowired + private IFavoriteProductService favoriteProductService; + + /** + * 查询常用商品列表 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:list')") + @GetMapping("/list") + public TableDataInfo list(FavoriteProduct favoriteProduct) + { + startPage(); + List list = favoriteProductService.selectFavoriteProductList(favoriteProduct); + return getDataTable(list); + } + + /** + * 导出常用商品列表 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:export')") + @Log(title = "常用商品", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(FavoriteProduct favoriteProduct) + { + List list = favoriteProductService.selectFavoriteProductList(favoriteProduct); + ExcelUtil util = new ExcelUtil(FavoriteProduct.class); + return util.exportExcel(list, "常用商品数据"); + } + + /** + * 获取常用商品详细信息 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(favoriteProductService.selectFavoriteProductById(id)); + } + + /** + * 新增常用商品 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:add')") + @Log(title = "常用商品", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody FavoriteProduct favoriteProduct) + { + return toAjax(favoriteProductService.insertFavoriteProduct(favoriteProduct)); + } + + /** + * 修改常用商品 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:edit')") + @Log(title = "常用商品", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody FavoriteProduct favoriteProduct) + { + return toAjax(favoriteProductService.updateFavoriteProduct(favoriteProduct)); + } + + /** + * 删除常用商品 + */ + @PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:remove')") + @Log(title = "常用商品", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(favoriteProductService.deleteFavoriteProductByIds(ids)); + } + + /** + * 添加商品到常用列表 + */ + @PostMapping("/addToFavorites") + public AjaxResult addToFavorites(@RequestBody FavoriteProduct favoriteProduct) + { + return toAjax(favoriteProductService.addToFavorites(favoriteProduct)); + } + + /** + * 从常用列表移除商品 + */ + @DeleteMapping("/removeFromFavorites/{skuid}") + public AjaxResult removeFromFavorites(@PathVariable String skuid) + { + return toAjax(favoriteProductService.removeFromFavorites(skuid)); + } + + /** + * 更新置顶状态 + */ + @PutMapping("/updateTopStatus/{id}/{isTop}") + public AjaxResult updateTopStatus(@PathVariable Long id, @PathVariable Integer isTop) + { + return toAjax(favoriteProductService.updateTopStatus(id, isTop)); + } + + /** + * 批量更新置顶状态 + */ + @PutMapping("/batchUpdateTopStatus") + public AjaxResult batchUpdateTopStatus(@RequestBody FavoriteProduct favoriteProduct) + { + // 这里需要从请求体中获取ids和isTop + return toAjax(favoriteProductService.updateTopStatus(favoriteProduct.getId(), favoriteProduct.getIsTop())); + } + + /** + * 根据SKUID查询常用商品 + */ + @GetMapping("/getBySkuid/{skuid}") + public AjaxResult getBySkuid(@PathVariable String skuid) + { + return success(favoriteProductService.selectFavoriteProductBySkuid(skuid)); + } + + /** + * 查询用户的常用商品列表 + */ + @GetMapping("/userFavorites") + public AjaxResult getUserFavorites() + { + Long userId = getUserId(); + List list = favoriteProductService.selectUserFavoriteProducts(userId); + return success(list); + } + + /** + * 根据线报消息创建常用商品 + */ + @PostMapping("/createFromXbMessage") + public AjaxResult createFromXbMessage(@RequestBody Object xbMessageItem) + { + return toAjax(favoriteProductService.createFromXbMessage(xbMessageItem)); + } + + /** + * 快速发品(从常用商品) + */ + @PostMapping("/quickPublish/{id}") + public AjaxResult quickPublish(@PathVariable Long id, @RequestBody String appid) + { + Object result = favoriteProductService.quickPublishFromFavorite(id, appid); + return success(result); + } + + /** + * 更新使用次数和最后使用时间 + */ + @PutMapping("/updateUseCount/{id}") + public AjaxResult updateUseCount(@PathVariable Long id) + { + return toAjax(favoriteProductService.updateUseCountAndTime(id)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/ErpProductRelation.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/ErpProductRelation.java new file mode 100644 index 0000000..310847b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/ErpProductRelation.java @@ -0,0 +1,144 @@ +package com.ruoyi.jarvis.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * ERP商品关联对象 erp_product_relation + * + * @author ruoyi + * @date 2024-01-01 + */ +public class ErpProductRelation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 常用商品ID */ + @Excel(name = "常用商品ID") + private Long favoriteProductId; + + /** ERP应用ID */ + @Excel(name = "ERP应用ID") + private String appid; + + /** ERP商品ID */ + @Excel(name = "ERP商品ID") + private String erpProductId; + + /** ERP商品标题 */ + @Excel(name = "ERP商品标题") + private String erpProductTitle; + + /** ERP商品链接 */ + @Excel(name = "ERP商品链接") + private String erpProductUrl; + + /** ERP商品状态 */ + @Excel(name = "ERP商品状态") + private String erpProductStatus; + + /** 备注 */ + @Excel(name = "备注") + private String remark; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setFavoriteProductId(Long favoriteProductId) + { + this.favoriteProductId = favoriteProductId; + } + + public Long getFavoriteProductId() + { + return favoriteProductId; + } + + public void setAppid(String appid) + { + this.appid = appid; + } + + public String getAppid() + { + return appid; + } + + public void setErpProductId(String erpProductId) + { + this.erpProductId = erpProductId; + } + + public String getErpProductId() + { + return erpProductId; + } + + public void setErpProductTitle(String erpProductTitle) + { + this.erpProductTitle = erpProductTitle; + } + + public String getErpProductTitle() + { + return erpProductTitle; + } + + public void setErpProductUrl(String erpProductUrl) + { + this.erpProductUrl = erpProductUrl; + } + + public String getErpProductUrl() + { + return erpProductUrl; + } + + public void setErpProductStatus(String erpProductStatus) + { + this.erpProductStatus = erpProductStatus; + } + + public String getErpProductStatus() + { + return erpProductStatus; + } + + public void setRemark(String remark) + { + this.remark = remark; + } + + public String getRemark() + { + return remark; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("favoriteProductId", getFavoriteProductId()) + .append("appid", getAppid()) + .append("erpProductId", getErpProductId()) + .append("erpProductTitle", getErpProductTitle()) + .append("erpProductUrl", getErpProductUrl()) + .append("erpProductStatus", getErpProductStatus()) + .append("remark", getRemark()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/FavoriteProduct.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/FavoriteProduct.java new file mode 100644 index 0000000..4c53be2 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/domain/FavoriteProduct.java @@ -0,0 +1,323 @@ +package com.ruoyi.jarvis.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.List; + +/** + * 常用商品对象 favorite_product + * + * @author ruoyi + * @date 2024-01-01 + */ +public class FavoriteProduct extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** SKUID */ + @Excel(name = "SKUID") + private String skuid; + + /** 商品名称 */ + @Excel(name = "商品名称") + private String productName; + + /** 店铺名称 */ + @Excel(name = "店铺名称") + private String shopName; + + /** 店铺ID */ + @Excel(name = "店铺ID") + private String shopId; + + /** 商品链接 */ + @Excel(name = "商品链接") + private String productUrl; + + /** 商品图片 */ + @Excel(name = "商品图片") + private String productImage; + + /** 商品价格 */ + @Excel(name = "商品价格") + private String price; + + /** 佣金信息 */ + @Excel(name = "佣金信息") + private String commissionInfo; + + /** 是否置顶 */ + @Excel(name = "是否置顶", readConverterExp = "0=否,1=是") + private Integer isTop; + + /** 排序权重 */ + @Excel(name = "排序权重") + private Integer sortWeight; + + /** 备注 */ + @Excel(name = "备注") + private String remark; + + /** 创建用户ID */ + @Excel(name = "创建用户ID") + private Long createUserId; + + /** 创建用户名 */ + @Excel(name = "创建用户名") + private String createUserName; + + /** ERP商品ID列表(JSON格式) */ + private String erpProductIds; + + /** ERP商品ID列表(对象形式) */ + private List erpProducts; + + /** 商品分类 */ + @Excel(name = "商品分类") + private String category; + + /** 商品品牌 */ + @Excel(name = "商品品牌") + private String brand; + + /** 最后使用时间 */ + @Excel(name = "最后使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private String lastUsedTime; + + /** 使用次数 */ + @Excel(name = "使用次数") + private Integer useCount; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSkuid(String skuid) + { + this.skuid = skuid; + } + + public String getSkuid() + { + return skuid; + } + + public void setProductName(String productName) + { + this.productName = productName; + } + + public String getProductName() + { + return productName; + } + + public void setShopName(String shopName) + { + this.shopName = shopName; + } + + public String getShopName() + { + return shopName; + } + + public void setShopId(String shopId) + { + this.shopId = shopId; + } + + public String getShopId() + { + return shopId; + } + + public void setProductUrl(String productUrl) + { + this.productUrl = productUrl; + } + + public String getProductUrl() + { + return productUrl; + } + + public void setProductImage(String productImage) + { + this.productImage = productImage; + } + + public String getProductImage() + { + return productImage; + } + + public void setPrice(String price) + { + this.price = price; + } + + public String getPrice() + { + return price; + } + + public void setCommissionInfo(String commissionInfo) + { + this.commissionInfo = commissionInfo; + } + + public String getCommissionInfo() + { + return commissionInfo; + } + + public void setIsTop(Integer isTop) + { + this.isTop = isTop; + } + + public Integer getIsTop() + { + return isTop; + } + + public void setSortWeight(Integer sortWeight) + { + this.sortWeight = sortWeight; + } + + public Integer getSortWeight() + { + return sortWeight; + } + + public void setRemark(String remark) + { + this.remark = remark; + } + + public String getRemark() + { + return remark; + } + + public void setCreateUserId(Long createUserId) + { + this.createUserId = createUserId; + } + + public Long getCreateUserId() + { + return createUserId; + } + + public void setCreateUserName(String createUserName) + { + this.createUserName = createUserName; + } + + public String getCreateUserName() + { + return createUserName; + } + + public void setErpProductIds(String erpProductIds) + { + this.erpProductIds = erpProductIds; + } + + public String getErpProductIds() + { + return erpProductIds; + } + + public List getErpProducts() + { + return erpProducts; + } + + public void setErpProducts(List erpProducts) + { + this.erpProducts = erpProducts; + } + + public void setCategory(String category) + { + this.category = category; + } + + public String getCategory() + { + return category; + } + + public void setBrand(String brand) + { + this.brand = brand; + } + + public String getBrand() + { + return brand; + } + + public void setLastUsedTime(String lastUsedTime) + { + this.lastUsedTime = lastUsedTime; + } + + public String getLastUsedTime() + { + return lastUsedTime; + } + + public void setUseCount(Integer useCount) + { + this.useCount = useCount; + } + + public Integer getUseCount() + { + return useCount; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("skuid", getSkuid()) + .append("productName", getProductName()) + .append("shopName", getShopName()) + .append("shopId", getShopId()) + .append("productUrl", getProductUrl()) + .append("productImage", getProductImage()) + .append("price", getPrice()) + .append("commissionInfo", getCommissionInfo()) + .append("isTop", getIsTop()) + .append("sortWeight", getSortWeight()) + .append("remark", getRemark()) + .append("createUserId", getCreateUserId()) + .append("createUserName", getCreateUserName()) + .append("erpProductIds", getErpProductIds()) + .append("category", getCategory()) + .append("brand", getBrand()) + .append("lastUsedTime", getLastUsedTime()) + .append("useCount", getUseCount()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/mapper/FavoriteProductMapper.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/mapper/FavoriteProductMapper.java new file mode 100644 index 0000000..98d501e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/mapper/FavoriteProductMapper.java @@ -0,0 +1,93 @@ +package com.ruoyi.jarvis.mapper; + +import java.util.List; +import com.ruoyi.jarvis.domain.FavoriteProduct; + +/** + * 常用商品Mapper接口 + * + * @author ruoyi + * @date 2024-01-01 + */ +public interface FavoriteProductMapper +{ + /** + * 查询常用商品 + * + * @param id 常用商品主键 + * @return 常用商品 + */ + public FavoriteProduct selectFavoriteProductById(Long id); + + /** + * 查询常用商品列表 + * + * @param favoriteProduct 常用商品 + * @return 常用商品集合 + */ + public List selectFavoriteProductList(FavoriteProduct favoriteProduct); + + /** + * 新增常用商品 + * + * @param favoriteProduct 常用商品 + * @return 结果 + */ + public int insertFavoriteProduct(FavoriteProduct favoriteProduct); + + /** + * 修改常用商品 + * + * @param favoriteProduct 常用商品 + * @return 结果 + */ + public int updateFavoriteProduct(FavoriteProduct favoriteProduct); + + /** + * 删除常用商品 + * + * @param id 常用商品主键 + * @return 结果 + */ + public int deleteFavoriteProductById(Long id); + + /** + * 批量删除常用商品 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteFavoriteProductByIds(Long[] ids); + + /** + * 根据SKUID查询常用商品 + * + * @param skuid SKUID + * @return 常用商品 + */ + public FavoriteProduct selectFavoriteProductBySkuid(String skuid); + + /** + * 更新使用次数和最后使用时间 + * + * @param id 常用商品ID + * @return 结果 + */ + public int updateUseCountAndTime(Long id); + + /** + * 更新置顶状态和排序权重 + * + * @param favoriteProduct 常用商品 + * @return 结果 + */ + public int updateTopStatus(FavoriteProduct favoriteProduct); + + /** + * 查询用户的常用商品列表(按置顶和排序权重排序) + * + * @param createUserId 创建用户ID + * @return 常用商品集合 + */ + public List selectUserFavoriteProducts(Long createUserId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/IFavoriteProductService.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/IFavoriteProductService.java new file mode 100644 index 0000000..eb2eaff --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/IFavoriteProductService.java @@ -0,0 +1,136 @@ +package com.ruoyi.jarvis.service; + +import java.util.List; +import com.ruoyi.jarvis.domain.FavoriteProduct; + +/** + * 常用商品Service接口 + * + * @author ruoyi + * @date 2024-01-01 + */ +public interface IFavoriteProductService +{ + /** + * 查询常用商品 + * + * @param id 常用商品主键 + * @return 常用商品 + */ + public FavoriteProduct selectFavoriteProductById(Long id); + + /** + * 查询常用商品列表 + * + * @param favoriteProduct 常用商品 + * @return 常用商品集合 + */ + public List selectFavoriteProductList(FavoriteProduct favoriteProduct); + + /** + * 新增常用商品 + * + * @param favoriteProduct 常用商品 + * @return 结果 + */ + public int insertFavoriteProduct(FavoriteProduct favoriteProduct); + + /** + * 修改常用商品 + * + * @param favoriteProduct 常用商品 + * @return 结果 + */ + public int updateFavoriteProduct(FavoriteProduct favoriteProduct); + + /** + * 批量删除常用商品 + * + * @param ids 需要删除的常用商品主键集合 + * @return 结果 + */ + public int deleteFavoriteProductByIds(Long[] ids); + + /** + * 删除常用商品信息 + * + * @param id 常用商品主键 + * @return 结果 + */ + public int deleteFavoriteProductById(Long id); + + /** + * 根据SKUID查询常用商品 + * + * @param skuid SKUID + * @return 常用商品 + */ + public FavoriteProduct selectFavoriteProductBySkuid(String skuid); + + /** + * 添加商品到常用列表 + * + * @param favoriteProduct 常用商品信息 + * @return 结果 + */ + public int addToFavorites(FavoriteProduct favoriteProduct); + + /** + * 从常用列表移除商品 + * + * @param skuid SKUID + * @return 结果 + */ + public int removeFromFavorites(String skuid); + + /** + * 更新使用次数和最后使用时间 + * + * @param id 常用商品ID + * @return 结果 + */ + public int updateUseCountAndTime(Long id); + + /** + * 更新置顶状态 + * + * @param id 常用商品ID + * @param isTop 是否置顶 + * @return 结果 + */ + public int updateTopStatus(Long id, Integer isTop); + + /** + * 批量置顶/取消置顶 + * + * @param ids 常用商品ID数组 + * @param isTop 是否置顶 + * @return 结果 + */ + public int batchUpdateTopStatus(Long[] ids, Integer isTop); + + /** + * 查询用户的常用商品列表(按置顶和排序权重排序) + * + * @param createUserId 创建用户ID + * @return 常用商品集合 + */ + public List selectUserFavoriteProducts(Long createUserId); + + /** + * 根据线报消息创建常用商品 + * + * @param xbMessageItem 线报消息项 + * @return 结果 + */ + public int createFromXbMessage(Object xbMessageItem); + + /** + * 快速发品(从常用商品) + * + * @param id 常用商品ID + * @param appid ERP应用ID + * @return 结果 + */ + public Object quickPublishFromFavorite(Long id, String appid); +}