通用模块-商品评价
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user