refactor code
This commit is contained in:
@@ -1,144 +0,0 @@
|
||||
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.BookClockinCommentEntity;
|
||||
import com.peanut.modules.book.entity.BookClockInEntity;
|
||||
import com.peanut.modules.book.entity.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.service.BookClockinCommentService;
|
||||
import com.peanut.modules.book.service.BookClockinPunchService;
|
||||
import com.peanut.modules.book.service.BookClockInService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 签到信息用户评论
|
||||
*
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("clockin/comment")
|
||||
public class BookClockinCommentController {
|
||||
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
|
||||
/**
|
||||
* 列表 倒叙
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = bookClockinCommentService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
BookClockinCommentEntity commentEntity = bookClockinCommentService.getById(id);
|
||||
|
||||
return R.ok().put("commentEntity", commentEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockinCommentEntity clockinComment){
|
||||
Integer bookid1 = clockinComment.getBookId();
|
||||
Integer userId = clockinComment.getUserId();
|
||||
Integer taskId = clockinComment.getTaskId();
|
||||
|
||||
|
||||
BookClockinCommentEntity bookClockinCommentEntity = bookClockinCommentService.getBaseMapper().selectOne(new QueryWrapper<BookClockinCommentEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("task_id", taskId)
|
||||
|
||||
);
|
||||
BookClockinPunchEntity ClockinCommen = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("t_id", taskId)
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (bookClockinCommentEntity !=null) {
|
||||
return R.error("该信息允许发布一条内容,请勿重复发布");
|
||||
}
|
||||
|
||||
if (ClockinCommen!=null) {
|
||||
clockinComment.setPid(1);
|
||||
}
|
||||
|
||||
bookClockinCommentService.save(clockinComment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/replysave")
|
||||
public R replysave(@RequestBody BookClockinCommentEntity clockinComment) {
|
||||
Integer bookid = clockinComment.getBookId();
|
||||
Integer userId = clockinComment.getUserId();
|
||||
Integer pid = clockinComment.getPid();
|
||||
BookClockInEntity bookClockinEntity = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("id",pid)
|
||||
);
|
||||
clockinComment.setDelFlag(0);
|
||||
bookClockinCommentService.save(clockinComment);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockinCommentEntity clockinComment){
|
||||
|
||||
bookClockinCommentService.updateById(clockinComment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
bookClockinCommentService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.*;
|
||||
/**
|
||||
* 签到内容信息
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/clockin")
|
||||
public class BookClockinController {
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
@Autowired
|
||||
private BookTaskService bookTaskService;
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
/**
|
||||
* 列表 app post请求
|
||||
*/
|
||||
@RequestMapping("/applistSS")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看全部评价
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam("bookid") String bookid,
|
||||
@RequestParam("taskid") String taskid) {
|
||||
|
||||
List<BookClockInEntity> bookClockinEntityList = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookid).eq("task_id", taskid));
|
||||
List list = new ArrayList<>();
|
||||
for (BookClockInEntity bookClockinEntity : bookClockinEntityList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String name = "";
|
||||
String avatar="";
|
||||
Integer id2 =null;
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer taskId = bookClockinEntity.getTaskId();
|
||||
Integer bookId = bookClockinEntity.getBookId();
|
||||
String conTent = bookClockinEntity.getContent();
|
||||
Integer id1 = bookClockinEntity.getId();
|
||||
String images = (String)bookClockinEntity.getImages();
|
||||
Date createTime = bookClockinEntity.getCreateTime();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : id) {
|
||||
name = user.getNickname();
|
||||
id2 = user.getId();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
//评论信息
|
||||
map.put("userid", id2);
|
||||
map.put("name", name);
|
||||
map.put("avatar", avatar);
|
||||
map.put("bookid", bookId);
|
||||
map.put("taskId", taskId);
|
||||
map.put("content", conTent);
|
||||
map.put("images", images);
|
||||
map.put("createdate", createTime);
|
||||
list.add(map);
|
||||
}
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表 后台get请求
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
BookClockInEntity bookClockinEntity = bookClockinService.getById(id);
|
||||
return R.ok().put("bookBuyConfig", bookClockinEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockInEntity bookClockinEntity) {
|
||||
|
||||
Integer bookId = bookClockinEntity.getBookId();
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer taskId = bookClockinEntity.getTaskId();
|
||||
Integer dayId = bookClockinEntity.getDayId();
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.eq("t_id", taskId)
|
||||
.eq("days", dayId)
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookClockinPunchEntity==null) {
|
||||
return R.error("当天打卡内容未发布");
|
||||
}
|
||||
BookClockInEntity bookClockin = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.eq("task_id", taskId)
|
||||
.eq("day_id", dayId)
|
||||
.eq("user_id", userId)
|
||||
);
|
||||
if (bookClockin!=null) {
|
||||
return R.error("您已参与第"+dayId+"天签到评论");
|
||||
}
|
||||
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) bookClockinEntity.getImageeStrings();
|
||||
String imageStr = "";
|
||||
for (Map m : imageList) {
|
||||
imageStr += m.get("url") + ",";
|
||||
|
||||
}
|
||||
|
||||
if (imageStr!=null &&!imageStr.isEmpty()){
|
||||
String substring = imageStr.substring(0, imageStr.length() - 1);
|
||||
bookClockinEntity.setImages(substring);
|
||||
}else {
|
||||
bookClockinEntity.setImages("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bookClockinEntity.setDelFlag(0);
|
||||
bookClockinService.save(bookClockinEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockInEntity bookClockinEntity) {
|
||||
bookClockinService.updateById(bookClockinEntity);
|
||||
return R.ok("提交成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookClockinService.removeByIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全部评价
|
||||
*
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("commentAll")
|
||||
public R commentAll(@RequestParam("bookId") Integer bookId) {
|
||||
List applist = new ArrayList<>();
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
//根据bookid查找出签到表中签到的用户数据
|
||||
List<BookClockInEntity> bookid = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("book_id", bookId)
|
||||
.orderByDesc("create_time"));
|
||||
|
||||
for (BookClockInEntity book : bookid) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
|
||||
Integer bookid1 = book.getBookId();
|
||||
//BookClockinEntity获取点赞总数
|
||||
String likes = book.getLikeSum();
|
||||
|
||||
Integer userid1 = book.getUserId();
|
||||
Integer taskId = book.getTaskId();
|
||||
Integer id1 = book.getId();
|
||||
applist.add(taskId);
|
||||
//根据id和bookid查询出对应的签到下评论的全部数据
|
||||
|
||||
productMap.put("bookid",bookid1);
|
||||
productMap.put("userid",userid1);
|
||||
}
|
||||
PageUtils pages = bookClockinService.queryPage(productMap);
|
||||
return R.ok().put("days",applist).put("pages",pages);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 我的 :我的签到记录
|
||||
* @param id
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myinfo")
|
||||
public R myinfo(@RequestParam("userid") Integer id,
|
||||
@RequestParam("bookid") Integer bookId) {
|
||||
|
||||
|
||||
List<BookClockInEntity> bookClockinEntityList = bookClockinService.getBaseMapper().selectList(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("user_id",id) .eq("book_id",bookId).orderByDesc("create_time"));
|
||||
List list = new ArrayList<>();
|
||||
|
||||
for (BookClockInEntity bookClockinEntity : bookClockinEntityList) {
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
Integer userId = bookClockinEntity.getUserId();
|
||||
Integer dayId = bookClockinEntity.getDayId();
|
||||
Integer bookIds = bookClockinEntity.getBookId();
|
||||
Integer typeId = bookClockinEntity.getTaskId();
|
||||
String content = bookClockinEntity.getContent();
|
||||
Object images = bookClockinEntity.getImages();
|
||||
Date createTime = bookClockinEntity.getCreateTime();
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
String name = byId.getName();
|
||||
String images1 = byId.getImages();
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(typeId);
|
||||
String heading = bookTaskEntity.getHeading();
|
||||
|
||||
|
||||
String myUsername = "";
|
||||
String avatar="";
|
||||
List<MyUserEntity> myUserid = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : myUserid) {
|
||||
myUsername = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
productMap.put("myUseravatar",avatar);
|
||||
productMap.put("myUsername",myUsername);
|
||||
|
||||
productMap.put("dayId",dayId);
|
||||
productMap.put("userId",userId);
|
||||
productMap.put("taskId",typeId);
|
||||
productMap.put("content",content);
|
||||
productMap.put("clockinimages",images);
|
||||
productMap.put("createTime",createTime);
|
||||
productMap.put("bookId",bookIds);
|
||||
productMap.put("bookname",name);
|
||||
productMap.put("bookimages",images1);
|
||||
productMap.put("TaskHeading",heading);
|
||||
list.add(productMap);
|
||||
|
||||
}
|
||||
// Collections.sort(list);
|
||||
// Collections.reverse(list);
|
||||
return R.ok().put("ClockinList", list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 详情页我的签到评论
|
||||
* @param id
|
||||
* @param taskid
|
||||
* @param bookId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myinfolist")
|
||||
public R myinfolist(@RequestParam("userid") Integer id,
|
||||
@RequestParam("taskid") Integer taskid,
|
||||
@RequestParam("bookid") Integer bookId
|
||||
) {
|
||||
List list = new ArrayList<>();
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
BookClockInEntity bookClockin = bookClockinService.getBaseMapper().selectOne(new QueryWrapper<BookClockInEntity>()
|
||||
.eq("user_id",id)
|
||||
.eq("task_id",taskid)
|
||||
.eq("book_id",bookId)
|
||||
);
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("user_id",id)
|
||||
.eq("t_id",taskid)
|
||||
.eq("book_id",bookId)
|
||||
);
|
||||
|
||||
|
||||
if (bookClockin == null ) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
Integer userId = bookClockin.getUserId();
|
||||
Integer bookIds = bookClockin.getBookId();
|
||||
Integer taskId = bookClockin.getTaskId();
|
||||
Integer dayId = bookClockin.getDayId();
|
||||
String content = bookClockin.getContent();
|
||||
Object images = bookClockin.getImages();
|
||||
Date createTime = bookClockin.getCreateTime();
|
||||
BookEntity byId = bookService.getById(bookId);
|
||||
String name = byId.getName();
|
||||
String images1 = byId.getImages();
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(taskId);
|
||||
String heading = bookTaskEntity.getHeading();
|
||||
|
||||
|
||||
|
||||
String myUsername = "";
|
||||
String avatar="";
|
||||
List<MyUserEntity> myUserid = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : myUserid) {
|
||||
myUsername = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
|
||||
productMap.put("myUseravatar",avatar);
|
||||
productMap.put("myUsername",myUsername);
|
||||
|
||||
|
||||
|
||||
productMap.put("userId",userId);
|
||||
productMap.put("taskId",taskId);
|
||||
productMap.put("dayId",dayId);
|
||||
|
||||
productMap.put("content",content);
|
||||
productMap.put("clockinimages",images);
|
||||
productMap.put("createTime",createTime);
|
||||
productMap.put("bookId",bookIds);
|
||||
productMap.put("bookname",name);
|
||||
productMap.put("bookimages",images1);
|
||||
productMap.put("TaskHeading",heading);
|
||||
list.add(productMap);
|
||||
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("productlist", list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.UserEbookBuyDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("book/clockinPunch")
|
||||
public class BookClockinPunchController {
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookClockinCommentService bookClockinCommentService;
|
||||
@Autowired
|
||||
private UserEbookBuyDao userEbookBuyDao;
|
||||
@Autowired
|
||||
UserBookClockService userBookClockService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表 app post请求 /applistSS
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookClockinPunchService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
BookClockinPunchEntity bookClockinPunchEntity = bookClockinPunchService.getById(id);
|
||||
|
||||
return R.ok().put("bookClockinPunchEntity", bookClockinPunchEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
Integer bookid1 = bookClockinPunchEntity.getBookId();
|
||||
Integer userId = bookClockinPunchEntity.getUserId();
|
||||
Integer taskId = bookClockinPunchEntity.getTId();
|
||||
BookEntity bookEntity = bookService.getBaseMapper().selectById(bookid1);
|
||||
Boolean canListen = bookEntity.getCanListen();
|
||||
BookClockinPunchEntity bookClock = bookClockinPunchService.getBaseMapper().selectOne(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("book_id", bookid1)
|
||||
.eq("user_id", userId)
|
||||
.eq("t_id", taskId)
|
||||
|
||||
|
||||
);
|
||||
if (bookClock != null) {
|
||||
return R.error("您已经签到,请勿重复签到");
|
||||
}
|
||||
|
||||
|
||||
if (canListen == true) {
|
||||
boolean b = myUserService.bookAuthen(bookid1, userId);
|
||||
if (b) {
|
||||
bookClockinPunchEntity.setDelFlag(0);
|
||||
bookClockinPunchService.save(bookClockinPunchEntity);
|
||||
return R.ok("签到成功");
|
||||
} else {
|
||||
return R.error("您还未购买此书,购买后即可签到");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
return R.error("该书暂未开放打卡权限");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户打卡已购图书
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/myClockBooks")
|
||||
public R myClockBooks(@RequestParam Integer userId, @RequestParam Integer limit, @RequestParam Integer page) {
|
||||
MPJLambdaWrapper<UserEbookBuyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BookEntity.class);
|
||||
wrapper.leftJoin(BookEntity.class, BookEntity::getId, UserEbookBuyEntity::getBookId);
|
||||
wrapper.eq(UserEbookBuyEntity::getUserId, userId);
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
Page<BookEntity> userBookEntityPage = userEbookBuyDao.selectJoinPage(new Page<BookEntity>(page, limit), BookEntity.class, wrapper);
|
||||
return R.ok().put("page", userBookEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打卡推荐图书
|
||||
*
|
||||
* @param userId
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBestClockBooks")
|
||||
public R getBestClockBooks(@RequestParam Integer userId, @RequestParam Integer limit, @RequestParam Integer page) {
|
||||
String not_ex_sql = "select 1 from user_ebook_buy where book.id = book_id and user_id = " + userId;
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookEntity::getDelFlag, 0);
|
||||
wrapper.eq(BookEntity::getClockIn, 1);
|
||||
wrapper.notExists(not_ex_sql);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
return R.ok().put("page", bookEntityPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
bookClockinPunchService.updateById(bookClockinPunchEntity);
|
||||
return R.ok("提交成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookClockinPunchService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论
|
||||
*
|
||||
* @param bookClockinPunchEntity
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/punchcoments")
|
||||
public R punchcoments(@RequestBody BookClockinPunchEntity bookClockinPunchEntity) {
|
||||
//图书Id
|
||||
Integer bookId = bookClockinPunchEntity.getBookId();
|
||||
//用户id
|
||||
Integer userId = bookClockinPunchEntity.getUserId();
|
||||
//天数
|
||||
Integer days = bookClockinPunchEntity.getDays();
|
||||
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
List<BookClockinCommentEntity> bookClockinCommentEntities = bookClockinCommentService.getBaseMapper().selectList(new QueryWrapper<BookClockinCommentEntity>()
|
||||
.eq("user_id", userId)
|
||||
.eq("book_id", bookId)
|
||||
.eq("task_id", days)
|
||||
//pid等于1时为一级评论
|
||||
// .eq("pid",1)
|
||||
);
|
||||
for (BookClockinCommentEntity bookClockinCommentEntity : bookClockinCommentEntities) {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
String name = "";
|
||||
String avatar = "";
|
||||
|
||||
Integer userId1 = bookClockinCommentEntity.getUserId();
|
||||
Integer bookId1 = bookClockinCommentEntity.getBookId();
|
||||
String content = bookClockinCommentEntity.getContent();
|
||||
String images = bookClockinCommentEntity.getImages();
|
||||
Date createTime = bookClockinCommentEntity.getCreateTime();
|
||||
|
||||
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userId));
|
||||
for (MyUserEntity user : id) {
|
||||
name = user.getNickname();
|
||||
avatar = user.getAvatar();
|
||||
}
|
||||
map.put("userid", userId1);
|
||||
map.put("name", name);
|
||||
map.put("avatar", avatar);
|
||||
map.put("bookid", bookId1);
|
||||
map.put("content", content);
|
||||
map.put("images", images);
|
||||
map.put("createdate", createTime);
|
||||
list.add(map);
|
||||
|
||||
}
|
||||
|
||||
Collections.reverse(list);
|
||||
return R.ok().put("list", list);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
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.BookClockinPunchEntity;
|
||||
import com.peanut.modules.book.entity.BookTaskEntity;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 发布签到任务
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/task")
|
||||
public class BookTaskController {
|
||||
|
||||
@Autowired
|
||||
private BookTaskService bookTaskService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private BookClockInService bookClockinService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BookClockinPunchService bookClockinPunchService;
|
||||
|
||||
/**
|
||||
* 列表后台
|
||||
*
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookTaskService.queryPage(params);
|
||||
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表app根据days查询
|
||||
*
|
||||
*/
|
||||
@RequestMapping("/applist")
|
||||
public R applist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = bookTaskService.queryPageServi(params);
|
||||
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
|
||||
//根据id找到详细数据信息
|
||||
BookTaskEntity bookTaskEntity = bookTaskService.getById(id);
|
||||
Integer ids = bookTaskEntity.getId();
|
||||
Integer bookid = bookTaskEntity.getBookid();
|
||||
List<BookClockinPunchEntity> bookClockinPunchEntity = bookClockinPunchService.getBaseMapper().selectList(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("user_id", ids)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
// 遍历 bookClockinEntityList 中的每个 bookClockinEntity,查询 BookClockinEntity 表中对应的总数
|
||||
int total = 0;
|
||||
for ( BookClockinPunchEntity bookClockin : bookClockinPunchEntity) {
|
||||
|
||||
Integer id1 = bookClockin.getId();
|
||||
// BookClockinEntity byId = bookClockinService.getById(id1);
|
||||
//++获取到总条数
|
||||
total ++;
|
||||
}
|
||||
//返回总条数
|
||||
|
||||
return R.ok().put("bookTaskEntity", bookTaskEntity).put("totalCont",total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
bookTaskEntity.setDelFlag(0);
|
||||
bookTaskService.save(bookTaskEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
bookTaskService.updateById(bookTaskEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
bookTaskService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
@RequestMapping("/totalsum")
|
||||
public R totalsum(@RequestBody BookTaskEntity bookTaskEntity) {
|
||||
|
||||
// 获取 BookTaskEntity 表中所有的 bookid和id
|
||||
String days = bookTaskEntity.getDays();
|
||||
Integer bookid = bookTaskEntity.getBookid();
|
||||
List<BookClockinPunchEntity> books = bookClockinPunchService.getBaseMapper().selectList(new QueryWrapper<BookClockinPunchEntity>()
|
||||
.eq("days", days)
|
||||
.eq("book_id", bookid));
|
||||
|
||||
|
||||
|
||||
// 遍历 bookClockinEntityList 中的每个 bookClockinEntity,查询 BookClockinEntity 表中对应的总数
|
||||
int total = 0;
|
||||
for ( BookClockinPunchEntity book : books) {
|
||||
// 使用 bookClockinEntity 进行匹配查询
|
||||
Integer id1 = book.getId();
|
||||
BookClockinPunchEntity byId = bookClockinPunchService.getById(id1);
|
||||
//++获取到总条数
|
||||
total ++;
|
||||
}
|
||||
//返回总条数
|
||||
return R.ok().put("totalSum",total);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -78,33 +78,6 @@ public class BuyOrderController {
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param params
|
||||
* @return 听书未购买页面展示
|
||||
* (销量最多的书,最先放最前面展示。最新上线的书,预售的书,放最前面展示
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/lists")
|
||||
public R lists(@RequestParam Map<String, Object> params) throws Exception {
|
||||
|
||||
if ("all".equals(params.get("orderStatus"))) {
|
||||
params.remove("orderStatus");
|
||||
}
|
||||
PageUtils page = buyOrderService.queryPages(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{orderId}")
|
||||
public R info(@PathVariable("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
return R.ok().put("buyOrder", buyOrder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*
|
||||
@@ -202,74 +175,13 @@ public class BuyOrderController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/appUserGetlist")
|
||||
public R appUserGetlist(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderService.queryPage1(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
*/
|
||||
@RequestMapping("/appDelete")
|
||||
@Transactional
|
||||
public R appDelete(@RequestParam("orderId") Integer orderId) {
|
||||
|
||||
//1. 判断订单状态
|
||||
BuyOrderEntity byId = buyOrderService.getById(orderId);
|
||||
if (byId != null) {
|
||||
//2. 判断当前订单是否存在优惠券 进行 回显
|
||||
Integer couponId = byId.getCouponId();
|
||||
if (couponId != null) {
|
||||
|
||||
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
|
||||
byId1.setUseStatus(0);
|
||||
couponHistoryService.updateById(byId1);
|
||||
}
|
||||
// 库存回滚
|
||||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
.eq("order_id", byId.getOrderId()));
|
||||
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||
Integer productId = buyOrderDetailEntity.getProductId();
|
||||
ShopProductEntity product = shopProductService.getById(productId);
|
||||
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
|
||||
shopProductService.updateById(product);
|
||||
}
|
||||
buyOrderService.removeById(orderId);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/randomOrderCode")
|
||||
@Transactional
|
||||
public R randomOrderCode(@RequestBody BuyOrderEntity buyOrder) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值专用订单生成接口
|
||||
*/
|
||||
@RequestMapping("/rechargeSave")
|
||||
@Transactional
|
||||
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder) {
|
||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(timeId);
|
||||
buyOrderService.save(buyOrder);
|
||||
return R.ok().put("orderSn", timeId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/appGetOrderInfo/{type}")
|
||||
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
|
||||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime()/1000);
|
||||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime() / 1000);
|
||||
List<BuyOrderDetailEntity> orderDetail = null;
|
||||
if ("1".equals(type)) {
|
||||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||||
@@ -307,36 +219,6 @@ public class BuyOrderController {
|
||||
return R.ok().put("buyOrder", buyOrder).put("CreateTime", createDate).put("userRecordid", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
*/
|
||||
@RequestMapping("/getTransPrice/{area}")
|
||||
public R getTransPrice(@PathVariable String area, @RequestParam Map<String, Object> productMap) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("kdCode", "YD");
|
||||
params.put("area", area);
|
||||
int price = this.buyOrderService.getProductGoodsType(params, productMap);
|
||||
return R.ok().put("price", price);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 后台发货按钮
|
||||
*
|
||||
* @Param shipperCode 快递公司编码
|
||||
* @Param sendType 0:订单列表发货 1:商品列表发货
|
||||
* @Param type 合并发货/拆分发货
|
||||
* @Param ids 订单id串
|
||||
*/
|
||||
@RequestMapping("/delivery/{shipperCode}")
|
||||
public R delivery(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] ids) {
|
||||
|
||||
buyOrderService.sendFMS(ids, shipperCode, shipperName);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
*/
|
||||
@@ -381,44 +263,22 @@ public class BuyOrderController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发货功能
|
||||
* 分包发货
|
||||
*
|
||||
* @param orderDetailIds 订单详情
|
||||
* @return
|
||||
* @param expressCompanyCode 快递公司编码
|
||||
* @param userAddressId 用户地址 ID
|
||||
* @param productIds 商品 ID 列表
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/blendSendFMS/{shipperCode}")
|
||||
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] orderDetailIds) {
|
||||
|
||||
|
||||
buyOrderService.blendSendFMS(orderDetailIds, shipperCode, shipperName);
|
||||
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
|
||||
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestParam("userAddressId") Integer userAddressId,
|
||||
@RequestBody List<Integer> productIds) {
|
||||
buyOrderService.createSplitPackageOrder(expressCompanyCode, userAddressId, productIds);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台取消订单接口
|
||||
*/
|
||||
@RequestMapping("/cancelFMS")
|
||||
public R cancelFMS(@RequestParam Map<String, Object> params) {
|
||||
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
|
||||
params.get("expNo").toString());
|
||||
return R.ok().put("paramsTEXT", params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去重查询可打印面单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querySheetPage")
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||||
|
||||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品实际价格
|
||||
*
|
||||
@@ -548,7 +408,7 @@ public class BuyOrderController {
|
||||
private MessagePostProcessor messagePostProcessor() {
|
||||
return message -> {
|
||||
//设置有效期30分钟
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30*60*1000));
|
||||
message.getMessageProperties().setExpiration(String.valueOf(30 * 60 * 1000));
|
||||
return message;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.ExpressCompanyService;
|
||||
import com.peanut.modules.book.vo.ExpressCompanyVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 快递 Controller
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/express")
|
||||
public class ExpressController {
|
||||
|
||||
private final ExpressCompanyService expressCompanyService;
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getExpressCompanyList")
|
||||
public R getExpressCompanyList() {
|
||||
List<ExpressCompanyVo> expressCompanyList = expressCompanyService.getExpressCompanyList();
|
||||
return R.ok().put("result", expressCompanyList);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ExpressController(ExpressCompanyService expressCompanyService) {
|
||||
this.expressCompanyService = expressCompanyService;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,7 +69,6 @@ public class ProvinceController {
|
||||
public R getCityList(@RequestParam("provId") Integer provId){
|
||||
List<CityEntity> prov = cityService.getBaseMapper().selectList(new QueryWrapper<CityEntity>()
|
||||
.eq("prov_id", provId));
|
||||
|
||||
return R.ok().put("prov",prov);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,133 +1,84 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
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.UserAddress;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.UserAddressEntity;
|
||||
import com.peanut.modules.book.service.UserAddressService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-31 11:20:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/useraddress")
|
||||
@RequestMapping("book/userAddress")
|
||||
public class UserAddressController {
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* 用户地址列表
|
||||
*
|
||||
* @param params param
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:useraddress:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = userAddressService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* 获取地址信息
|
||||
*
|
||||
* @param addressId address ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/info/{addressid}")
|
||||
// @RequiresPermissions("book:useraddress:info")
|
||||
public R info(@PathVariable("addressid") Integer addressid){
|
||||
UserAddressEntity userAddress = userAddressService.getById(addressid);
|
||||
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
return R.ok().put("userAddress", userAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* 保存、更新
|
||||
*
|
||||
* @param userAddress 用户地址
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:useraddress:save")
|
||||
public R save(@RequestBody UserAddressEntity userAddress){
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
if (isdefault == 1) {
|
||||
Integer userid = userAddress.getUserid();
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
userAddressEntity.setIsdefault(0);
|
||||
}
|
||||
}
|
||||
userAddressService.updateBatchById(list);
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
userAddressService.saveOrUpdate(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* 删除用户地址
|
||||
*
|
||||
* @param id address ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:useraddress:update")
|
||||
public R update(@RequestBody UserAddressEntity userAddress){
|
||||
|
||||
Integer isdefault = userAddress.getIsdefault();
|
||||
|
||||
if (isdefault == 1) {
|
||||
|
||||
Integer userid = userAddress.getUserid();
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userid));
|
||||
|
||||
for (UserAddressEntity userAddressEntity : list) {
|
||||
if (userAddressEntity.getIsdefault() == 1) {
|
||||
userAddressEntity.setIsdefault(0);
|
||||
userAddressService.updateById(userAddressEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userAddressService.updateById(userAddress);
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public R delete(@RequestParam("id") Integer id) {
|
||||
userAddressService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R delete(@RequestBody Integer[] addressids){
|
||||
userAddressService.removeByIds(Arrays.asList(addressids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* app获取用户 收货地址
|
||||
* 获取用户收货地址列表
|
||||
*
|
||||
* @param userId 用户 ID
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
// @RequiresPermissions("book:useraddress:delete")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId){
|
||||
|
||||
List<UserAddressEntity> list = userAddressService.list(new QueryWrapper<UserAddressEntity>().eq("userId", userId).orderByDesc("isDefault"));
|
||||
|
||||
return R.ok().put("list",list);
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
return R.ok().put("list", userAddressList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user