AdminOrgBaiscInfoApiController.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package com.goafanti.admin.controller;
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import java.util.UUID;
  6. import javax.annotation.Resource;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import com.alibaba.fastjson.JSON;
  13. import com.alibaba.fastjson.JSONArray;
  14. import com.goafanti.common.bo.Result;
  15. import com.goafanti.common.constant.ErrorConstants;
  16. import com.goafanti.common.controller.CertifyApiController;
  17. import com.goafanti.common.enums.DeleteStatus;
  18. import com.goafanti.common.model.LegalPersonOwnership;
  19. import com.goafanti.user.service.LegalPersonOwnershipService;
  20. import com.goafanti.user.service.NatureOwnershipService;
  21. @Controller
  22. @RequestMapping(value = "/api/admin/basic")
  23. public class AdminOrgBaiscInfoApiController extends CertifyApiController {
  24. @Resource
  25. private LegalPersonOwnershipService legalPersonOwnershipService;
  26. @Resource
  27. private NatureOwnershipService natureOwnershipService;
  28. /**
  29. * 法人股权人列表
  30. */
  31. @RequestMapping(value = "/listLegalPerson", method = RequestMethod.GET)
  32. public Result listLegalPerson(String uid) {
  33. Result res = new Result();
  34. if (StringUtils.isBlank(uid)) {
  35. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  36. return res;
  37. }
  38. res.setData(legalPersonOwnershipService.selectByUid(uid));
  39. return res;
  40. }
  41. /**
  42. * 法人股权人保存修改
  43. * @return
  44. */
  45. @RequestMapping(value = "/legalPerson", method = RequestMethod.POST)
  46. public Result legalPerson(String data){
  47. Result res = new Result();
  48. JSONArray ja = (JSONArray) JSON.parse(data);
  49. if (ja != null && !ja.isEmpty()) {
  50. List<LegalPersonOwnership> lpo = new ArrayList<LegalPersonOwnership>();
  51. for (int idx = 0; idx < ja.size(); idx++) {
  52. lpo.add(ja.getJSONObject(idx).toJavaObject(LegalPersonOwnership.class));
  53. }
  54. for (LegalPersonOwnership l : lpo){
  55. if (StringUtils.isBlank(l.getId())){
  56. l.setId(UUID.randomUUID().toString());
  57. }
  58. if (null == l.getDeletedSign()){
  59. l.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  60. }
  61. }
  62. res.setData(legalPersonOwnershipService.batchInsert(lpo));
  63. } else {
  64. res.getError().add(buildError("", "参数格式不正确"));
  65. }
  66. return res;
  67. }
  68. /**
  69. * 删除自然股权人
  70. *
  71. * @param ids
  72. * @return
  73. */
  74. @RequestMapping(value = "/deleteLegalPerson", method = RequestMethod.POST)
  75. public Result deleteLegalPerson(@RequestParam(name = "ids[]", required = false) String[] ids) {
  76. Result res = new Result();
  77. if (ids == null || ids.length < 1) {
  78. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  79. } else {
  80. res.setData(legalPersonOwnershipService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
  81. }
  82. return res;
  83. }
  84. /**
  85. * 自然人股权列表
  86. * @param uid
  87. * @return
  88. */
  89. @RequestMapping(value = "/listNature", method = RequestMethod.GET)
  90. public Result listNature(String uid) {
  91. Result res = new Result();
  92. if (StringUtils.isBlank(uid)) {
  93. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  94. return res;
  95. }
  96. res.setData(natureOwnershipService.selectByUid(uid));
  97. return res;
  98. }
  99. /**
  100. * 删除自然人股权
  101. * @param ids
  102. * @return
  103. */
  104. @RequestMapping(value = "/deleteNature", method = RequestMethod.POST)
  105. public Result deleteNature(@RequestParam(name = "ids[]", required = false) String[] ids) {
  106. Result res = new Result();
  107. if (ids == null || ids.length < 1) {
  108. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  109. } else {
  110. res.setData(natureOwnershipService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
  111. }
  112. return res;
  113. }
  114. }