prescript

This commit is contained in:
wangjinlei
2023-12-15 15:39:57 +08:00
parent 065cce514f
commit 8d88be960e
5 changed files with 24 additions and 8 deletions

View File

@@ -119,8 +119,10 @@ public class PrescriptController {
*/ */
@RequestMapping("/prescriptListForJF") @RequestMapping("/prescriptListForJF")
public R prescriptListForJF(@RequestBody Map<String,Object> map){ public R prescriptListForJF(@RequestBody Map<String,Object> map){
Integer limit = Integer.valueOf(map.get("limit").toString());
return R.ok(); Integer page = Integer.valueOf(map.get("page").toString());
Page<PrescriptEntity> prescriptListForJF = prescriptService.getPrescriptListForJF(limit, page);
return R.ok().put("page",prescriptListForJF);
} }
private R getR(@RequestBody Map<String, Object> map) { private R getR(@RequestBody Map<String, Object> map) {

View File

@@ -37,6 +37,9 @@ public class PrescriptEntity {
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
@TableField(exist = false)
private String letter;
@TableField(exist = false) @TableField(exist = false)
private List<String> imageList; private List<String> imageList;

View File

@@ -10,4 +10,6 @@ import java.util.List;
public interface PrescriptService extends IService<PrescriptEntity> { public interface PrescriptService extends IService<PrescriptEntity> {
Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page); Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId,int limit,int page);
Page<PrescriptEntity> getPrescriptListForJF(int limit,int page);
} }

View File

@@ -22,10 +22,10 @@ public class PrescriptCategoryServiceImpl extends ServiceImpl<PrescriptCategoryD
public List<PrescriptCategoryEntity> getPrescriptCategoryList() { public List<PrescriptCategoryEntity> getPrescriptCategoryList() {
LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PrescriptCategoryEntity::getPid,0); wrapper.eq(PrescriptCategoryEntity::getPid,0);
wrapper.orderByDesc(PrescriptCategoryEntity::getSort); wrapper.orderByAsc(PrescriptCategoryEntity::getSort);
List<PrescriptCategoryEntity> list = list(wrapper); List<PrescriptCategoryEntity> list = list(wrapper);
for (PrescriptCategoryEntity p:list){ for (PrescriptCategoryEntity p:list){
p.setChildren(list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid,p.getPrescriptCategoryId()).orderByDesc(PrescriptCategoryEntity::getSort))); p.setChildren(list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid,p.getPrescriptCategoryId()).orderByAsc(PrescriptCategoryEntity::getSort)));
} }
return list; return list;
} }
@@ -52,7 +52,7 @@ public class PrescriptCategoryServiceImpl extends ServiceImpl<PrescriptCategoryD
public List<PrescriptCategoryEntity> getCategoryByPid(Integer pid) { public List<PrescriptCategoryEntity> getCategoryByPid(Integer pid) {
LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PrescriptCategoryEntity::getPid,pid); wrapper.eq(PrescriptCategoryEntity::getPid,pid);
wrapper.orderByDesc(PrescriptCategoryEntity::getSort); wrapper.orderByAsc(PrescriptCategoryEntity::getSort);
List<PrescriptCategoryEntity> list = list(wrapper); List<PrescriptCategoryEntity> list = list(wrapper);
return list; return list;
} }

View File

@@ -2,6 +2,7 @@ package com.peanut.modules.book.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.PrescriptCategoryDao; import com.peanut.modules.book.dao.PrescriptCategoryDao;
@@ -19,10 +20,10 @@ import java.util.List;
@Slf4j @Slf4j
@Service("prescriptService") @Service("prescriptService")
public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEntity> implements PrescriptService { public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEntity> implements PrescriptService {
@Autowired @Autowired
private PrescriptCategoryDao prescriptCategoryDao; private PrescriptCategoryDao prescriptCategoryDao;
@Override @Override
public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) { public Page<PrescriptEntity> getPrescriptList(int prescriptCategoryId, int limit, int page) {
LambdaQueryWrapper<PrescriptEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PrescriptEntity> wrapper = new LambdaQueryWrapper<>();
@@ -31,7 +32,7 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
getCategoryIds(prescriptCategoryId,list); getCategoryIds(prescriptCategoryId,list);
wrapper.in(PrescriptEntity::getPrescriptCategoryId,list); wrapper.in(PrescriptEntity::getPrescriptCategoryId,list);
} }
wrapper.orderByDesc(PrescriptEntity::getSort); wrapper.orderByAsc(PrescriptEntity::getSort);
Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper); Page<PrescriptEntity> prescriptEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
for (PrescriptEntity p : prescriptEntityPage.getRecords()){ for (PrescriptEntity p : prescriptEntityPage.getRecords()){
p.setImageList(JSON.parseArray(p.getImages(),String.class)); p.setImageList(JSON.parseArray(p.getImages(),String.class));
@@ -40,6 +41,15 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
return prescriptEntityPage; return prescriptEntityPage;
} }
@Override
public Page<PrescriptEntity> getPrescriptListForJF(int limit, int page) {
QueryWrapper<PrescriptEntity> wrapper = new QueryWrapper<>();
wrapper.select("prescript.*","to_first_pinyin(title) letter");
wrapper.eq("prescript_category_id",3);
wrapper.orderByAsc("CONVERT(title USING gbk) COLLATE gbk_chinese_ci");
Page<PrescriptEntity> page1 = page(new Page<PrescriptEntity>(page, limit), wrapper);
return page1;
}
private PrescriptCategoryEntity getTree(int categoryId){ private PrescriptCategoryEntity getTree(int categoryId){
PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId,categoryId)); PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId,categoryId));
@@ -53,7 +63,6 @@ public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEn
private void getCategoryIds(int id,List<Integer> list){ private void getCategoryIds(int id,List<Integer> list){
PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId, id)); PrescriptCategoryEntity prescriptCategoryEntity = prescriptCategoryDao.selectOne(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPrescriptCategoryId, id));
List<PrescriptCategoryEntity> prescriptCategoryEntities = prescriptCategoryDao.selectList(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid, prescriptCategoryEntity.getPrescriptCategoryId())); List<PrescriptCategoryEntity> prescriptCategoryEntities = prescriptCategoryDao.selectList(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid, prescriptCategoryEntity.getPrescriptCategoryId()));
for (PrescriptCategoryEntity p : prescriptCategoryEntities){ for (PrescriptCategoryEntity p : prescriptCategoryEntities){
getCategoryIds(p.getPrescriptCategoryId(),list); getCategoryIds(p.getPrescriptCategoryId(),list);