Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -23,7 +23,7 @@
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<mssql.version>4.0</mssql.version>
|
||||
<oracle.version>11.2.0.3</oracle.version>
|
||||
<druid.version>1.1.13</druid.version>
|
||||
<druid.version>1.2.1</druid.version>
|
||||
<quartz.version>2.3.0</quartz.version>
|
||||
<commons.lang.version>2.6</commons.lang.version>
|
||||
<commons.fileupload.version>1.2.2</commons.fileupload.version>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package com.peanut.common.utils;
|
||||
|
||||
import com.peanut.common.exception.RRException;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
@@ -36,6 +37,11 @@ public class ShiroUtils {
|
||||
public static Long getUserId() {
|
||||
return getUserEntity().getUserId();
|
||||
}
|
||||
|
||||
public static Integer getUId() {
|
||||
MyUserEntity user = (MyUserEntity)SecurityUtils.getSubject().getPrincipal();
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
public static void setSessionAttribute(Object key, Object value) {
|
||||
getSession().setAttribute(key, value);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -12,15 +10,11 @@ import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.service.BookMedicalRecordsService;
|
||||
import com.peanut.modules.book.service.BookService;
|
||||
import com.peanut.modules.book.service.UserEbookBuyService;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@@ -32,8 +26,6 @@ public class BookMedicalRecordsController {
|
||||
private BookMedicalRecordsService bookMedicalRecordsService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private UserEbookBuyService userEbookBuyService;
|
||||
|
||||
/**
|
||||
* 已购图书列表
|
||||
@@ -58,12 +50,23 @@ public class BookMedicalRecordsController {
|
||||
*/
|
||||
@RequestMapping("/recommendBookList")
|
||||
public R recommendBookList(@RequestBody Map<String, Object> params){
|
||||
List<BookEntity> list = bookMedicalRecordsService.getBooks(params);
|
||||
int count = bookMedicalRecordsService.getCount((Integer) params.get("userId"));
|
||||
Page<BookEntity> page = new Page<>();
|
||||
page.setRecords(list);
|
||||
page.setTotal(count);
|
||||
page.setPages((int)Math.ceil(list.size()/page.getSize()));
|
||||
// List<BookEntity> list = bookMedicalRecordsService.getBooks(params);
|
||||
// int count = bookMedicalRecordsService.getCount((Integer) params.get("userId"));
|
||||
// Page<BookEntity> page = new Page<>();
|
||||
// page.setRecords(list);
|
||||
// page.setTotal(count);
|
||||
// page.setPages((int)Math.ceil(list.size()/page.getSize()));
|
||||
// return R.ok().put("page", page);
|
||||
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
String exsql = "SELECT 1 FROM book_medical_records bmr WHERE bmr.book_id = id and bmr.del_flag = 0 ";
|
||||
String notsql = "select 1 from user_ebook_buy b where b.book_id = id and user_id = "+params.get("userId");
|
||||
wrapper.selectAll(BookEntity.class);
|
||||
wrapper.exists(exsql);
|
||||
wrapper.notExists(notsql);
|
||||
wrapper.eq("state",1);
|
||||
wrapper.eq("del_flag",0);
|
||||
IPage<BookEntity> page = bookService.page(
|
||||
new Query<BookEntity>().getPage(params),wrapper);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.book.entity.BookTeachCommentEntity;
|
||||
import com.peanut.modules.book.entity.BookTeachLikeEntity;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.service.BookTeachCommentService;
|
||||
import com.peanut.modules.book.service.BookTeachLikeService;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("book/teach")
|
||||
public class BookTeachLikeAndCommentController {
|
||||
|
||||
@Autowired
|
||||
private BookTeachLikeService likeService;
|
||||
@Autowired
|
||||
private BookTeachCommentService commentService;
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
|
||||
/**
|
||||
* 获取点赞数量
|
||||
*/
|
||||
@RequestMapping("/getLikeCount")
|
||||
public R getLikeCount(int teachId) {
|
||||
LambdaQueryWrapper<BookTeachLikeEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookTeachLikeEntity::getDelFlag,0);
|
||||
wrapper.eq(BookTeachLikeEntity::getTeachId,teachId);
|
||||
int count = likeService.count(wrapper);
|
||||
return R.ok().put("count", count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加或取消点赞
|
||||
*/
|
||||
@RequestMapping("/addOrCancelLike")
|
||||
public R addOrCancelLike(int teachId) {
|
||||
R r = new R();
|
||||
LambdaQueryWrapper<BookTeachLikeEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookTeachLikeEntity::getTeachId,teachId);
|
||||
wrapper.eq(BookTeachLikeEntity::getUserId, ShiroUtils.getUId());
|
||||
BookTeachLikeEntity like = likeService.getOne(wrapper);
|
||||
if (like == null){
|
||||
like = new BookTeachLikeEntity();
|
||||
like.setTeachId(teachId);
|
||||
like.setUserId(ShiroUtils.getUId());
|
||||
r.put("msg","点赞成功");
|
||||
}else {
|
||||
if (0==like.getDelFlag()){
|
||||
like.setDelFlag(1);
|
||||
r.put("msg","取消成功");
|
||||
}else {
|
||||
like.setDelFlag(0);
|
||||
r.put("msg","点赞成功");
|
||||
}
|
||||
}
|
||||
likeService.saveOrUpdate(like);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* 本用户当前目录是否点赞
|
||||
*/
|
||||
@RequestMapping("/ifLike")
|
||||
public boolean ifLike(int teachId) {
|
||||
LambdaQueryWrapper<BookTeachLikeEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookTeachLikeEntity::getDelFlag,0);
|
||||
wrapper.eq(BookTeachLikeEntity::getTeachId,teachId);
|
||||
wrapper.eq(BookTeachLikeEntity::getUserId,ShiroUtils.getUId());
|
||||
BookTeachLikeEntity likeEntity = likeService.getOne(wrapper);
|
||||
if (likeEntity != null){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取评论列表
|
||||
*/
|
||||
@RequestMapping("/getCommentList")
|
||||
public R getCommentList(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<BookTeachCommentEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.eq(BookTeachCommentEntity::getTeachId,params.get("teachId"));
|
||||
wrapper.eq(BookTeachCommentEntity::getParentId,0);
|
||||
wrapper.eq(BookTeachCommentEntity::getDelFlag,0);
|
||||
IPage<BookTeachCommentEntity> page = commentService.page(
|
||||
new Query<BookTeachCommentEntity>().getPage(params),wrapper);
|
||||
//返回体添加子评论和用户信息
|
||||
if (page.getRecords().size() > 0){
|
||||
for (BookTeachCommentEntity comment:page.getRecords()){
|
||||
getSonComment(comment);
|
||||
}
|
||||
}
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
//递归查询子评论
|
||||
private void getSonComment(BookTeachCommentEntity comment){
|
||||
LambdaQueryWrapper<BookTeachCommentEntity> w = new LambdaQueryWrapper();
|
||||
w.eq(BookTeachCommentEntity::getParentId,comment.getId());
|
||||
w.eq(BookTeachCommentEntity::getDelFlag,0);
|
||||
List<BookTeachCommentEntity> list = commentService.list(w);
|
||||
if (list.size() > 0){
|
||||
for (BookTeachCommentEntity c : list){
|
||||
getSonComment(c);
|
||||
}
|
||||
}
|
||||
comment.setComments(list);
|
||||
comment.setUser(userService.getById(comment.getUserId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加修改评论
|
||||
*/
|
||||
@RequestMapping("/addComment")
|
||||
public R addComment(@RequestBody BookTeachCommentEntity comment) {
|
||||
comment.setUserId(ShiroUtils.getUId());
|
||||
commentService.saveOrUpdate(comment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@RequestMapping("/delComment")
|
||||
public R delComment(int commentId) {
|
||||
BookTeachCommentEntity comment = commentService.getById(commentId);
|
||||
comment.setDelFlag(1);
|
||||
commentService.updateById(comment);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.book.entity.BookTeachCommentEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookTeachCommentDao extends MPJBaseMapper<BookTeachCommentEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.book.entity.BookTeachLikeEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BookTeachLikeDao extends MPJBaseMapper<BookTeachLikeEntity> {
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("book_teach_comment")
|
||||
public class BookTeachCommentEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
|
||||
@TableField("parent_id")
|
||||
private Integer parentId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<BookTeachCommentEntity> comments;
|
||||
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private MyUserEntity user;
|
||||
|
||||
@TableField("teach_id")
|
||||
private Integer teachId;
|
||||
|
||||
private String content;
|
||||
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
@TableField("del_flag")
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("book_teach_like")
|
||||
public class BookTeachLikeEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
|
||||
@TableField("teach_id")
|
||||
private Integer teachId;
|
||||
|
||||
@TableField("del_flag")
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.BookTeachCommentEntity;
|
||||
|
||||
public interface BookTeachCommentService extends IService<BookTeachCommentEntity> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.BookTeachLikeEntity;
|
||||
|
||||
public interface BookTeachLikeService extends IService<BookTeachLikeEntity> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.BookTeachCommentDao;
|
||||
import com.peanut.modules.book.entity.BookTeachCommentEntity;
|
||||
import com.peanut.modules.book.service.BookTeachCommentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookTeachCommentService")
|
||||
public class BookTeachCommentServiceImpl extends ServiceImpl<BookTeachCommentDao, BookTeachCommentEntity> implements BookTeachCommentService {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.BookTeachLikeDao;
|
||||
import com.peanut.modules.book.entity.BookTeachLikeEntity;
|
||||
import com.peanut.modules.book.service.BookTeachLikeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("bookTeachLikeService")
|
||||
public class BookTeachLikeServiceImpl extends ServiceImpl<BookTeachLikeDao, BookTeachLikeEntity> implements BookTeachLikeService {
|
||||
}
|
||||
68
src/main/java/com/peanut/modules/job/task/ExpressTask.java
Normal file
68
src/main/java/com/peanut/modules/job/task/ExpressTask.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.peanut.modules.job.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.BuyOrderProduct;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import com.peanut.modules.book.entity.ExpressQueryResponse;
|
||||
import com.peanut.modules.book.service.BuyOrderProductService;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.ExpressOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component("expressTask")
|
||||
public class ExpressTask implements ITask{
|
||||
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private BuyOrderProductService productService;
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
System.out.println("------expressTask定时任务正在执行------");
|
||||
System.out.println("------查询快递修改状态定时任务正在执行------");
|
||||
System.out.println("------expressTask定时任务正在执行------");
|
||||
|
||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(BuyOrder::getOrderStatus,"2");
|
||||
List<BuyOrder> list = buyOrderService.list(wrapper);
|
||||
if (list.size() > 0){
|
||||
for (BuyOrder buyOrder : list) {
|
||||
MPJLambdaWrapper<BuyOrderProduct> w = new MPJLambdaWrapper();
|
||||
w.selectAll(ExpressOrder.class);
|
||||
w.eq(BuyOrderProduct::getOrderId,buyOrder.getOrderId());
|
||||
w.leftJoin(ExpressOrder.class,ExpressOrder::getId,BuyOrderProduct::getExpressOrderId);
|
||||
List<Map<String,Object>> plist = productService.listMaps(w);
|
||||
if (plist.size() > 0){
|
||||
boolean flag = true;
|
||||
for (Map<String,Object> m : plist){
|
||||
String expressOrderSn = m.get("express_order_sn").toString();
|
||||
String consigneeMobile = m.get("consignee_mobile").toString();
|
||||
String expressCompanyCode = m.get("express_company_code").toString();
|
||||
String tel = consigneeMobile.substring(consigneeMobile.length()-4);
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressCompanyCode, expressOrderSn, tel);
|
||||
if (!"3".equals(expressQueryResponse.getState())){
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
buyOrder.setOrderStatus("3");
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("------expressTask定时任务执行完毕------");
|
||||
System.out.println("------查询快递修改状态定时任务执行完毕------");
|
||||
System.out.println("------expressTask定时任务执行完毕------");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user