通用模块-商品评价

This commit is contained in:
wuchunlei
2024-03-28 10:29:29 +08:00
parent c0431f7280
commit e92dfa8b13
4 changed files with 50 additions and 13 deletions

View File

@@ -6,13 +6,15 @@ import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.entity.ShopProductRecord;
import com.peanut.modules.common.service.ShopProductRecordService;
import com.peanut.modules.master.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@@ -25,6 +27,8 @@ public class ShopProductRecordController {
@Autowired
private ShopProductRecordService recordService;
@Autowired
private ShopProductService productService;
@RequestMapping("/listByPage")
public R listByPage(@RequestBody Map<String, Object> params) {
@@ -41,11 +45,19 @@ public class ShopProductRecordController {
wrapper.orderByAsc(ShopProductRecord::getCreateTime);
Page<ShopProductRecord> records = recordService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
List<ShopProductRecord> result = records.getRecords();
if (result.size() > 0) {
for (ShopProductRecord record:result){
ShopProduct product = productService.getById(record.getProductId());
record.setProduct(product);
}
}
return R.ok().put("result", records);
}
@RequestMapping("/saveRecord")
public R saveRecord(@RequestBody ShopProductRecord record) {
record.setRecordTime(new Date());
record.setState(1);
recordService.saveOrUpdate(record);
return R.ok();
@@ -53,6 +65,7 @@ public class ShopProductRecordController {
@RequestMapping("/reSaveRecord")
public R reSaveRecord(@RequestBody ShopProductRecord record) {
record.setReRecordTime(new Date());
recordService.saveOrUpdate(record);
return R.ok();
}

View File

@@ -1,5 +1,6 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -63,4 +64,7 @@ public class ShopProductRecord implements Serializable {
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private ShopProduct product;
}