|
@ -0,0 +1,172 @@
|
|
|
package com.yihu.wlyy.web.patient.family;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonAnyFormatVisitor;
|
|
|
import com.yihu.wlyy.service.app.family.FamilyMemberService;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
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.RestController;
|
|
|
|
|
|
/**
|
|
|
* 家庭关系成员控制器
|
|
|
* <p>
|
|
|
* Created by lyr-pc on 2016/10/18.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/patient/family")
|
|
|
@Api(description = "家庭成员")
|
|
|
public class FamilyMemberController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
FamilyMemberService familyMemberService;
|
|
|
|
|
|
/**
|
|
|
* 添加成员
|
|
|
*
|
|
|
* @param member 成员code
|
|
|
* @param captcha 验证码
|
|
|
* @param relation 关系
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/member_add", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "添加成员")
|
|
|
public String addFamilyMember(String member, String captcha, int relation) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(member)) {
|
|
|
return error(-1, "添加成员不能为空");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(captcha)) {
|
|
|
return error(-1, "验证码不能为空");
|
|
|
}
|
|
|
if (relation < 0 || relation > 6) {
|
|
|
return error(-1, "家庭关系无效");
|
|
|
}
|
|
|
|
|
|
int result = familyMemberService.addMember(getUID(), member, captcha, relation);
|
|
|
|
|
|
if (result == -1) {
|
|
|
return error(-1, "居民信息查询失败");
|
|
|
} else if (result == -2) {
|
|
|
return error(-1, "该成员未注册");
|
|
|
} else if (result == -3) {
|
|
|
return error(-1, "验证码无效");
|
|
|
} else if (result == -4) {
|
|
|
return error(-1, "该家庭成员已存在");
|
|
|
} else {
|
|
|
return write(200, "添加成功");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "添加失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新家庭关系
|
|
|
*
|
|
|
* @param member 成员code
|
|
|
* @param relation 家庭关系
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/relation_update", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "家庭成员关系修改")
|
|
|
public String modifyFamilyRelation(String member, int relation) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(member)) {
|
|
|
return error(-1, "添加成员不能为空");
|
|
|
}
|
|
|
if (relation < 0 || relation > 6) {
|
|
|
return error(-1, "家庭关系无效");
|
|
|
}
|
|
|
|
|
|
int result = familyMemberService.modifyFamilyRelation(getUID(), member, relation);
|
|
|
|
|
|
if (result == -1) {
|
|
|
return error(-1, "居民信息查询失败");
|
|
|
} else if (result == -2) {
|
|
|
return error(-1, "该成员未注册");
|
|
|
} else if (result == -3) {
|
|
|
return error(-1, "与该成员的关系不存在");
|
|
|
} else {
|
|
|
return write(200, "更新成功");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "更新失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除成员
|
|
|
*
|
|
|
* @param member
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/member_delete", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "家庭成员删除")
|
|
|
public String deleteMember(String member) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(member)) {
|
|
|
return error(-1, "成员不能为空");
|
|
|
}
|
|
|
|
|
|
int result = familyMemberService.deleteMember(getUID(), member);
|
|
|
|
|
|
if (result == -1) {
|
|
|
return error(-1, "与该成员的关系不存在");
|
|
|
} else {
|
|
|
return write(200, "删除成功");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 家庭成员查询
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/members", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "家庭成员查询")
|
|
|
public String getPatientFamilyMembers() {
|
|
|
try {
|
|
|
JSONArray result = familyMemberService.getPatientFamilyMembers(getUID());
|
|
|
|
|
|
return write(200, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据身份证号查询居民是否注册
|
|
|
*
|
|
|
* @param idcard 身份证号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/is_register", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "家庭成员查询")
|
|
|
public String isRegister(String idcard) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(idcard)) {
|
|
|
return error(-1, "身份证号不能为空");
|
|
|
}
|
|
|
|
|
|
JSONObject result = familyMemberService.isRegister(idcard);
|
|
|
|
|
|
return write(-1, "查询成功", "data", result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
}
|