bug fix
This commit is contained in:
@@ -3,15 +3,19 @@ package com.peanut.modules.book.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecord;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.book.service.UserFollowUpService;
|
||||
import com.peanut.modules.book.service.UserRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.peanut.common.utils.R.error;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/followUp")
|
||||
public class UserFollowUpController {
|
||||
@@ -25,41 +29,34 @@ public class UserFollowUpController {
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params ){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = userFollowUpService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 我的评价
|
||||
* 我的评价
|
||||
*/
|
||||
@RequestMapping("/Allevaluations")
|
||||
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity){
|
||||
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity) {
|
||||
List<UserFollowUpEntity> userid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("userid", userFollowUpEntity.getUserId()));
|
||||
return R.ok().put("Allevaluations",userid);
|
||||
return R.ok().put("Allevaluations", userid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 全部评价
|
||||
* 全部评价
|
||||
*/
|
||||
@RequestMapping("/Alllevas")
|
||||
public R Alllevas(@RequestBody UserFollowUpEntity users){
|
||||
public R Alllevas(@RequestBody UserFollowUpEntity users) {
|
||||
HashMap<Object, Object> maps = new HashMap<>();
|
||||
List list = new ArrayList<>();
|
||||
List<UserFollowUpEntity> bookid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("bookid", users.getBookid()));
|
||||
@@ -68,67 +65,62 @@ public class UserFollowUpController {
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
Integer userid1 = userRecord.getUserId();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
|
||||
String usser="";
|
||||
String usser = "";
|
||||
String name = "";
|
||||
for (MyUserEntity user : id) {
|
||||
usser = user.getAvatar();
|
||||
name =user.getNickname();
|
||||
usser = user.getAvatar();
|
||||
name = user.getNickname();
|
||||
|
||||
}
|
||||
map.put("Avatar",usser);
|
||||
map.put("name",name);
|
||||
map.put("Avatar", usser);
|
||||
map.put("name", name);
|
||||
map.put("userId", users.getUserId());
|
||||
map.put("bookid",bookid1);
|
||||
map.put("userid",userid1);
|
||||
map.put("content",users.getConTent());
|
||||
map.put("create_date",users.getCreateDate());
|
||||
map.put("oid",users.getOid());
|
||||
map.put("praIse",users.getPraIse());
|
||||
map.put("bookid", bookid1);
|
||||
map.put("userid", userid1);
|
||||
map.put("content", users.getConTent());
|
||||
map.put("create_date", users.getCreateDate());
|
||||
map.put("oid", users.getOid());
|
||||
map.put("praIse", users.getPraIse());
|
||||
|
||||
list.add(map);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
maps.put("list",list);
|
||||
maps.put("list", list);
|
||||
|
||||
return R.ok().put("list",list);
|
||||
return R.ok().put("list", list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 追加评论(用户只可评论一次)
|
||||
*
|
||||
* */
|
||||
@RequestMapping("/userFollowUp")
|
||||
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity ) {
|
||||
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity) {
|
||||
|
||||
|
||||
//根据传过来的userid和oid查询出来userRecordEntity中关联数据
|
||||
UserRecordEntity userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
UserRecord userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>()
|
||||
.eq("userid", userFollowUpEntity.getUserId()).last("LIMIT 1")
|
||||
.eq("bookid", userFollowUpEntity.getBookid())
|
||||
.eq("id",userFollowUpEntity.getOid())
|
||||
.eq("id", userFollowUpEntity.getOid())
|
||||
);
|
||||
if (userRecord==null){
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
if (userRecord == null) {
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
String orderSn = userRecord.getOrderSn();
|
||||
BuyOrder buyOrder =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn",orderSn).last("LIMIT 1")
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", orderSn).last("LIMIT 1")
|
||||
);
|
||||
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
Integer bookid = userRecord.getBookid();
|
||||
Integer userid = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("Order_id", orderId).eq("product_id",bookid));
|
||||
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid",id1).last("LIMIT 1"));
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid", id1).last("LIMIT 1"));
|
||||
|
||||
// if (followUpEntity != null) {
|
||||
// return R.error("您已评价过");
|
||||
@@ -136,11 +128,11 @@ public class UserFollowUpController {
|
||||
|
||||
buyOrder.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
if (userFollowUpEntity.getImages()!=null) {
|
||||
if (userFollowUpEntity.getImages() != null) {
|
||||
|
||||
List<Map<String,String>> imageList = (ArrayList<Map<String,String>>)userFollowUpEntity.getImages();
|
||||
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) userFollowUpEntity.getImages();
|
||||
String imageStr = "";
|
||||
for(Map m : imageList){
|
||||
for (Map m : imageList) {
|
||||
imageStr += m.get("url") + ",";
|
||||
}
|
||||
|
||||
@@ -148,33 +140,30 @@ public class UserFollowUpController {
|
||||
|
||||
}
|
||||
|
||||
userFollowUpEntity.setOid(id1);
|
||||
userFollowUpEntity.setDelflag(0);
|
||||
userFollowUpEntity.setCreateDate(new Date());
|
||||
userFollowUpService.saveOrUpdate(userFollowUpEntity);
|
||||
return R.ok("成功").put("userFollowUpEntity",userFollowUpEntity);
|
||||
}
|
||||
|
||||
|
||||
userFollowUpEntity.setOid(id1);
|
||||
userFollowUpEntity.setDelflag(0);
|
||||
userFollowUpEntity.setCreateDate(new Date());
|
||||
userFollowUpService.saveOrUpdate(userFollowUpEntity);
|
||||
return R.ok("成功").put("userFollowUpEntity", userFollowUpEntity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
UserFollowUpEntity user = userFollowUpService.getById(id);
|
||||
|
||||
return R.ok().put("UserFollowUpEntity", user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserRecordEntity user){
|
||||
public R update(@RequestBody UserRecord user) {
|
||||
userRecordService.updateById(user);
|
||||
|
||||
return R.ok();
|
||||
@@ -184,7 +173,7 @@ public class UserFollowUpController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
userRecordService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
|
||||
@@ -192,4 +181,4 @@ public class UserFollowUpController {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user