new prescript
This commit is contained in:
@@ -3,5 +3,11 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1,7 +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> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user