游客访问接口类
This commit is contained in:
@@ -75,6 +75,7 @@ public class ShiroConfig {
|
||||
filterMap.put("/aaa.txt", "anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
filterMap.put("/cent/**","anon");
|
||||
filterMap.put("/visitor/**","anon");//游客访问接口
|
||||
|
||||
//todo 过滤 用户隐私协议未生效
|
||||
// filterMap.put("sys/agreement/list","anon");
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.peanut.modules.sys.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.dao.ShopProductToLabelDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/visitor")
|
||||
public class VisitorController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private ShopProductToLabelDao shopProductToLabelDao;
|
||||
@Autowired
|
||||
private ShopProductLabelService shopProductLabelService;
|
||||
@Autowired
|
||||
private ShopCategoryService shopCategoryService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ShopProductToLabelService shopProductToLabelService;
|
||||
@Autowired
|
||||
private UserRecordService userRecordService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private UserFollowUpService userFollowUpService;
|
||||
|
||||
//新书
|
||||
@RequestMapping("/getNewBook")
|
||||
public R getNewBook(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopProductService.getNewBook(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表通过标签
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getProductsByLabel")
|
||||
public R getProductsByLabel(@RequestParam Integer splId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
|
||||
shopProductEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
|
||||
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
|
||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
|
||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
|
||||
shopProductEntityMPJLambdaWrapper.eq(ShopProduct::getDelFlag,0);
|
||||
shopProductEntityMPJLambdaWrapper.gt(ShopProduct::getProductStock,0);
|
||||
Page<ShopProduct> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProduct>(page, limit), ShopProduct.class, shopProductEntityMPJLambdaWrapper);
|
||||
return R.ok().put("page",shopProductEntityPage);
|
||||
}
|
||||
|
||||
@RequestMapping("/getLabels")
|
||||
public R getLabels(){
|
||||
List<ShopProductLabelEntity> shopProductLabelEntities = shopProductLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductLabelEntity>()
|
||||
.eq("del_flag",0));
|
||||
Map re = new HashMap();
|
||||
re.put("labels",shopProductLabelEntities);
|
||||
return R.ok().put("result",re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/info/{productId}")
|
||||
public R info(@PathVariable("productId") Integer productId) {
|
||||
ShopProduct shopProduct = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProduct>().eq("product_id", productId).eq("del_flag", 0));
|
||||
if (shopProduct == null) {
|
||||
return R.error("该商品已下架,看看其他商品吧");
|
||||
}
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
|
||||
Integer poid = shopProduct.getProductPid();
|
||||
Integer productId1 = shopProduct.getProductId();
|
||||
List<Integer> poids = shopCategoryService.findPoid(poid);
|
||||
shopProduct.setPoids(poids);
|
||||
List<Object> list = new ArrayList<>();
|
||||
List<Object> bookIdlist = new ArrayList<>();
|
||||
ArrayList<String> booklist = new ArrayList<>();
|
||||
List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
|
||||
.eq("product_id", productId1));
|
||||
for (ShopProductBookEntity shopProductBookEntity : product) {
|
||||
Integer id = shopProductBookEntity.getId();
|
||||
Integer bookId = shopProductBookEntity.getBookId();
|
||||
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
bookIdlist.add(id);
|
||||
booklist.add(String.valueOf(bookId));
|
||||
list.add(byId);
|
||||
}
|
||||
//添加获取标签逻辑
|
||||
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
|
||||
.eq("product_id", productId).eq("del_flag", 0));
|
||||
List labelList = new ArrayList();
|
||||
for (ShopProductToLabelEntity sp : shopProductToLabelEntities) {
|
||||
labelList.add(sp.getSplId());
|
||||
}
|
||||
shopProduct.setBookidsimages(list);
|
||||
shopProduct.setBookids(booklist);
|
||||
shopProduct.setShoproudIds(bookIdlist);
|
||||
return R.ok().put("shopProduct", shopProduct).put("labels", labelList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看全部评价
|
||||
*/
|
||||
@RequestMapping("/All")
|
||||
public R All(@RequestBody UserRecord userRecordEntity) {
|
||||
List list = new ArrayList<>();
|
||||
//此处bookid实际传的是商品id
|
||||
List<UserRecord> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
|
||||
if (bookid != null) {
|
||||
for (UserRecord userRecord : bookid) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
Integer userid1 = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
|
||||
String usser = "";
|
||||
String name = "";
|
||||
for (MyUserEntity user : id) {
|
||||
usser = user.getAvatar();
|
||||
name = user.getNickname();
|
||||
}
|
||||
List<UserFollowUpEntity> followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>()
|
||||
.eq("oid", id1)
|
||||
.eq("userId", userid1)
|
||||
.orderByDesc("create_date"));
|
||||
String conTent = "";
|
||||
Date date = null;
|
||||
for (UserFollowUpEntity followUp : followUpEntity) {
|
||||
conTent = followUp.getConTent();
|
||||
date = followUp.getCreateDate();
|
||||
}
|
||||
map.put("followUpdate", date);
|
||||
map.put("followUpcontent", conTent);
|
||||
map.put("avatar", usser);
|
||||
map.put("name", name);
|
||||
map.put("bookid", bookid1);
|
||||
map.put("orderSn", userRecord.getOrderSn());
|
||||
map.put("userid", userid1);
|
||||
map.put("content", userRecord.getContent());
|
||||
map.put("images", userRecord.getImages());
|
||||
map.put("starlevel", userRecord.getStarLevel());
|
||||
map.put("createdate", userRecord.getCreateDate());
|
||||
list.add(map);
|
||||
}
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
return R.error("该商品暂无评论");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user