TASK:mixi;

This commit is contained in:
shahaibo
2024-08-23 16:33:24 +08:00
parent 8f1d8c7b0f
commit 76992a0fb7
13 changed files with 3010 additions and 2812 deletions

View File

@@ -1,10 +1,7 @@
package com.mixi.controller; package com.mixi.controller;
import com.mixi.common.response.Response; import com.mixi.common.response.Response;
import com.mixi.model.dto.AccountLoginDTO; import com.mixi.model.dto.*;
import com.mixi.model.dto.AccountLogoutDTO;
import com.mixi.model.dto.AccountRegisterDTO;
import com.mixi.model.dto.AppAccountLoginDTO;
import com.mixi.model.vo.AccountLoginVO; import com.mixi.model.vo.AccountLoginVO;
import com.mixi.model.vo.AppAccountLoginVO; import com.mixi.model.vo.AppAccountLoginVO;
import com.mixi.model.vo.StoreVO; import com.mixi.model.vo.StoreVO;
@@ -12,11 +9,9 @@ import com.mixi.service.AccountService;
import com.mixi.service.StoreService; import com.mixi.service.StoreService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
@@ -63,6 +58,10 @@ public class AppAccountController {
return Response.success(storeService.queryUserStore(null,null)); 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));
}
} }

View File

@@ -74,6 +74,12 @@ public class AppProductController {
return Response.success(tAppProductService.productColorMatch(query)); 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 = "商品详情") @ApiOperation(value = "商品详情")
@GetMapping("/detail") @GetMapping("/detail")
public Response<ProductVO> detail(@ApiParam(value = "商品id") @RequestParam(value = "id") String id) { public Response<ProductVO> detail(@ApiParam(value = "商品id") @RequestParam(value = "id") String id) {
@@ -118,7 +124,7 @@ public class AppProductController {
@ApiOperation(value = "AI推荐") @ApiOperation(value = "AI推荐")
@PostMapping("/aiRecommend") @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)); return Response.success(tAppProductService.aiRecommend(aiRecommendDTO));
} }

View File

@@ -3,6 +3,7 @@ package com.mixi.mapper;
import com.mixi.common.config.mybatis.plus.CommonMapper; import com.mixi.common.config.mybatis.plus.CommonMapper;
import com.mixi.mapper.entity.MiTuProduct; import com.mixi.mapper.entity.MiTuProduct;
import com.mixi.model.vo.TProductVO;
import java.util.List; import java.util.List;
@@ -17,4 +18,8 @@ public interface MiTuProductMapper extends CommonMapper<MiTuProduct> {
List<MiTuProduct> getTop30ScoreByMemberCode(String memberCode); List<MiTuProduct> getTop30ScoreByMemberCode(String memberCode);
List<MiTuProduct> getTopScoreByMemberCode(String memberCode, List<Long> productIdList); List<MiTuProduct> getTopScoreByMemberCode(String memberCode, List<Long> productIdList);
List<TProductVO> getData();
List<Long> getOtherColorByProductId(Long productId);
} }

View File

