TASK:mixi;
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,7 @@
|
||||
package com.mixi.controller;
|
||||
|
||||
import com.mixi.common.response.Response;
|
||||
import com.mixi.model.dto.AccountLoginDTO;
|
||||
import com.mixi.model.dto.AccountLogoutDTO;
|
||||
import com.mixi.model.dto.AccountRegisterDTO;
|
||||
import com.mixi.model.dto.AppAccountLoginDTO;
|
||||
import com.mixi.model.dto.*;
|
||||
import com.mixi.model.vo.AccountLoginVO;
|
||||
import com.mixi.model.vo.AppAccountLoginVO;
|
||||
import com.mixi.model.vo.StoreVO;
|
||||
@@ -12,11 +9,9 @@ import com.mixi.service.AccountService;
|
||||
import com.mixi.service.StoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
@@ -63,6 +58,10 @@ public class AppAccountController {
|
||||
return Response.success(storeService.queryUserStore(null,null));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "setCommonStore")
|
||||
@PostMapping("/setCommonStore")
|
||||
public Response<Boolean> setCommonStore(@ApiParam(value = "店铺ID") @RequestParam(value = "id") Long id) {
|
||||
return Response.success(storeService.setCommonStore(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,6 +74,12 @@ public class AppProductController {
|
||||
return Response.success(tAppProductService.productColorMatch(query));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商品其他颜色")
|
||||
@PostMapping("/productOtherColor")
|
||||
public Response<List<AppNewProductVO>> productOtherColor(@Valid @RequestBody ProductColorDTO query) {
|
||||
return Response.success(tAppProductService.productOtherColor(query));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "商品详情")
|
||||
@GetMapping("/detail")
|
||||
public Response<ProductVO> detail(@ApiParam(value = "商品id") @RequestParam(value = "id") String id) {
|
||||
@@ -118,7 +124,7 @@ public class AppProductController {
|
||||
|
||||
@ApiOperation(value = "AI推荐")
|
||||
@PostMapping("/aiRecommend")
|
||||
public Response<OutfitRecommendation> aiRecommend(@Valid @RequestBody AIRecommendDTO aiRecommendDTO) {
|
||||
public Response<List<OutfitRecommendation>> aiRecommend(@Valid @RequestBody AIRecommendDTO aiRecommendDTO) {
|
||||
return Response.success(tAppProductService.aiRecommend(aiRecommendDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mixi.mapper;
|
||||
|
||||
import com.mixi.common.config.mybatis.plus.CommonMapper;
|
||||
import com.mixi.mapper.entity.MiTuProduct;
|
||||
import com.mixi.model.vo.TProductVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,4 +18,8 @@ public interface MiTuProductMapper extends CommonMapper<MiTuProduct> {
|
||||
List<MiTuProduct> getTop30ScoreByMemberCode(String memberCode);
|
||||
|
||||
List<MiTuProduct> getTopScoreByMemberCode(String memberCode, List<Long> productIdList);
|
||||
|
||||
List<TProductVO> getData();
|
||||
|
||||
List<Long> getOtherColorByProductId(Long productId);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ public class TAccount implements Serializable {
|
||||
@TableField("update_date")
|
||||
private Date updateDate;
|
||||
|
||||
// private Long storeId;
|
||||
|
||||
|
||||
/**
|
||||
* ID
|
||||
|
||||
@@ -15,11 +15,13 @@ import java.util.List;
|
||||
@ApiModel("颜色识别")
|
||||
public class ProductColorDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty("商品主色 RGB 值 数组")
|
||||
@Size(min = 1,max = 5,message = "Rgb size must be 1 to 5 !")
|
||||
@NotEmpty(message = "productRgbList cannot be empty!")
|
||||
// @ApiModelProperty("商品主色 RGB 值 数组")
|
||||
// @Size(min = 1,max = 5,message = "Rgb size must be 1 to 5 !")
|
||||
// @NotEmpty(message = "productRgbList cannot be empty!")
|
||||
private List<AppProductColorExtractVO> productRgbList;
|
||||
|
||||
private String productColor;
|
||||
|
||||
private Long productId;
|
||||
|
||||
}
|
||||
|
||||
11
src/main/java/com/mixi/model/vo/TProductVO.java
Normal file
11
src/main/java/com/mixi/model/vo/TProductVO.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.mixi.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TProductVO {
|
||||
private Long productId;
|
||||
private String itemGroup;
|
||||
private String subGroup;
|
||||
private String pictureName;
|
||||
}
|
||||
@@ -579,9 +579,9 @@ public class PythonService {
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
Map<String, Object> content = Maps.newHashMap();
|
||||
content.put("input_message", "recommend an outfit");
|
||||
content.put("user_id", aiRecommendDTO.getUserId());
|
||||
content.put("image_urls", "http://localhost:5001/chat");
|
||||
content.put("input_message", "recommend three outfits");
|
||||
content.put("user_id", "user456");
|
||||
content.put("image_urls", "");
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
Request request = new Request.Builder()
|
||||
|
||||
@@ -196,4 +196,14 @@ public class StoreService extends ServiceImpl<TStoreMapper, TStore>{
|
||||
return tStoreMapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
public Boolean setCommonStore(Long id) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
TAccount tAccount = accountMapper.selectById(userHolder.getId());
|
||||
// tAccount.setStoreId(id);
|
||||
accountMapper.updateById(tAccount);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,21 +739,21 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
// @Resource
|
||||
// private MinioUtil minioUtil;
|
||||
|
||||
public OutfitRecommendation aiRecommend(AIRecommendDTO aiRecommendDTO) {
|
||||
public List<OutfitRecommendation> aiRecommend(AIRecommendDTO aiRecommendDTO) {
|
||||
// 创建推荐对象
|
||||
OutfitRecommendation recommendation = new OutfitRecommendation();
|
||||
|
||||
// 调用ai推荐模型
|
||||
JSONObject jsonObject = pythonService.getAIRecommend(aiRecommendDTO);
|
||||
|
||||
// 检查jsonObject是否为null
|
||||
if (jsonObject == null) {
|
||||
throw new NullPointerException("The response from Python service is null");
|
||||
}
|
||||
// JSONObject jsonObject = pythonService.getAIRecommend(aiRecommendDTO);
|
||||
//
|
||||
// // 检查jsonObject是否为null
|
||||
// if (jsonObject == null) {
|
||||
// throw new NullPointerException("The response from Python service is null");
|
||||
// }
|
||||
|
||||
// 从JSON对象中获取output字段
|
||||
String output = jsonObject.getString("output");
|
||||
// String output = "I have a great outfit recommendation for you! Here are the details:\n\n### Recommended Outfit:\n1. **Tailored Navy Blue Blazer**\n - **Description**: A single-breasted design with notched lapels and a slim fit. Features two front flap pockets and a single button closure. Made from a wool blend for a structured yet comfortable feel.\n - \n\n2. **White Silk Blouse**\n - **Description**: A classic collar, button-down front, and long sleeves with buttoned cuffs. Slightly loose fit for a sophisticated and airy look.\n - \n\n3. **High-Waisted Beige Trousers**\n - **Description**: Straight-leg trousers in a light beige color. Clean front with a concealed hook-and-bar closure, side pockets, and a slightly cropped length to show off the ankles.\n - \n\n### Reasons for Recommendation:\n- **Parisian Chic Theme**: Classic and versatile pieces that embody sophistication and elegance.\n- **Navy Blue Blazer**: Adds a touch of structure, perfect for various occasions.\n- **White Silk Blouse**: A timeless staple that pairs well with the blazer.\n- **High-Waisted Beige Trousers**: Neutral base that complements the navy and white, creating a balanced and polished ensemble.\n\nThis combination is ideal for general use and can be dressed up or down depending on the occasion. Enjoy your new look!";
|
||||
// String output = jsonObject.getString("output");
|
||||
String output = "I have a great outfit recommendation for you! Here are the details:\n\n### Recommended Outfit:\n1. **Tailored Navy Blue Blazer**\n - **Description**: A single-breasted design with notched lapels and a slim fit. Features two front flap pockets and a single button closure. Made from a wool blend for a structured yet comfortable feel.\n - \n\n2. **White Silk Blouse**\n - **Description**: A classic collar, button-down front, and long sleeves with buttoned cuffs. Slightly loose fit for a sophisticated and airy look.\n - \n\n3. **High-Waisted Beige Trousers**\n - **Description**: Straight-leg trousers in a light beige color. Clean front with a concealed hook-and-bar closure, side pockets, and a slightly cropped length to show off the ankles.\n - \n\n### Reasons for Recommendation:\n- **Parisian Chic Theme**: Classic and versatile pieces that embody sophistication and elegance.\n- **Navy Blue Blazer**: Adds a touch of structure, perfect for various occasions.\n- **White Silk Blouse**: A timeless staple that pairs well with the blazer.\n- **High-Waisted Beige Trousers**: Neutral base that complements the navy and white, creating a balanced and polished ensemble.\n\nThis combination is ideal for general use and can be dressed up or down depending on the occasion. Enjoy your new look!";
|
||||
|
||||
List<String> urls = extractBracketContents(output);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
@@ -823,9 +823,14 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
|
||||
// 设置Markdown内容
|
||||
recommendation.setMarkdownContent(output);
|
||||
|
||||
// recommendation.setMarkdownContent(output + output + output + output + output);
|
||||
// System.out.println(markdownBuilder.toString().trim());
|
||||
return recommendation;
|
||||
List<OutfitRecommendation> result = new ArrayList<>();
|
||||
result.add(recommendation);
|
||||
result.add(recommendation);
|
||||
result.add(recommendation);
|
||||
result.add(recommendation);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> extractBracketContents(String input) {
|
||||
@@ -871,4 +876,36 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
public List<AppNewProductVO> productOtherColor(ProductColorDTO query) {
|
||||
List<Long> productIdList = miTuProductMapper.getOtherColorByProductId(query.getProductId());
|
||||
if (CollectionUtils.isEmpty(productIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
QueryWrapper<TProduct> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(TProduct::getId, productIdList);
|
||||
List<TProduct> dataBase = productMapper.selectList(qw);
|
||||
Map<Long,String> productIdToUrlMap =
|
||||
CollectionUtil.emptyIfNull(dataBase).stream().collect(Collectors.toMap(TProduct::getId,TProduct::getPictureUrl));
|
||||
|
||||
Map<Long,List<TProductLabel>> productToLabelMap = productLabelService.findByProductIds(dataBase.stream().map(TProduct::getId).collect(Collectors.toList()));
|
||||
List<Long> labelIds = productToLabelMap.values()
|
||||
.stream()
|
||||
.map(list->list.stream().map(TProductLabel::getLabelId).collect(Collectors.toList()))
|
||||
.flatMap(List::stream).collect(Collectors.toList());
|
||||
//标签map
|
||||
Map<Long,TLabel> labelMap = labelService.queryMapByIds(labelIds);
|
||||
return CopyUtil.copyList(dataBase,AppNewProductVO.class,(oo,dd)->{
|
||||
dd.setId(oo.getId().toString());
|
||||
dd.setPictureUrl(productIdToUrlMap.get(oo.getId()));
|
||||
dd.setPictureUrl(minioUtil.getPresignedUrl(dd.getPictureUrl(), 24 * 60));
|
||||
dd.setProductLabelInfo(CopyUtil.copyList(productToLabelMap.get(oo.getId()),ProductLabelVO.class,(o,d) ->{
|
||||
d.setId(o.getLabelId().toString());
|
||||
d.setName(labelMap.get(o.getLabelId()).getName());
|
||||
d.setType(labelMap.get(o.getLabelId()).getType());
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
TProduct tProduct = tProductMapper.selectById(deleteDTO.getId());
|
||||
Assert.notNull(tProduct, "Unknown Product!");
|
||||
//删除商品库存
|
||||
tProductStockService.deleteByProductId(deleteDTO.getId());
|
||||
tProductStockService.deleteByProductId(Long.valueOf(deleteDTO.getId()));
|
||||
//删除商品标签
|
||||
productLabelService.deleteByProductId(deleteDTO.getId());
|
||||
//删除商品搭配
|
||||
@@ -773,9 +773,11 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
}
|
||||
String itemNameColorCode = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
|
||||
// 根据itemName查询mi-tu商品信息
|
||||
String[] split = itemNameColorCode.split("_");
|
||||
String itemName = split[0];
|
||||
String colorCode = split[1];
|
||||
// 根据最后一个"_"分割itemNameColorCode
|
||||
int lastUnderscoreIndex = itemNameColorCode.lastIndexOf("_");
|
||||
|
||||
String itemName = itemNameColorCode.substring(0, lastUnderscoreIndex);
|
||||
String colorCode = itemNameColorCode.substring(lastUnderscoreIndex + 1);
|
||||
List<MiTuProduct> miTuProductList = getMiTuProductList(itemName, colorCode);
|
||||
int total = 0;
|
||||
// for (MiTuProduct miTuProduct : miTuProductList) {
|
||||
@@ -852,7 +854,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
|
||||
return new TProductSingleUploadVo(saveProduct.getId().toString(), minioUtil.getPresignedUrl(minioFullPath, 24 * 60), itemNameColorCode, md5);
|
||||
}
|
||||
|
||||
private List<MiTuProductStock> getMiTuProductStock(String pluCode, String color) {
|
||||
public List<MiTuProductStock> getMiTuProductStock(String pluCode, String color) {
|
||||
List<MiTuProductStock> miTuProductStockList = new ArrayList<>();
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TProductStockService extends ServiceImpl<TProductStockMapper, TProd
|
||||
private TProductStockMapper tProductStockMapper;
|
||||
|
||||
@Transactional
|
||||
public Boolean deleteByProductId(String productId) {
|
||||
public Boolean deleteByProductId(Long productId) {
|
||||
QueryWrapper<TProductStock> query = new QueryWrapper<>();
|
||||
query.eq("product_id",productId);
|
||||
tProductStockMapper.delete(query);
|
||||
|
||||
@@ -153,4 +153,38 @@
|
||||
GROUP BY ps.product_id, ps.price_sales
|
||||
ORDER BY score DESC;
|
||||
</select>
|
||||
|
||||
<select id="getData" resultType="com.mixi.model.vo.TProductVO">
|
||||
WITH a as (SELECT
|
||||
product_id,
|
||||
item_group,
|
||||
sub_group
|
||||
FROM
|
||||
`mi_tu_product`
|
||||
GROUP BY
|
||||
product_id,
|
||||
item_group,
|
||||
sub_group)
|
||||
SELECT
|
||||
a.*,
|
||||
b.picture_name
|
||||
FROM a, t_product b
|
||||
WHERE a.product_id = b.id
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getOtherColorByProductId" resultType="java.lang.Long">
|
||||
SELECT
|
||||
product_id
|
||||
FROM
|
||||
mi_tu_product
|
||||
WHERE plu_code = (SELECT
|
||||
plu_code
|
||||
FROM
|
||||
mi_tu_product
|
||||
WHERE product_id = #{productId}
|
||||
LIMIT 1)
|
||||
AND product_id != #{productId}
|
||||
GROUP BY product_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user