Merge remote-tracking branch 'origin/wjl/ban1'

This commit is contained in:
wangjinlei
2023-12-14 10:00:29 +08:00
9 changed files with 251 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import java.util.List;
public interface PrescriptCategoryService extends IService<PrescriptCategoryEntity> {
List<PrescriptCategoryEntity> getPrescriptCategoryList();
boolean delPrescriptCategory(Integer prescriptCategoryId);
}

View File

@@ -0,0 +1,11 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import com.peanut.modules.book.entity.PrescriptEntity;
import java.util.List;
public interface PrescriptService extends IService<PrescriptEntity> {
}

View File

@@ -0,0 +1,49 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.PrescriptCategoryDao;
import com.peanut.modules.book.dao.PrescriptDao;
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import com.peanut.modules.book.entity.PrescriptEntity;
import com.peanut.modules.book.service.PrescriptCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service("prescriptCategoryService")
public class PrescriptCategoryServiceImpl extends ServiceImpl<PrescriptCategoryDao, PrescriptCategoryEntity> implements PrescriptCategoryService {
@Autowired
private PrescriptDao prescriptDao;
@Override
public List<PrescriptCategoryEntity> getPrescriptCategoryList() {
LambdaQueryWrapper<PrescriptCategoryEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PrescriptCategoryEntity::getPid,0);
List<PrescriptCategoryEntity> list = list(wrapper);
for (PrescriptCategoryEntity p:list){
p.setChildren(list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid,p.getPrescriptCategoryId())));
}
return list;
}
@Override
public boolean delPrescriptCategory(Integer prescriptCategoryId) {
PrescriptCategoryEntity byId = getById(prescriptCategoryId);
if(byId.getPid().equals(0)){
return false;
}
List<PrescriptCategoryEntity> list = list(new LambdaQueryWrapper<PrescriptCategoryEntity>().eq(PrescriptCategoryEntity::getPid, prescriptCategoryId));
if(list.size()>0){
return false;
}
List<PrescriptEntity> prescriptEntities = prescriptDao.selectList(new LambdaQueryWrapper<PrescriptEntity>().eq(PrescriptEntity::getPrescriptCategoryId, prescriptCategoryId));
if(prescriptEntities.size()>0){
return false;
}
removeById(prescriptCategoryId);
return true;
}
}

View File

@@ -0,0 +1,21 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.PrescriptCategoryDao;
import com.peanut.modules.book.dao.PrescriptDao;
import com.peanut.modules.book.entity.PrescriptCategoryEntity;
import com.peanut.modules.book.entity.PrescriptEntity;
import com.peanut.modules.book.service.PrescriptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service("prescriptService")
public class PrescriptServiceImpl extends ServiceImpl<PrescriptDao, PrescriptEntity> implements PrescriptService {
@Autowired
private PrescriptCategoryDao prescriptCategoryDao;
}