@@ -83,6 +83,8 @@ public class TAccount implements Serializable {
@TableField("update_date") @TableField("update_date")
private Date updateDate; private Date updateDate;
// private Long storeId;
/** /**
* ID * ID

View File

@@ -15,11 +15,13 @@ import java.util.List;
@ApiModel("颜色识别") @ApiModel("颜色识别")
public class ProductColorDTO implements Serializable { public class ProductColorDTO implements Serializable {
@ApiModelProperty("商品主色 RGB 值 数组") // @ApiModelProperty("商品主色 RGB 值 数组")
@Size(min = 1,max = 5,message = "Rgb size must be 1 to 5 !") // @Size(min = 1,max = 5,message = "Rgb size must be 1 to 5 !")
@NotEmpty(message = "productRgbList cannot be empty!") // @NotEmpty(message = "productRgbList cannot be empty!")
private List<AppProductColorExtractVO> productRgbList; private List<AppProductColorExtractVO> productRgbList;
private String productColor; private String productColor;
private Long productId;
} }

View 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;
}

View File

@@ -579,9 +579,9 @@ public class PythonService {
.build(); .build();
MediaType mediaType = MediaType.parse("application/json"); MediaType mediaType = MediaType.parse("application/json");
Map<String, Object> content = Maps.newHashMap(); Map<String, Object> content = Maps.newHashMap();
content.put("input_message", "recommend an outfit"); content.put("input_message", "recommend three outfits");
content.put("user_id", aiRecommendDTO.getUserId()); content.put("user_id", "user456");
content.put("image_urls", "http://localhost:5001/chat"); content.put("image_urls", "");
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
Request request = new Request.Builder() Request request = new Request.Builder()

View File

@@ -196,4 +196,14 @@ public class StoreService extends ServiceImpl<TStoreMapper, TStore>{
return tStoreMapper.selectCount(queryWrapper); 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;
}
} }

View File

@@ -739,21 +739,21 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
// @Resource // @Resource
// private MinioUtil minioUtil; // private MinioUtil minioUtil;
public OutfitRecommendation aiRecommend(AIRecommendDTO aiRecommendDTO) { public List<OutfitRecommendation> aiRecommend(AIRecommendDTO aiRecommendDTO) {
// 创建推荐对象 // 创建推荐对象
OutfitRecommendation recommendation = new OutfitRecommendation(); OutfitRecommendation recommendation = new OutfitRecommendation();
// 调用ai推荐模型 // 调用ai推荐模型
JSONObject jsonObject = pythonService.getAIRecommend(aiRecommendDTO); // JSONObject jsonObject = pythonService.getAIRecommend(aiRecommendDTO);
//
// 检查jsonObject是否为null // // 检查jsonObject是否为null
if (jsonObject == null) { // if (jsonObject == null) {
throw new NullPointerException("The response from Python service is null"); // throw new NullPointerException("The response from Python service is null");
} // }
// 从JSON对象中获取output字段 // 从JSON对象中获取output字段
String output = jsonObject.getString("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 - ![Navy Blue Blazer](fashion_items/mitu/MKTS27015_0CMY.jpg)\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 - ![White Silk Blouse](fashion_items/mitu/MKTS27018_0WHT.jpg)\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 - ![Beige Trousers](fashion_items/mitu/MLSS27160_0BGE.jpg)\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 = "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 - ![Navy Blue Blazer](fashion_items/mitu/MKTS27015_0CMY.jpg)\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 - ![White Silk Blouse](fashion_items/mitu/MKTS27018_0WHT.jpg)\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 - ![Beige Trousers](fashion_items/mitu/MLSS27160_0BGE.jpg)\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); List<String> urls = extractBracketContents(output);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
@@ -823,9 +823,14 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
// 设置Markdown内容 // 设置Markdown内容
recommendation.setMarkdownContent(output); recommendation.setMarkdownContent(output);
// recommendation.setMarkdownContent(output + output + output + output + output);
// System.out.println(markdownBuilder.toString().trim()); // 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) { public List<String> extractBracketContents(String input) {
@@ -871,4 +876,36 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
return Boolean.TRUE; 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());
}));
});
}
} }

View File

@@ -710,7 +710,7 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
TProduct tProduct = tProductMapper.selectById(deleteDTO.getId()); TProduct tProduct = tProductMapper.selectById(deleteDTO.getId());
Assert.notNull(tProduct, "Unknown Product!"); Assert.notNull(tProduct, "Unknown Product!");
//删除商品库存 //删除商品库存
tProductStockService.deleteByProductId(deleteDTO.getId()); tProductStockService.deleteByProductId(Long.valueOf(deleteDTO.getId()));
//删除商品标签 //删除商品标签
productLabelService.deleteByProductId(deleteDTO.getId()); productLabelService.deleteByProductId(deleteDTO.getId());
//删除商品搭配 //删除商品搭配
@@ -773,9 +773,11 @@ public class TProductService extends ServiceImpl<TProductMapper, TProduct> {
} }
String itemNameColorCode = originalFilename.substring(0, originalFilename.lastIndexOf('.')); String itemNameColorCode = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
// 根据itemName查询mi-tu商品信息 // 根据itemName查询mi-tu商品信息
String[] split = itemNameColorCode.split("_"); // 根据最后一个"_"分割itemNameColorCode
String itemName = split[0]; int lastUnderscoreIndex = itemNameColorCode.lastIndexOf("_");
String colorCode = split[1];
String itemName = itemNameColorCode.substring(0, lastUnderscoreIndex);
String colorCode = itemNameColorCode.substring(lastUnderscoreIndex + 1);
List<MiTuProduct> miTuProductList = getMiTuProductList(itemName, colorCode); List<MiTuProduct> miTuProductList = getMiTuProductList(itemName, colorCode);
int total = 0; int total = 0;
// for (MiTuProduct miTuProduct : miTuProductList) { // 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); 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<>(); List<MiTuProductStock> miTuProductStockList = new ArrayList<>();
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;

View File

@@ -35,7 +35,7 @@ public class TProductStockService extends ServiceImpl<TProductStockMapper, TProd
private TProductStockMapper tProductStockMapper; private TProductStockMapper tProductStockMapper;
@Transactional @Transactional
public Boolean deleteByProductId(String productId) { public Boolean deleteByProductId(Long productId) {
QueryWrapper<TProductStock> query = new QueryWrapper<>(); QueryWrapper<TProductStock> query = new QueryWrapper<>();
query.eq("product_id",productId); query.eq("product_id",productId);
tProductStockMapper.delete(query); tProductStockMapper.delete(query);

View File

@@ -153,4 +153,38 @@
GROUP BY ps.product_id, ps.price_sales GROUP BY ps.product_id, ps.price_sales
ORDER BY score DESC; ORDER BY score DESC;
</select> </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> </mapper>