Commit 5f179e2e774b266f9695d7dc89c214055349dfca
1 parent
659916a0e2
Exists in
master
小程序多人关注一个病人
Showing 8 changed files with 172 additions and 56 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatientAttention.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientAttentionMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientAttentionService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientAttentionServiceImpl.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientServiceImpl.java
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java
View file @
5f179e2
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | import org.springframework.util.DigestUtils; |
| 22 | 22 | import org.springframework.util.StringUtils; |
| 23 | 23 | import org.springframework.validation.BindingResult; |
| 24 | +import org.springframework.validation.ObjectError; | |
| 24 | 25 | import org.springframework.validation.annotation.Validated; |
| 25 | 26 | import org.springframework.web.bind.annotation.*; |
| 26 | 27 | |
| ... | ... | @@ -917,6 +918,7 @@ |
| 917 | 918 | * @return |
| 918 | 919 | */ |
| 919 | 920 | @PostMapping("signInPatient") |
| 921 | + @TokenRequired | |
| 920 | 922 | public BaseResponse signInPatient(@RequestBody LymsPatient patient) { |
| 921 | 923 | BaseResponse baseResponse = new BaseResponse(); |
| 922 | 924 | baseResponse.setErrorcode(1); |
| ... | ... | @@ -936,60 +938,112 @@ |
| 936 | 938 | } |
| 937 | 939 | return baseResponse; |
| 938 | 940 | } |
| 939 | -// /** | |
| 940 | -// * 小程序关注患者查询 | |
| 941 | -// * | |
| 942 | -// * @param patient | |
| 943 | -// * @return | |
| 944 | -// */ | |
| 945 | -// @GetMapping("getPatientAttention") | |
| 946 | -// public BaseResponse getPatientAttention(LymsPatient patient) { | |
| 947 | -// QueryWrapper<LymsPatient> queryWrapper=new QueryWrapper<>(); | |
| 948 | -// if(StringUtil.isNotEmpty(patient.getIdno())){ | |
| 949 | -// queryWrapper.lambda().eq(LymsPatient::getIdno, patient.getIdno()); | |
| 950 | -// } | |
| 951 | -// if(StringUtil.isNotEmpty(patient.getEnrolmentPhone())){ | |
| 952 | -// queryWrapper.eq("p.enrolment_phone", patient.getEnrolmentPhone()) | |
| 953 | -// .or().eq("pc.mobile", patient.getEnrolmentPhone()); | |
| 954 | -// } | |
| 955 | -// //指定返回列 | |
| 956 | -// queryWrapper.lambda().select(LymsPatient::getId, | |
| 957 | -// LymsPatient::getPname, | |
| 958 | -// LymsPatient::getSex, | |
| 959 | -// LymsPatient::getBirth, | |
| 960 | -// LymsPatient::getIdno, | |
| 961 | -// LymsPatient::getCreatedtime); | |
| 962 | -// LymsPatient resultPatient = lymsPatientService.getPatient(queryWrapper); | |
| 963 | -// | |
| 964 | -// BaseResponse baseResponse = new BaseResponse(); | |
| 965 | -// baseResponse.setErrorcode(0); | |
| 966 | -// baseResponse.setObject(resultPatient); | |
| 967 | -// baseResponse.setErrormsg("成功"); | |
| 968 | -// return baseResponse; | |
| 969 | -// } | |
| 970 | -// | |
| 971 | -// /** | |
| 972 | -// * 小程序关注的患者列表 | |
| 973 | -// * | |
| 974 | -// * @param patient | |
| 975 | -// * @return | |
| 976 | -// */ | |
| 977 | -// @GetMapping("getPatientAttentionList") | |
| 978 | -// public BaseResponse getPatientAttentionList(LymsPatientAttention patientAttention) { | |
| 979 | -// BaseResponse baseResponse = new BaseResponse(); | |
| 980 | -// if (null==patientAttention.getPid()) { | |
| 981 | -// baseResponse.setErrorcode(1); | |
| 982 | -// baseResponse.setErrormsg("参数错误"); | |
| 983 | -// return baseResponse; | |
| 984 | -// } | |
| 985 | -// QueryWrapper<LymsPatientAttention> queryWrapper=Wrappers.query(patientAttention); | |
| 986 | -// //指定返回列 | |
| 987 | -// queryWrapper.lambda().select(LymsPatientAttention::getAttentionId); | |
| 988 | -// List<LymsPatient> ids=lymsPatientAttentionService.listObjs(queryWrapper); | |
| 989 | -// baseResponse.setErrorcode(0); | |
| 990 | -// baseResponse.setObject(ids); | |
| 991 | -// baseResponse.setErrormsg("成功"); | |
| 992 | -// return baseResponse; | |
| 993 | -// } | |
| 941 | + /** | |
| 942 | + * 小程序关注患者查询or是否关注过 | |
| 943 | + * | |
| 944 | + * @param patient | |
| 945 | + * @return | |
| 946 | + */ | |
| 947 | + @GetMapping("getPatientAttention") | |
| 948 | + @TokenRequired | |
| 949 | + public BaseResponse getPatientAttention(LymsPatient patient) { | |
| 950 | + List<Map> result=new ArrayList<>(); | |
| 951 | + if(null!=patient.getId()) { | |
| 952 | + QueryWrapper<LymsPatient> queryWrapper = new QueryWrapper<>(); | |
| 953 | + if (StringUtil.isNotEmpty(patient.getIdno())) { | |
| 954 | + queryWrapper.eq("p.idno", patient.getIdno()); | |
| 955 | + } | |
| 956 | + if (StringUtil.isNotEmpty(patient.getEnrolmentPhone())) { | |
| 957 | + queryWrapper.eq("p.enrolment_phone", patient.getEnrolmentPhone()) | |
| 958 | + .or().eq("pc.mobile", patient.getEnrolmentPhone()); | |
| 959 | + } | |
| 960 | + //指定返回列 | |
| 961 | + queryWrapper.lambda().select(LymsPatient::getId, | |
| 962 | + LymsPatient::getPname, | |
| 963 | + LymsPatient::getSex, | |
| 964 | + LymsPatient::getBirth, | |
| 965 | + LymsPatient::getIdno, | |
| 966 | + LymsPatient::getCreatedtime); | |
| 967 | + result = lymsPatientService.getPatient(queryWrapper); | |
| 968 | + if (CollectionUtils.isNotEmpty(result)) { | |
| 969 | + Iterator<Map> iterator = result.iterator(); | |
| 970 | + while (iterator .hasNext()) { | |
| 971 | + Map map= iterator.next(); | |
| 972 | + if(map.get("id")==patient.getId()){ | |
| 973 | + iterator.remove(); | |
| 974 | + continue; | |
| 975 | + } | |
| 976 | + QueryWrapper<LymsPatientAttention> queryWrapper2 = new QueryWrapper<>(); | |
| 977 | + queryWrapper2.lambda().eq(LymsPatientAttention::getPid, patient.getId()); | |
| 978 | + queryWrapper2.lambda().eq(LymsPatientAttention::getAttentionId, map.get("id")); | |
| 979 | + final int count = lymsPatientAttentionService.count(queryWrapper2); | |
| 980 | + if (count == 0) { | |
| 981 | + map.put("type", 2);//未关注 | |
| 982 | + } else { | |
| 983 | + map.put("type", 1);//已关注 | |
| 984 | + } | |
| 985 | + } | |
| 986 | + } | |
| 987 | + } | |
| 988 | + | |
| 989 | + BaseResponse baseResponse = new BaseResponse(); | |
| 990 | + baseResponse.setErrorcode(0); | |
| 991 | + baseResponse.setObject(result); | |
| 992 | + baseResponse.setErrormsg("成功"); | |
| 993 | + return baseResponse; | |
| 994 | + } | |
| 995 | + | |
| 996 | + /** | |
| 997 | + * 小程序关注的患者列表 | |
| 998 | + * | |
| 999 | + * @param patient | |
| 1000 | + * @return | |
| 1001 | + */ | |
| 1002 | + @GetMapping("getPatientAttentionList") | |
| 1003 | + @TokenRequired | |
| 1004 | + public BaseResponse getPatientAttentionList(LymsPatientAttention patientAttention) { | |
| 1005 | + BaseResponse baseResponse = new BaseResponse(); | |
| 1006 | + if (null==patientAttention.getPid()) { | |
| 1007 | + baseResponse.setErrorcode(1); | |
| 1008 | + baseResponse.setErrormsg("参数错误"); | |
| 1009 | + return baseResponse; | |
| 1010 | + } | |
| 1011 | + QueryWrapper<LymsPatientAttention> queryWrapper=new QueryWrapper<>(); | |
| 1012 | + if(null!=patientAttention.getPid()){ | |
| 1013 | + queryWrapper.eq("pa.pid", patientAttention.getPid()); | |
| 1014 | + } | |
| 1015 | + List<Map> resultList=lymsPatientAttentionService.getPatientList(queryWrapper); | |
| 1016 | + baseResponse.setErrorcode(0); | |
| 1017 | + baseResponse.setObject(resultList); | |
| 1018 | + baseResponse.setErrormsg("成功"); | |
| 1019 | + return baseResponse; | |
| 1020 | + } | |
| 1021 | + /** | |
| 1022 | + * 小程序关注患者 | |
| 1023 | + * | |
| 1024 | + * @param patient | |
| 1025 | + * @return | |
| 1026 | + */ | |
| 1027 | + @PostMapping("addPatientAttention") | |
| 1028 | + @TokenRequired | |
| 1029 | + public BaseResponse addPatientAttention(@RequestBody @Validated LymsPatientAttention patientAttention,BindingResult bindingResult) { | |
| 1030 | + BaseResponse baseResponse = new BaseResponse(); | |
| 1031 | + //对象验证 | |
| 1032 | + if(bindingResult.hasErrors()){ | |
| 1033 | + baseResponse.setErrorcode(1); | |
| 1034 | + for (ObjectError allError : bindingResult.getAllErrors()) { | |
| 1035 | + baseResponse.setErrormsg((StringUtil.isNotEmpty(baseResponse.getErrormsg())?baseResponse.getErrormsg():"")+allError.getDefaultMessage()+";"); | |
| 1036 | + } | |
| 1037 | + return baseResponse; | |
| 1038 | + } | |
| 1039 | + final boolean result = lymsPatientAttentionService.save(patientAttention); | |
| 1040 | + if(!result){ | |
| 1041 | + baseResponse.setErrorcode(1); | |
| 1042 | + baseResponse.setErrormsg("保存异常!"); | |
| 1043 | + } | |
| 1044 | + baseResponse.setErrorcode(0); | |
| 1045 | + baseResponse.setErrormsg("成功"); | |
| 1046 | + return baseResponse; | |
| 1047 | + } | |
| 994 | 1048 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatientAttention.java
View file @
5f179e2
| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | import java.io.Serializable; |
| 8 | 8 | import lombok.Data; |
| 9 | 9 | |
| 10 | +import javax.validation.constraints.NotNull; | |
| 11 | + | |
| 10 | 12 | /** |
| 11 | 13 | * 关注的患者 |
| 12 | 14 | * @TableName lyms_patient_attention |
| 13 | 15 | |
| ... | ... | @@ -18,12 +20,14 @@ |
| 18 | 20 | * 患者id |
| 19 | 21 | */ |
| 20 | 22 | @TableField(value = "pid") |
| 23 | + @NotNull(message = "pid不能为空") | |
| 21 | 24 | private Integer pid; |
| 22 | 25 | |
| 23 | 26 | /** |
| 24 | 27 | * 关注的患者id |
| 25 | 28 | */ |
| 26 | 29 | @TableField(value = "attention_id") |
| 30 | + @NotNull(message = "attention_id不能为空") | |
| 27 | 31 | private Integer attentionId; |
| 28 | 32 | |
| 29 | 33 | @TableField(exist = false) |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientAttentionMapper.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.mapper; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 4 | +import com.lyms.talkonlineweb.domain.LymsPatient; | |
| 3 | 5 | import com.lyms.talkonlineweb.domain.LymsPatientAttention; |
| 4 | 6 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | +import org.apache.ibatis.annotations.Param; | |
| 9 | +import org.apache.ibatis.annotations.Select; | |
| 5 | 10 | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | + | |
| 6 | 14 | /** |
| 7 | 15 | * @Entity com.lyms.talkonlineweb.domain.LymsPatientAttention |
| 8 | 16 | */ |
| 17 | +@Mapper | |
| 9 | 18 | public interface LymsPatientAttentionMapper extends BaseMapper<LymsPatientAttention> { |
| 10 | 19 | |
| 20 | + @Select({ | |
| 21 | + "<script>", | |
| 22 | + "SELECT "+ | |
| 23 | + "p.id,p.pname,p.idno,p.sex,p.birth,p.createdtime " + | |
| 24 | + "FROM "+ | |
| 25 | + "lyms_patient p "+ | |
| 26 | + "INNER JOIN lyms_patient_attention pa ON p.id = pa.attention_id "+ | |
| 27 | + "<where>${ew.sqlSegment}</where> "+ | |
| 28 | + "</script>" | |
| 29 | + }) | |
| 30 | + List<Map> getPatientList(@Param("ew") QueryWrapper<LymsPatientAttention> ew); | |
| 11 | 31 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientMapper.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.mapper; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 3 | 4 | import com.lyms.talkonlineweb.domain.LymsPatient; |
| 4 | 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | 6 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -29,5 +30,16 @@ |
| 29 | 30 | "GROUP BY pc.hid\n" + |
| 30 | 31 | "order by pc.createdtime desc") |
| 31 | 32 | List<Map<String,String>> getAppPatientHospital(@Param("patientId") Integer patientId); |
| 33 | + | |
| 34 | + @Select({"<script>", | |
| 35 | + "SELECT "+ | |
| 36 | + "p.id,p.pname,p.idno,p.sex,p.birth,p.createdtime " + | |
| 37 | + "FROM "+ | |
| 38 | + "lyms_patient p "+ | |
| 39 | + "LEFT JOIN lyms_pcase pc ON p.id = pc.pid "+ | |
| 40 | + "<where>${ew.sqlSegment}</where> "+ | |
| 41 | + "GROUP BY p.idno "+ | |
| 42 | + "</script>"}) | |
| 43 | + List<Map> getPatient(@Param("ew")QueryWrapper ew); | |
| 32 | 44 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientAttentionService.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.service; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 4 | +import com.lyms.talkonlineweb.domain.LymsPatient; | |
| 3 | 5 | import com.lyms.talkonlineweb.domain.LymsPatientAttention; |
| 4 | 6 | import com.baomidou.mybatisplus.extension.service.IService; |
| 5 | 7 | |
| 8 | +import java.util.List; | |
| 9 | +import java.util.Map; | |
| 10 | + | |
| 6 | 11 | /** |
| 7 | 12 | * |
| 8 | 13 | */ |
| 9 | 14 | public interface LymsPatientAttentionService extends IService<LymsPatientAttention> { |
| 10 | 15 | |
| 16 | + List<Map> getPatientList(QueryWrapper<LymsPatientAttention> queryWrapper); | |
| 11 | 17 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientService.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.service; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 3 | 4 | import com.lyms.talkonlineweb.domain.LymsPatient; |
| 4 | 5 | import com.baomidou.mybatisplus.extension.service.IService; |
| 5 | 6 | |
| ... | ... | @@ -12,5 +13,7 @@ |
| 12 | 13 | public interface LymsPatientService extends IService<LymsPatient> { |
| 13 | 14 | |
| 14 | 15 | List<Map<String,String>> getAppPatientHospital(Integer patientId); |
| 16 | + | |
| 17 | + List<Map> getPatient(QueryWrapper queryWrapper); | |
| 15 | 18 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientAttentionServiceImpl.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.service.impl; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 3 | 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 5 | +import com.lyms.talkonlineweb.domain.LymsPatient; | |
| 4 | 6 | import com.lyms.talkonlineweb.domain.LymsPatientAttention; |
| 5 | 7 | import com.lyms.talkonlineweb.service.LymsPatientAttentionService; |
| 6 | 8 | import com.lyms.talkonlineweb.mapper.LymsPatientAttentionMapper; |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | 10 | import org.springframework.stereotype.Service; |
| 8 | 11 | |
| 12 | +import java.util.List; | |
| 13 | +import java.util.Map; | |
| 14 | + | |
| 9 | 15 | /** |
| 10 | 16 | * |
| 11 | 17 | */ |
| 12 | 18 | @Service |
| 13 | 19 | public class LymsPatientAttentionServiceImpl extends ServiceImpl<LymsPatientAttentionMapper, LymsPatientAttention> |
| 14 | 20 | implements LymsPatientAttentionService{ |
| 15 | - | |
| 21 | + @Autowired | |
| 22 | + LymsPatientAttentionMapper lymsPatientAttentionMapper; | |
| 23 | + @Override | |
| 24 | + public List<Map> getPatientList(QueryWrapper<LymsPatientAttention> queryWrapper) { | |
| 25 | + return lymsPatientAttentionMapper.getPatientList(queryWrapper); | |
| 26 | + } | |
| 16 | 27 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientServiceImpl.java
View file @
5f179e2
| 1 | 1 | package com.lyms.talkonlineweb.service.impl; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 3 | 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 4 | 5 | import com.lyms.talkonlineweb.domain.LymsPatient; |
| 5 | 6 | import com.lyms.talkonlineweb.service.LymsPatientService; |
| ... | ... | @@ -22,6 +23,11 @@ |
| 22 | 23 | @Override |
| 23 | 24 | public List<Map<String,String>> getAppPatientHospital(Integer patientId) { |
| 24 | 25 | return lymsPatientMapper.getAppPatientHospital(patientId); |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public List<Map> getPatient(QueryWrapper queryWrapper) { | |
| 30 | + return lymsPatientMapper.getPatient(queryWrapper); | |
| 25 | 31 | } |
| 26 | 32 | } |