Commit 2f09449227827cae559b84818a771f029bc9fb26

Authored by maliang
1 parent cffa813e80
Exists in master

编写业务实现代码

Showing 3 changed files with 80 additions and 12 deletions

parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/DiagnoseSourceServiceImpl.java View file @ 2f09449
... ... @@ -5,11 +5,14 @@
5 5  
6 6 import org.springframework.stereotype.Service;
7 7  
  8 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
8 9 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
9 10 import com.lyms.base.common.dao.conf.DiagnoseSourceMapper;
10 11 import com.lyms.base.common.entity.conf.DiagnoseSource;
  12 +import com.lyms.base.common.enums.StatusEnum;
11 13 import com.lyms.base.common.service.conf.DiagnoseSourceService;
12 14 import com.lyms.exception.SystemException;
  15 +import com.lyms.util.StrUtils;
13 16  
14 17 /**
15 18 * <p>
16 19  
17 20  
18 21  
... ... @@ -26,22 +29,41 @@
26 29 return baseMapper.deleteLogicById(id);
27 30 }
28 31  
  32 + private void throwCheckException(DiagnoseSource diagnoseSource) throws SystemException {
  33 + if (diagnoseSource == null) {
  34 + throw new SystemException("诊断资源信息不能为空");
  35 + }
  36 + }
  37 +
29 38 @Override
30 39 public String createDiagnoseSource(DiagnoseSource diagnoseSource) throws SystemException {
31   - // TODO Auto-generated method stub
32   - return null;
  40 +
  41 + throwCheckException(diagnoseSource);
  42 + String id = StrUtils.uuid();
  43 + diagnoseSource.setId(id);
  44 + boolean tag = insert(diagnoseSource);
  45 + return tag ? id : null;
33 46 }
34 47  
35 48 @Override
36 49 public boolean enable(Serializable id) throws SystemException {
37   - // TODO Auto-generated method stub
38   - return false;
  50 + if (id == null)
  51 + return false;
  52 + DiagnoseSource diagnoseSource = selectById(id);
  53 + if (diagnoseSource == null)
  54 + return false;
  55 + Integer enable = diagnoseSource.getEnable();
  56 + enable = enable == null || StatusEnum.isDisEnabled(enable) ? StatusEnum.ENABLED.getStatus()
  57 + : StatusEnum.DISENABLED.getStatus();
  58 + diagnoseSource.setEnable(enable);
  59 + return updateById(diagnoseSource);
39 60 }
40 61  
41 62 @Override
42 63 public List<DiagnoseSource> getDiagnoseSource() throws SystemException {
43   - // TODO Auto-generated method stub
44   - return null;
  64 + EntityWrapper<DiagnoseSource> wrapper = new EntityWrapper<>();
  65 + wrapper.where("enable={0}", StatusEnum.ENABLED.getStatus());
  66 + return selectList(wrapper);
45 67 }
46 68 }
parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/DiagnoseVersionServiceImpl.java View file @ 2f09449
... ... @@ -3,13 +3,17 @@
3 3 import java.io.Serializable;
4 4 import java.util.List;
5 5  
  6 +import org.springframework.beans.factory.annotation.Autowired;
6 7 import org.springframework.stereotype.Service;
7 8  
  9 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
8 10 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
9 11 import com.lyms.base.common.dao.conf.DiagnoseVersionMapper;
10 12 import com.lyms.base.common.entity.conf.DiagnoseVersion;
  13 +import com.lyms.base.common.enums.StatusEnum;
11 14 import com.lyms.base.common.service.conf.DiagnoseVersionService;
12 15 import com.lyms.exception.SystemException;
  16 +import com.lyms.util.StrUtils;
13 17  
14 18 /**
15 19 * <p>
16 20  
17 21  
18 22  
19 23  
... ... @@ -22,26 +26,64 @@
22 26 public class DiagnoseVersionServiceImpl extends ServiceImpl<DiagnoseVersionMapper, DiagnoseVersion>
23 27 implements DiagnoseVersionService {
24 28  
  29 + @Autowired
  30 + private DiagnoseVersionMapper diagnoseVersionMapper;
  31 +
25 32 public Integer deleteLogicById(Serializable id) {
26 33 return baseMapper.deleteLogicById(id);
27 34 }
28 35  
  36 + private void throwCheckExecption(DiagnoseVersion diagnoseVersion) throws SystemException {
  37 + if (diagnoseVersion == null)
  38 + throw new SystemException("诊断信息不能为空");
  39 + }
  40 +
29 41 @Override
30 42 public boolean enable(Serializable id) throws SystemException {
31   - // TODO Auto-generated method stub
32   - return false;
  43 +
  44 + if (id == null)
  45 + return false;
  46 + DiagnoseVersion version = diagnoseVersionMapper.selectById(id);
  47 + if (version == null)
  48 + return false;
  49 +
  50 + Integer status = version.getEnable();
  51 +
  52 + status = status == null || StatusEnum.isDisEnabled(status) ? StatusEnum.DISENABLED.getStatus()
  53 + : StatusEnum.ENABLED.getStatus();
  54 + version.setEnable(status);
  55 +
  56 + /*
  57 + * if (status == null || StatusEnum.isDisEnabled(status)) {
  58 + * version.setEnable(StatusEnum.ENABLED.getStatus()); } else {
  59 + * version.setEnable(StatusEnum.DISENABLED.getStatus()); }
  60 + */
  61 +
  62 + Integer tag = diagnoseVersionMapper.updateById(version);
  63 + return tag != null && tag >= 1;
33 64 }
34 65  
35 66 @Override
36 67 public List<DiagnoseVersion> getEnableDiagnoseVersionBy(Serializable id) throws SystemException {
37   - // TODO Auto-generated method stub
38   - return null;
  68 +
  69 + if (id == null)
  70 + return null;
  71 +
  72 + EntityWrapper<DiagnoseVersion> wrapper = new EntityWrapper<DiagnoseVersion>();
  73 + wrapper.where("enable={0}", StatusEnum.ENABLED.getStatus());
  74 + return diagnoseVersionMapper.selectList(wrapper);
39 75 }
40 76  
41 77 @Override
42 78 public String createVersion(DiagnoseVersion version) throws SystemException {
43   - // TODO Auto-generated method stub
44   - return null;
  79 + this.throwCheckExecption(version);
  80 +
  81 + String id = StrUtils.uuid();
  82 + version.setId(id);
  83 +
  84 + Integer tag = diagnoseVersionMapper.insert(version);
  85 +
  86 + return tag != null && tag >= 1 ? id : null;
45 87 }
46 88 }
parent/hospital.web/src/test/java/test/hospital/Test.java View file @ 2f09449
... ... @@ -11,6 +11,10 @@
11 11 System.out.println(str);
12 12 conver.conver(str);
13 13 System.out.println(conver.get(0));
  14 +
  15 + System.out.println(String.format("%s", "hello"));
  16 + System.out.println(String.format("{0}", "fd"));
  17 +
14 18 }
15 19  
16 20 // 创建