|
|
@@ -0,0 +1,287 @@
|
|
|
+package com.goafanti.user.controller;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.time.DateUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.AFTConstants;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.enums.DeleteStatus;
|
|
|
+import com.goafanti.common.enums.OrgBasicInfoFields;
|
|
|
+import com.goafanti.common.model.LegalPersonOwnership;
|
|
|
+import com.goafanti.common.model.NatureOwnership;
|
|
|
+import com.goafanti.common.model.OrgHumanResource;
|
|
|
+import com.goafanti.common.model.OrganizationIdentity;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import com.goafanti.user.bo.InputOrgBasicInfo;
|
|
|
+import com.goafanti.user.service.LegalPersonOwnershipService;
|
|
|
+import com.goafanti.user.service.NatureOwnershipService;
|
|
|
+import com.goafanti.user.service.OrganizationIdentityService;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "/api/user/basic")
|
|
|
+public class UserBasicInfoController extends CertifyApiController{
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private LegalPersonOwnershipService legalPersonOwnershipService;
|
|
|
+ @Resource
|
|
|
+ private NatureOwnershipService natureOwnershipService;
|
|
|
+ @Resource
|
|
|
+ private OrganizationIdentityService organizationIdentityService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业基本信息保存
|
|
|
+ *
|
|
|
+ * @param info
|
|
|
+ * @param bindingResult
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/disposeInfo", method = RequestMethod.POST)
|
|
|
+ public Result disposeInfo(@Valid InputOrgBasicInfo info, BindingResult bindingResult,
|
|
|
+ String listedDateFormattedDate, String registrationTimeFormattedDate) {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ OrgBasicInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(info.getUid())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ Date listedDate = null;
|
|
|
+ Date registrationTime = null;
|
|
|
+ if (!StringUtils.isBlank(listedDateFormattedDate)) {
|
|
|
+ try {
|
|
|
+ listedDate = DateUtils.parseDate(listedDateFormattedDate, AFTConstants.YYYYMMDD);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "上市时间"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isBlank(registrationTimeFormattedDate)) {
|
|
|
+ try {
|
|
|
+ registrationTime = DateUtils.parseDate(registrationTimeFormattedDate, AFTConstants.YYYYMMDD);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "注册时间"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ OrganizationIdentity oi = new OrganizationIdentity();
|
|
|
+ OrgHumanResource ohr = new OrgHumanResource();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(info, oi);
|
|
|
+ BeanUtils.copyProperties(info, ohr);
|
|
|
+
|
|
|
+ if (null != listedDate) {
|
|
|
+ oi.setListedDate(listedDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != registrationTime) {
|
|
|
+ oi.setRegistrationTime(registrationTime);
|
|
|
+ }
|
|
|
+ ohr.setId(info.getHid());
|
|
|
+
|
|
|
+ organizationIdentityService.saveBasicInfo(oi, ohr);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业基本信息入口
|
|
|
+ *
|
|
|
+ * @param uid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info", method = RequestMethod.GET)
|
|
|
+ public Result info() {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ res.setData(organizationIdentityService.selectBasicInfo(TokenManager.getUserId(), now.get(Calendar.YEAR) - 1));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 法人股权列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/listLegalPerson", method = RequestMethod.GET)
|
|
|
+ public Result listLegalPerson() {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.setData(legalPersonOwnershipService.selectByUid(TokenManager.getUserId()));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 法人股权保存修改
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/legalPerson", method = RequestMethod.POST)
|
|
|
+ public Result legalPerson(String data) {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ JSONArray ja = (JSONArray) JSON.parse(data);
|
|
|
+ if (ja != null && !ja.isEmpty()) {
|
|
|
+ List<LegalPersonOwnership> lpo = new ArrayList<LegalPersonOwnership>();
|
|
|
+ for (int idx = 0; idx < ja.size(); idx++) {
|
|
|
+ lpo.add(ja.getJSONObject(idx).toJavaObject(LegalPersonOwnership.class));
|
|
|
+ }
|
|
|
+ for (LegalPersonOwnership l : lpo) {
|
|
|
+ if (StringUtils.isBlank(l.getUid())){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(l.getId())) {
|
|
|
+ l.setId(UUID.randomUUID().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == l.getDeletedSign()) {
|
|
|
+ l.setDeletedSign(DeleteStatus.UNDELETE.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.setData(legalPersonOwnershipService.batchInsert(lpo));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError("", "参数格式不正确"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除法人股权人
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteLegalPerson", method = RequestMethod.POST)
|
|
|
+ public Result deleteLegalPerson(@RequestParam(name = "ids[]", required = false) String[] ids) {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (ids == null || ids.length < 1) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
|
|
|
+ } else {
|
|
|
+ res.setData(legalPersonOwnershipService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自然人股权列表
|
|
|
+ *
|
|
|
+ * @param uid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/listNature", method = RequestMethod.GET)
|
|
|
+ public Result listNature() {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.setData(natureOwnershipService.selectByUid(TokenManager.getUserId()));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除自然人股权
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteNature", method = RequestMethod.POST)
|
|
|
+ public Result deleteNature(@RequestParam(name = "ids[]", required = false) String[] ids) {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (ids == null || ids.length < 1) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
|
|
|
+ } else {
|
|
|
+ res.setData(natureOwnershipService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自然人股权保存修改
|
|
|
+ *
|
|
|
+ * @param data
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/nature", method = RequestMethod.POST)
|
|
|
+ public Result nature(String data) {
|
|
|
+ Result res = new Result();
|
|
|
+ User curUser = TokenManager.getUserToken();
|
|
|
+ if (!checkCertify(res, curUser)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ JSONArray ja = (JSONArray) JSON.parse(data);
|
|
|
+ if (ja != null && !ja.isEmpty()) {
|
|
|
+ List<NatureOwnership> no = new ArrayList<NatureOwnership>();
|
|
|
+ for (int idx = 0; idx < ja.size(); idx++) {
|
|
|
+ no.add(ja.getJSONObject(idx).toJavaObject(NatureOwnership.class));
|
|
|
+ }
|
|
|
+ for (NatureOwnership n : no) {
|
|
|
+ if (StringUtils.isBlank(n.getUid())){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(n.getId())) {
|
|
|
+ n.setId(UUID.randomUUID().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == n.getDeletedSign()) {
|
|
|
+ n.setDeletedSign(DeleteStatus.UNDELETE.getCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.setData(natureOwnershipService.batchInsert(no));
|
|
|
+ } else {
|
|
|
+ res.getError().add(buildError("", "参数格式不正确"));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|