|
@@ -1,19 +1,15 @@
|
|
|
package com.care.client.controller;
|
|
|
|
|
|
import com.care.client.service.PassportService;
|
|
|
-import com.care.client.service.PinanbaoService;
|
|
|
+import com.care.client.service.PinanbaoContactService;
|
|
|
import com.care.client.vo.HouseContactVO;
|
|
|
import com.care.client.vo.MemberInfoVO;
|
|
|
-import com.care.common.annotation.Permission;
|
|
|
import com.care.common.exception.BDException;
|
|
|
import com.care.common.util.Result;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -31,7 +27,7 @@ import java.util.List;
|
|
|
public class ContactApiController {
|
|
|
|
|
|
@Resource
|
|
|
- private PinanbaoService pinanbaoService;
|
|
|
+ private PinanbaoContactService pinanbaoContactService;
|
|
|
@Resource
|
|
|
private PassportService passportService;
|
|
|
|
|
@@ -45,7 +41,7 @@ public class ContactApiController {
|
|
|
public Result<List<HouseContactVO>> myHouseContactList(HttpServletRequest request, @RequestHeader(value = "token") String token){
|
|
|
MemberInfoVO current = passportService.checkToken(token);
|
|
|
try {
|
|
|
- List<HouseContactVO> datas = pinanbaoService.queryContactByMemberId(current.getId());
|
|
|
+ List<HouseContactVO> datas = pinanbaoContactService.queryContactByMemberId(current.getId());
|
|
|
return Result.success(datas);
|
|
|
}catch (BDException e) {
|
|
|
return Result.error(e.getMessage());
|
|
@@ -55,5 +51,76 @@ public class ContactApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 我的紧急联系人详情
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/my/getMyContactInfo")
|
|
|
+ @ApiOperation(tags = {"我的紧急联系人"},value = "紧急联系人详情 -- 二期新增")
|
|
|
+ public Result<HouseContactVO> getMyContactInfo(@RequestHeader(value = "token") String token,
|
|
|
+ @RequestParam("id") Long id){
|
|
|
+ try {
|
|
|
+ return Result.success(this.pinanbaoContactService.getContactInfo(id));
|
|
|
+ }catch (BDException e) {
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("紧急联系人: 查询详情出现异常",e);
|
|
|
+ return Result.error( "获取失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/my/add")
|
|
|
+ @ApiOperation(tags = {"我的紧急联系人"},value = "紧急联系人新增 -- 二期新增")
|
|
|
+ public Result<Object> addMyContact(@RequestHeader("token") String token,
|
|
|
+ @RequestBody HouseContactVO vo){
|
|
|
+ try {
|
|
|
+ MemberInfoVO current = passportService.checkToken(token);
|
|
|
+ if(this.pinanbaoContactService.createMyContact(current.getId(),vo)){
|
|
|
+ return Result.success("新增成功!");
|
|
|
+ } else {
|
|
|
+ return Result.error("新增失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("新增紧急联系人-出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("紧急联系人: 新增紧急联系人出现异常",e);
|
|
|
+ return Result.error("新增失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/my/update")
|
|
|
+ @ApiOperation(tags = {"我的紧急联系人"},value = "紧急联系人修改 -- 二期新增")
|
|
|
+ public Result<Object> updateMyContact(@RequestHeader("token") String token,
|
|
|
+ @RequestBody HouseContactVO vo){
|
|
|
+ try {
|
|
|
+ if(this.pinanbaoContactService.updateMyContact(vo)){
|
|
|
+ return Result.success("修改成功!");
|
|
|
+ } else {
|
|
|
+ return Result.error("修改失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("修改紧急联系人-出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("紧急联系人: 修改紧急联系人出现异常",e);
|
|
|
+ return Result.error("修改失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/my/delete/{id}")
|
|
|
+ @ApiOperation(tags = {"我的紧急联系人"},value = "删除紧急联系人 -- 二期新增")
|
|
|
+ public Result<Object> deleteMyContact(HttpServletRequest request,@RequestHeader("token") String token,
|
|
|
+ @PathVariable("id") Long id) {
|
|
|
+ try {
|
|
|
+ this.pinanbaoContactService.deleteById(id);
|
|
|
+ return Result.success("删除成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("紧急联系人: 删除紧急联系人出现异常", e);
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|