Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -1,11 +1,19 @@
|
|||||||
package com.peanut.modules.book.controller;
|
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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.Query;
|
||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.book.entity.BookEntity;
|
||||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
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.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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -22,12 +30,46 @@ public class BookMedicalRecordsController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BookMedicalRecordsService bookMedicalRecordsService;
|
private BookMedicalRecordsService bookMedicalRecordsService;
|
||||||
|
@Autowired
|
||||||
|
private BookService bookService;
|
||||||
|
@Autowired
|
||||||
|
private UserEbookBuyService userEbookBuyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已购图书列表
|
||||||
|
*/
|
||||||
|
@RequestMapping("/userEbookBuyList")
|
||||||
|
public R userEbookBuyList(@RequestBody Map<String, Object> params){
|
||||||
|
MPJLambdaWrapper<BookEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.selectAll(BookEntity.class);
|
||||||
|
wrapper.leftJoin(UserEbookBuyEntity.class, UserEbookBuyEntity::getBookId,BookEntity::getId);
|
||||||
|
wrapper.leftJoin(BookMedicalRecordsEntity.class,BookMedicalRecordsEntity::getBookId,BookEntity::getId);
|
||||||
|
wrapper.eq(BookMedicalRecordsEntity::getDelFlag,0);
|
||||||
|
wrapper.eq(BookEntity::getDelFlag,0);
|
||||||
|
wrapper.eq(BookEntity::getState,1);
|
||||||
|
wrapper.eq(UserEbookBuyEntity::getUserId,params.get("userId"));
|
||||||
|
wrapper.groupBy(BookMedicalRecordsEntity::getBookId);
|
||||||
|
IPage<BookEntity> page = bookService.page(
|
||||||
|
new Query<BookEntity>().getPage(params),wrapper);
|
||||||
|
return R.ok().put("page", page);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 推荐图书列表
|
||||||
|
*/
|
||||||
|
@RequestMapping("/recommendBookList")
|
||||||
|
public R recommendBookList(@RequestBody Map<String, Object> params){
|
||||||
|
List<BookEntity> list = bookMedicalRecordsService.getBooks(params);
|
||||||
|
Page<BookEntity> page = new Page<>();
|
||||||
|
page.setRecords(list);
|
||||||
|
page.setTotal(list.size());
|
||||||
|
page.setPages((int)Math.ceil(list.size()/page.getSize()));
|
||||||
|
return R.ok().put("page", page);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestBody Map<String, Object> params){
|
||||||
IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
|
IPage<BookMedicalRecordsEntity> page = bookMedicalRecordsService.page(
|
||||||
new Query<BookMedicalRecordsEntity>().getPage(params),
|
new Query<BookMedicalRecordsEntity>().getPage(params),
|
||||||
new QueryWrapper<BookMedicalRecordsEntity>()
|
new QueryWrapper<BookMedicalRecordsEntity>()
|
||||||
@@ -64,12 +106,6 @@ public class BookMedicalRecordsController {
|
|||||||
@RequestMapping("/saveOrUpdate")
|
@RequestMapping("/saveOrUpdate")
|
||||||
public R save(@RequestBody BookMedicalRecordsEntity entity){
|
public R save(@RequestBody BookMedicalRecordsEntity entity){
|
||||||
try {
|
try {
|
||||||
if (entity.getSort()==null){
|
|
||||||
entity.setSort(1);
|
|
||||||
}
|
|
||||||
if (entity.getDelFlag()==null){
|
|
||||||
entity.setDelFlag(0);
|
|
||||||
}
|
|
||||||
bookMedicalRecordsService.saveOrUpdate(entity);
|
bookMedicalRecordsService.saveOrUpdate(entity);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
@@ -82,11 +118,7 @@ public class BookMedicalRecordsController {
|
|||||||
@RequestMapping("/del")
|
@RequestMapping("/del")
|
||||||
public R del(Integer medicalRecordsId){
|
public R del(Integer medicalRecordsId){
|
||||||
try {
|
try {
|
||||||
BookMedicalRecordsEntity entity = bookMedicalRecordsService.getOne(
|
bookMedicalRecordsService.removeById(medicalRecordsId);
|
||||||
new QueryWrapper<BookMedicalRecordsEntity>()
|
|
||||||
.eq("medical_records_id", medicalRecordsId));
|
|
||||||
entity.setDelFlag(1);
|
|
||||||
bookMedicalRecordsService.updateById(entity);
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
return R.error("删除失败:"+e.getMessage());
|
return R.error("删除失败:"+e.getMessage());
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package com.peanut.modules.book.dao;
|
package com.peanut.modules.book.dao;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.peanut.modules.book.entity.BookEntity;
|
||||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BookMedicalRecordsDao extends MPJBaseMapper<BookMedicalRecordsEntity> {
|
public interface BookMedicalRecordsDao extends MPJBaseMapper<BookMedicalRecordsEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<BookEntity> getBooks(Integer page,Integer limit,Integer userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package com.peanut.modules.book.entity;
|
package com.peanut.modules.book.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -44,6 +41,7 @@ public class BookMedicalRecordsEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 删除标志
|
* 删除标志
|
||||||
*/
|
*/
|
||||||
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.peanut.modules.book.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
|
import com.peanut.modules.book.entity.BookEntity;
|
||||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -10,4 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface BookMedicalRecordsService extends IService<BookMedicalRecordsEntity> {
|
public interface BookMedicalRecordsService extends IService<BookMedicalRecordsEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
List<BookEntity> getBooks(Map<String, Object> params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.Query;
|
import com.peanut.common.utils.Query;
|
||||||
import com.peanut.modules.book.dao.BookMedicalRecordsDao;
|
import com.peanut.modules.book.dao.BookMedicalRecordsDao;
|
||||||
|
import com.peanut.modules.book.entity.BookEntity;
|
||||||
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
import com.peanut.modules.book.entity.BookMedicalRecordsEntity;
|
||||||
import com.peanut.modules.book.service.BookMedicalRecordsService;
|
import com.peanut.modules.book.service.BookMedicalRecordsService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,5 +20,14 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
public class BookMedicalRecordsServiceImpl extends ServiceImpl<BookMedicalRecordsDao, BookMedicalRecordsEntity> implements BookMedicalRecordsService {
|
public class BookMedicalRecordsServiceImpl extends ServiceImpl<BookMedicalRecordsDao, BookMedicalRecordsEntity> implements BookMedicalRecordsService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BookMedicalRecordsDao dao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BookEntity> getBooks(Map<String, Object> params) {
|
||||||
|
int page = Integer.parseInt(params.get("page").toString());
|
||||||
|
int limit = Integer.parseInt(params.get("limit").toString());
|
||||||
|
return dao.getBooks((page-1)*limit,limit
|
||||||
|
,(Integer)params.get("userId"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,13 @@
|
|||||||
<result property="delFlag" column="del_flag"/>
|
<result property="delFlag" column="del_flag"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="getBooks" parameterType="int" resultType="com.peanut.modules.book.entity.BookEntity">
|
||||||
|
select b.* from book_medical_records bmr
|
||||||
|
left join book b on bmr.book_id = b.id
|
||||||
|
where bmr.book_id not in (select book_id from user_ebook_buy where user_id = #{userId})
|
||||||
|
and b.del_flag = 0 and b.state = 1
|
||||||
|
GROUP BY bmr.book_id
|
||||||
|
limit #{page},#{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user