|
@@ -1,120 +0,0 @@
|
|
-package com.diagbot.facade;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
-import com.diagbot.entity.ClassifyMapping;
|
|
|
|
-import com.diagbot.entity.FolderMapping;
|
|
|
|
-import com.diagbot.entity.TemplateClassify;
|
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
|
-import com.diagbot.service.impl.TemplateClassifyServiceImpl;
|
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
|
-import com.diagbot.vo.HospitalCodeSetVO;
|
|
|
|
-import com.diagbot.vo.TemplateClassifyDelVO;
|
|
|
|
-import com.diagbot.vo.TemplateClassifyListVO;
|
|
|
|
-import com.diagbot.vo.TemplateClassifyVO;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * @author zhoutg
|
|
|
|
- * @Description: 模板分类
|
|
|
|
- * @date 2018年11月16日 上午11:24:36
|
|
|
|
- */
|
|
|
|
-@Component
|
|
|
|
-public class TemplateClassifyAdminFacade extends TemplateClassifyServiceImpl {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ClassifyMappingFacade classifyMappingFacade;
|
|
|
|
- @Autowired
|
|
|
|
- AdminCheckFacade adminCheckFacade;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分类新增或更新
|
|
|
|
- *
|
|
|
|
- * @param templateClassifyVO
|
|
|
|
- */
|
|
|
|
- public void saveOrUpdate(TemplateClassifyVO templateClassifyVO) {
|
|
|
|
- HospitalCodeSetVO hospitalCodeSetVO = new HospitalCodeSetVO();
|
|
|
|
- hospitalCodeSetVO.setDoctorId(templateClassifyVO.getDoctorId());
|
|
|
|
- hospitalCodeSetVO.setHospitalId(templateClassifyVO.getHospitalId());
|
|
|
|
- boolean res = adminCheckFacade.getadminCheck(hospitalCodeSetVO);
|
|
|
|
- if (!res) {
|
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "暂无修改权限");
|
|
|
|
- }
|
|
|
|
- boolean add = true;
|
|
|
|
- if (templateClassifyVO.getId() != null) {
|
|
|
|
- add = false;
|
|
|
|
- }
|
|
|
|
- int count = this.count(new QueryWrapper<TemplateClassify>()
|
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
- .eq("name", templateClassifyVO.getName())
|
|
|
|
- .eq("hospital_id", templateClassifyVO.getHospitalId())
|
|
|
|
-// .eq("doctor_id", templateClassifyVO.getDoctorId())
|
|
|
|
- .ne(!add, "id", templateClassifyVO.getId())
|
|
|
|
- );
|
|
|
|
- if (count > 0) {
|
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该分类已存在");
|
|
|
|
- }
|
|
|
|
- TemplateClassify templateClassify = new TemplateClassify();
|
|
|
|
- BeanUtil.copyProperties(templateClassifyVO, templateClassify);
|
|
|
|
- Date date = DateUtil.now();
|
|
|
|
- if (add) {
|
|
|
|
- templateClassify.setGmtCreate(date);
|
|
|
|
- templateClassify.setCreator(templateClassifyVO.getDoctorId().toString());
|
|
|
|
- }
|
|
|
|
- templateClassify.setGmtModified(date);
|
|
|
|
- templateClassify.setModifier(templateClassifyVO.getDoctorId().toString());
|
|
|
|
- this.saveOrUpdate(templateClassify);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分类删除
|
|
|
|
- *
|
|
|
|
- * @param templateClassifyDelVO
|
|
|
|
- */
|
|
|
|
- public void delete(TemplateClassifyDelVO templateClassifyDelVO) {
|
|
|
|
- // 校验权限
|
|
|
|
- HospitalCodeSetVO hospitalCodeSetVO = new HospitalCodeSetVO();
|
|
|
|
- hospitalCodeSetVO.setDoctorId(templateClassifyDelVO.getDoctorId());
|
|
|
|
- hospitalCodeSetVO.setHospitalId(templateClassifyDelVO.getHospitalId());
|
|
|
|
- boolean res = adminCheckFacade.getadminCheck(hospitalCodeSetVO);
|
|
|
|
- if (!res) {
|
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "暂无删除权限");
|
|
|
|
- }
|
|
|
|
- int count = classifyMappingFacade.count(new QueryWrapper<ClassifyMapping>()
|
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
- .eq("folder_id", templateClassifyDelVO.getClassifyId())
|
|
|
|
- );
|
|
|
|
- if (count > 0) {
|
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请先删除当前分类下的模板");
|
|
|
|
- }
|
|
|
|
- // 删除
|
|
|
|
- this.update(new UpdateWrapper<TemplateClassify>()
|
|
|
|
- .eq("id", templateClassifyDelVO.getClassifyId())
|
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
|
- .set("gmt_modified", DateUtil.now())
|
|
|
|
- .set("modifier", templateClassifyDelVO.getDoctorId())
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分类列表
|
|
|
|
- *
|
|
|
|
- * @param templateClassifyListVO
|
|
|
|
- */
|
|
|
|
- public List<TemplateClassify> list(TemplateClassifyListVO templateClassifyListVO) {
|
|
|
|
- return this.list(new QueryWrapper<TemplateClassify>()
|
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
-// .eq("doctor_id", templateClassifyListVO.getDoctorId())
|
|
|
|
- .eq("hospital_id", templateClassifyListVO.getHospitalId())
|
|
|
|
- .orderByDesc("gmt_modified")
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-}
|
|
|