通用模块-商品评价
This commit is contained in:
@@ -86,11 +86,33 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateLabel")
|
||||
public R saveOrUpdateLabel(@RequestBody ShopProductBookLabel label) {
|
||||
if (label.getIsLast()==1){
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
if (label.getId()==null){
|
||||
if(label.getPid()==0){
|
||||
labelService.save(label);
|
||||
return R.ok().put("result",label);
|
||||
}else {
|
||||
ShopProductBookLabel l = labelService.getById(label.getPid());
|
||||
if (l.getIsLast()==1){
|
||||
return R.error("请将父标签设置为非最后一集");
|
||||
}else {
|
||||
labelService.save(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return R.error("父标签非最后一集");
|
||||
if (label.getIsLast() == 1){
|
||||
List llast = labelService.list(new LambdaQueryWrapper<ShopProductBookLabel>()
|
||||
.eq(ShopProductBookLabel::getPid,label.getId()));
|
||||
if (llast.size()>0){
|
||||
return R.error("请先删除子集,再设置为最后一集");
|
||||
}else {
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}else {
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,11 +141,33 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody ShopProductBookMarket market) {
|
||||
if (market.getIsLast()==1){
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
if (market.getId()==null){
|
||||
if(market.getPid()==0){
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
ShopProductBookMarket m = marketService.getById(market.getPid());
|
||||
if (m.getIsLast()==1){
|
||||
return R.error("请将父标签设置为非最后一集");
|
||||
}else {
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return R.error("父标签非最后一集");
|
||||
if (market.getIsLast() == 1){
|
||||
List mList = marketService.list(new LambdaQueryWrapper<ShopProductBookMarket>()
|
||||
.eq(ShopProductBookMarket::getPid,market.getId()));
|
||||
if (mList.size()>0){
|
||||
return R.error("请先删除子集,再设置为最后一集");
|
||||
}else {
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}else {
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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