Compare commits

..

No commits in common. 'c7c44479205eb4d839fa8ed08798a00362b83203' and '0cfd56a7fd454f496edebe551a36c10397f66091' have entirely different histories.

@ -209,9 +209,8 @@ public class AppController extends BaseController
logger.info("add patient param is {} ", appPatientReq);
TPatient tPatient = new TPatient();
BeanUtils.copyProperties(appPatientReq, tPatient);
tPatient.setDelFlag("0");
// 查询患者信息
TPatient currentPatient = tPatientService.queryTPatientByPhoneAndName(tPatient);
TPatient currentPatient = tPatientService.queryTPatient(tPatient);
if (Objects.nonNull(currentPatient))
{
//患者信息已存在 新增诊断记录
@ -269,11 +268,6 @@ public class AppController extends BaseController
logger.info("modify patient param is {} ", appPatientReq);
TPatient tPatient = new TPatient();
BeanUtils.copyProperties(appPatientReq, tPatient);
tPatient.setDelFlag("0");
TPatient currentPatient = tPatientService.queryTPatientByPhoneAndName(tPatient);
if (Objects.nonNull(currentPatient) && currentPatient.getId().compareTo(appPatientReq.getId()) != 0) {
return AjaxResult.error("手机号下已存在该患者。");
}
return AjaxResult.success(tPatientService.updateTPatient(tPatient));
}

@ -6,7 +6,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.req.GetOpenidReq;
import com.ruoyi.system.domain.req.LoginForAppReq;
import com.ruoyi.system.domain.req.LoginForMpReq;
import com.ruoyi.system.domain.req.LoginForMultiPatientReq;
import com.ruoyi.system.domain.resp.GetOpenidResp;
import com.ruoyi.system.service.IWechatService;
import org.slf4j.Logger;
@ -53,15 +52,6 @@ public class WechatLoginController extends BaseController {
return AjaxResult.success(map);
}
@PostMapping("/for/multi/patient")
public AjaxResult loginForMultiPatient(@RequestBody @Validated LoginForMultiPatientReq req) {
logger.info("loginForMultiPatient req :{}", req);
String token = iWechatService.loginForMultiPatient(req);
Map map = new HashMap<>();
map.put(Constants.TOKEN, token);
return AjaxResult.success(map);
}
@PostMapping("/get/unionid")
public AjaxResult getWechatUnionInfo(@RequestBody @Validated GetOpenidReq getOpenidReq, HttpServletRequest request) {
logger.info("wechat获取unionid, req = [{}]", getOpenidReq);

@ -1,39 +0,0 @@
package com.ruoyi.system.domain.req;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
public class LoginForMultiPatientReq implements Serializable {
private static final long serialVersionUID = -2077202239424966485L;
@NotBlank(message = "openid不能为空")
private String openId;
@NotNull(message = "患者id不能为空")
private Long patientId;
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public Long getPatientId() {
return patientId;
}
public void setPatientId(Long patientId) {
this.patientId = patientId;
}
@Override
public String toString() {
return "LoginForMultiPatientReq{" +
"openId='" + openId + '\'' +
", patientId='" + patientId + '\'' +
'}';
}
}

@ -1,9 +1,6 @@
package com.ruoyi.system.domain.resp;
import com.ruoyi.system.domain.TPatient;
import java.io.Serializable;
import java.util.List;
public class GetOpenidResp implements Serializable {
private static final long serialVersionUID = -8328911573370172974L;
@ -16,18 +13,6 @@ public class GetOpenidResp implements Serializable {
private String unionid;
private List<TPatient> patients;
private Boolean multiPatient = false;
public List<TPatient> getPatients() {
return patients;
}
public void setPatients(List<TPatient> patients) {
this.patients = patients;
}
public String getOpenid() {
return openid;
}
@ -59,12 +44,4 @@ public class GetOpenidResp implements Serializable {
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public Boolean getMultiPatient() {
return multiPatient;
}
public void setMultiPatient(Boolean multiPatient) {
this.multiPatient = multiPatient;
}
}

@ -2,7 +2,6 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.TPatient;
import com.ruoyi.system.domain.req.LoginForMultiPatientReq;
import com.ruoyi.system.domain.req.PcTPatintQueryByPageReq;
import com.ruoyi.system.domain.resp.PcTPatientQueryByPageResp;
import tk.mybatis.mapper.common.Mapper;
@ -63,13 +62,9 @@ public interface TPatientMapper
*/
public int deleteTPatientByIds(Long[] ids);
public TPatient queryTPatientByPhoneAndName(TPatient tPatient);
public TPatient queryTPatient(TPatient tPatient);
List<PcTPatientQueryByPageResp> queryByPage(PcTPatintQueryByPageReq pcTPatintQueryByPageReq);
int checkPhoneUnique(String phone);
public List<TPatient> querySamePhonePatientsById(Long id);
public TPatient queryPatientByOpenidAndPatientId(LoginForMultiPatientReq loginForMultiPatientReq);
}

@ -65,5 +65,5 @@ public interface ITPatientService
String checkPhoneUnique(String phone);
public TPatient queryTPatientByPhoneAndName(TPatient tPatient);
public TPatient queryTPatient(TPatient tPatient);
}

@ -3,7 +3,6 @@ package com.ruoyi.system.service;
import com.ruoyi.system.domain.req.GetOpenidReq;
import com.ruoyi.system.domain.req.LoginForAppReq;
import com.ruoyi.system.domain.req.LoginForMpReq;
import com.ruoyi.system.domain.req.LoginForMultiPatientReq;
import com.ruoyi.system.domain.resp.GetOpenidResp;
import javax.servlet.http.HttpServletRequest;
@ -17,6 +16,4 @@ public interface IWechatService {
String loginForMp(LoginForMpReq req);
String loginForApp(LoginForAppReq req);
String loginForMultiPatient(LoginForMultiPatientReq req);
}

@ -136,7 +136,7 @@ public class TPatientServiceImpl implements ITPatientService
}
@Override
public TPatient queryTPatientByPhoneAndName(TPatient tPatient) {
return tPatientMapper.queryTPatientByPhoneAndName(tPatient);
public TPatient queryTPatient(TPatient tPatient) {
return tPatientMapper.queryTPatient(tPatient);
}
}

