package com.goafanti.admin.controller; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Controller; 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.ErrorConstants; import com.goafanti.common.controller.CertifyApiController; import com.goafanti.common.enums.DeleteStatus; import com.goafanti.common.model.LegalPersonOwnership; import com.goafanti.user.service.LegalPersonOwnershipService; import com.goafanti.user.service.NatureOwnershipService; @Controller @RequestMapping(value = "/api/admin/basic") public class AdminOrgBaiscInfoApiController extends CertifyApiController { @Resource private LegalPersonOwnershipService legalPersonOwnershipService; @Resource private NatureOwnershipService natureOwnershipService; /** * 法人股权人列表 */ @RequestMapping(value = "/listLegalPerson", method = RequestMethod.GET) public Result listLegalPerson(String uid) { Result res = new Result(); if (StringUtils.isBlank(uid)) { res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户")); return res; } res.setData(legalPersonOwnershipService.selectByUid(uid)); return res; } /** * 法人股权人保存修改 * @return */ @RequestMapping(value = "/legalPerson", method = RequestMethod.POST) public Result legalPerson(String data){ Result res = new Result(); JSONArray ja = (JSONArray) JSON.parse(data); if (ja != null && !ja.isEmpty()) { List lpo = new ArrayList(); for (int idx = 0; idx < ja.size(); idx++) { lpo.add(ja.getJSONObject(idx).toJavaObject(LegalPersonOwnership.class)); } for (LegalPersonOwnership l : lpo){ 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(); 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(String uid) { Result res = new Result(); if (StringUtils.isBlank(uid)) { res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户")); return res; } res.setData(natureOwnershipService.selectByUid(uid)); 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(); if (ids == null || ids.length < 1) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "")); } else { res.setData(natureOwnershipService.batchDeleteByPrimaryKey(Arrays.asList(ids))); } return res; } }