Ver código fonte

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 anos atrás
pai
commit
c16f8eeb49

+ 18 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -8,11 +8,14 @@ import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
@ -42,9 +45,10 @@ public class FamilyMemberService extends BaseService {
     * @param patient 患者
     * @param member  成员
     * @param captcha 验证码
     * @param member  成员
     * @return
     */
    public int addMember(String patient, String member, String captcha, int relation) {
    public int addMember(String patient, String member, String captcha, String password, int relation) {
        Patient p = patientDao.findByCode(patient);
        Patient m = patientDao.findByCode(member);
@ -56,9 +60,15 @@ public class FamilyMemberService extends BaseService {
            return -2;
        }
        // 验证码验证
        if (smsService.check(m.getMobile(), 9, captcha) != 1) {
        if (StringUtils.isNotEmpty(captcha) && smsService.check(m.getMobile(), 9, captcha) != 1) {
            return -3;
        }
        if (StringUtils.isNotEmpty(password)) {
            String loginPassword = MD5.GetMD5Code(password + m.getSalt());
            if (!loginPassword.equals(m.getPassword())) {
                return -3;
            }
        }
        // 添加自己与对方的关系
        PatientFamilyMember fm = memberDao.findByPatientAndFamilyMember(patient, member);
        // 家庭关系已存在时,不重复添加
@ -100,6 +110,7 @@ public class FamilyMemberService extends BaseService {
     * @param relation 关系
     * @return
     */
    public int modifyFamilyRelation(String patient, String member, int relation) {
        Patient p = patientDao.findByCode(patient);
        Patient m = patientDao.findByCode(member);
@ -176,10 +187,12 @@ public class FamilyMemberService extends BaseService {
        Patient p = patientDao.findByIdcard(idcard);
        if (p == null) {
            result.put("isRegister",0);
            result.put("isRegister", 0);
        } else {
            result.put("isRegister",1);
            result.put("patient",p);
            result.put("isRegister", 1);
            result.put("mobile", p.getMobile());
            result.put("name", p.getName());
            result.put("code", p.getCode());
        }
        return result;

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java

@ -95,7 +95,7 @@ public class SMSService extends BaseService {
            sms.setContent("【厦门市民健康系统】您绑定手机号的验证码为:" + captcha);
        } else if (type == 10) {
            // 新手机号绑定验证
            sms.setContent("【厦门市民健康系统】XXX欲添加您为家人,验证码为:" + captcha + "。如您同意,可告知其验证码;如其非您的家人,请忽略本短信。");
            sms.setContent("【厦门市民健康系统】XXX欲添加您为家人,验证码为:" + captcha + "。如其非您的家人,请忽略本短信。");
        } else {
            // 其他验证码
            sms.setContent("验证码:" + captcha);

+ 7 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -11,6 +11,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
@ -36,26 +37,27 @@ public class FamilyMemberController extends BaseController {
     */
    @RequestMapping(value = "/member_add", method = RequestMethod.POST)
    @ApiOperation(value = "添加成员")
    public String addFamilyMember(String member, String captcha, int relation) {
    public String addFamilyMember(String member, @RequestParam(required = false) String captcha,
                                  @RequestParam(required = false) String password, int relation) {
        try {
            if (StringUtils.isEmpty(member)) {
                return error(-1, "添加成员不能为空");
            }
            if (StringUtils.isEmpty(captcha)) {
                return error(-1, "验证码不能为空");
            if (StringUtils.isEmpty(captcha) && StringUtils.isEmpty(password)) {
                return error(-1, "验证码或密码不能为空");
            }
            if (relation < 0 || relation > 6) {
                return error(-1, "家庭关系无效");
            }
            int result = familyMemberService.addMember(getUID(), member, captcha, relation);
            int result = familyMemberService.addMember(getUID(), member, captcha, password, relation);
            if (result == -1) {
                return error(-1, "居民信息查询失败");
            } else if (result == -2) {
                return error(-1, "该成员未注册");
            } else if (result == -3) {
                return error(-1, "验证码无效");
                return error(-1, StringUtils.isNotEmpty(captcha) ? "验证码错误" : "密码错误");
            } else if (result == -4) {
                return error(-1, "该家庭成员已存在");
            } else {