@ -17,7 +17,6 @@ import com.ruoyi.system.domain.TWechatUser;
import com.ruoyi.system.domain.req.GetOpenidReq;
import com.ruoyi.system.domain.req.LoginForAppReq;
import com.ruoyi.system.domain.req.LoginForMpReq;
import com.ruoyi.system.domain.req.LoginForMultiPatientReq;
import com.ruoyi.system.domain.resp.GetOpenidResp;
import com.ruoyi.system.mapper.TDoctorMapper;
import com.ruoyi.system.mapper.TPatientMapper;
@ -30,11 +29,13 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Service
public class WechatServiceImpl implements IWechatService {
@ -82,19 +83,11 @@ public class WechatServiceImpl implements IWechatService {
if (Objects.isNull(wechatUser.getUserId())) {
resp.setBindFlag(false);
} else {
// 已绑定患者
// 已绑定信息 直接登录
resp.setBindFlag(true);
// 查询该患者手机号是否存在多条数据
List<TPatient> patients = tPatientMapper.querySamePhonePatientsById(wechatUser.getUserId());
if (CollectionUtils.isEmpty(patients)) {
resp.setBindFlag(false);
} else if (!CollectionUtils.isEmpty(patients) && patients.size() == 1) {
String token = buildTokenByPatient(patients.get(0));
resp.setToken(token);
} else {
resp.setMultiPatient(true);
resp.setPatients(patients);
}
TPatient tPatient = tPatientMapper.selectTPatientById(wechatUser.getUserId());
String token = buildTokenByPatient(tPatient);
resp.setToken(token);
}
resp.setOpenid(openid);
return resp;
@ -124,7 +117,7 @@ public class WechatServiceImpl implements IWechatService {
// 查询手机号是否存在患者信息
TPatient tPatient = new TPatient();
BeanUtils.copyProperties(req, tPatient);
TPatient currentPatient = tPatientMapper.queryTPatientByPhoneAndName(tPatient);
TPatient currentPatient = tPatientMapper.queryTPatient(tPatient);
TWechatUser wechatUser = new TWechatUser();
if (Objects.nonNull(currentPatient)) {
// 存在 需要把患者信息更新 并绑定openid
@ -209,17 +202,6 @@ public class WechatServiceImpl implements IWechatService {
return token;
}
@Override
public String loginForMultiPatient(LoginForMultiPatientReq req) {
TPatient tPatient = tPatientMapper.queryPatientByOpenidAndPatientId(req);
String token = "";
if (Objects.nonNull(tPatient)) {
logger.info("query patient info :{}", tPatient);
token = buildTokenByPatient(tPatient);
}
return token;
}
private String queryOpenid(GetOpenidReq req){
String url = String.format(WechatKeys.MP_CODE_TO_OPENID_URL, appId, appSecret, req.getCode());
String json = HttpUtils.sendGet(url);

@ -114,18 +114,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="queryTPatientByPhoneAndName" parameterType="com.ruoyi.system.domain.TPatient" resultMap="TPatientResult">
<select id="queryTPatient" parameterType="com.ruoyi.system.domain.TPatient" resultMap="TPatientResult">
<include refid="selectTPatientVo"/>
<where>
<if test="delFlag != null and delFlag != ''">
and delFlag = #{delFlag}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="phone != null and phone != ''">
phone = #{phone}
</if>
</where>
</select>
@ -175,22 +169,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="checkPhoneUnique" parameterType="String" resultType="int">
select count(1) from t_patient where phone = #{phone} limit 1
</select>
<select id="querySamePhonePatientsById" parameterType="java.lang.Long" resultMap="TPatientResult">
<include refid="selectTPatientVo"/>
where del_flag = '0'
and phone = (select phone from t_patient where id = #{id})
</select>
<select id="queryPatientByOpenidAndPatientId" parameterType="com.ruoyi.system.domain.req.LoginForMultiPatientReq" resultMap="TPatientResult">
<include refid="selectTPatientVo"/>
where phone = (select phone from t_patient where id = (
SELECT
user_id
FROM
t_wechat_user
WHERE
openid = #{openId}
)) and id = #{patientId} and del_flag = '0'
</select>
</mapper>

Loading…
Cancel
Save