通用模块-商品评价

This commit is contained in:
wuchunlei
2024-03-27 17:04:16 +08:00
parent 4fc3835fac
commit 1b1cee0e90
6 changed files with 208 additions and 8 deletions

View File

@@ -0,0 +1,61 @@
package com.peanut.modules.common.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
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 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.Map;
/**
* 商品评价管理
*/
@Slf4j
@RestController("commonShopProductRecord")
@RequestMapping("common/shopProductRecord")
public class ShopProductRecordController {
@Autowired
private ShopProductRecordService recordService;
@RequestMapping("/listByPage")
public R listByPage(@RequestBody Map<String, Object> params) {
MPJLambdaWrapper<ShopProductRecord> wrapper = new MPJLambdaWrapper();
if (params.containsKey("userId")&&StringUtils.isNotEmpty(params.get("userId").toString())) {
wrapper.eq(ShopProductRecord::getUserId,params.get("userId"));
}
if (params.containsKey("productId")&&StringUtils.isNotEmpty(params.get("productId").toString())) {
wrapper.eq(ShopProductRecord::getProductId,params.get("productId"));
}
if (params.containsKey("state")&&StringUtils.isNotEmpty(params.get("state").toString())) {
wrapper.eq(ShopProductRecord::getState,params.get("state"));
}
wrapper.orderByAsc(ShopProductRecord::getCreateTime);
Page<ShopProductRecord> records = recordService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
return R.ok().put("result", records);
}
@RequestMapping("/saveRecord")
public R saveRecord(@RequestBody ShopProductRecord record) {
record.setState(1);
recordService.saveOrUpdate(record);
return R.ok();
}
@RequestMapping("/reSaveRecord")
public R reSaveRecord(@RequestBody ShopProductRecord record) {
recordService.saveOrUpdate(record);
return R.ok();
}
}

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peanut.modules.common.entity.ShopProductRecord;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ShopProductRecordDao extends BaseMapper<ShopProductRecord> {
}

View File

@@ -0,0 +1,66 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 商品评价
*/
@Data
@TableName("shop_product_record")
public class ShopProductRecord implements Serializable {
private static final long serialVersionUID = 1L;
@TableId
private Integer id;
/**
* 商品id
*/
private Integer productId;
/**
* 用户id
*/
private Integer userId;
/**
* 评价内容
*/
private String content;
/**
* 图片
*/
private String images;
/**
* 追评内容
*/
private String reContent;
/**
* 追评图片
*/
private String reImages;
/**
* 创建时间
*/
private Date createTime;
/**
* 评价时间
*/
private Date recordTime;
/**
* 追评时间
*/
private Date reRecordTime;
/**
* 0未评价1已评
*/
private Integer state;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProductRecord;
public interface ShopProductRecordService extends IService<ShopProductRecord> {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductRecordDao;
import com.peanut.modules.common.entity.ShopProductRecord;
import com.peanut.modules.common.service.ShopProductRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonShopProductRecordService")
public class ShopProductRecordServiceImpl extends ServiceImpl<ShopProductRecordDao, ShopProductRecord> implements ShopProductRecordService {
}