通用模块-商品评价
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
Reference in New Issue
Block a user