AuthApi.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. package com.caimei.controller.admin.auth;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.po.CmBrandAuthPo;
  5. import com.caimei.model.vo.AuthFormVo;
  6. import com.caimei.model.vo.AuthVo;
  7. import com.caimei.service.auth.AuthService;
  8. import com.github.pagehelper.PageInfo;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiImplicitParam;
  11. import io.swagger.annotations.ApiImplicitParams;
  12. import io.swagger.annotations.ApiOperation;
  13. import lombok.RequiredArgsConstructor;
  14. import lombok.extern.slf4j.Slf4j;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.springframework.web.bind.annotation.*;
  17. import org.springframework.web.multipart.MultipartFile;
  18. import javax.servlet.http.HttpServletResponse;
  19. import java.math.BigDecimal;
  20. import java.util.List;
  21. import java.util.Map;
  22. /**
  23. * 供应商API
  24. *
  25. * @author : Aslee
  26. * @date : 2021/5/11
  27. */
  28. @Api(tags = "认证机构API")
  29. @Slf4j
  30. @RestController
  31. @RequiredArgsConstructor
  32. @RequestMapping("/auth")
  33. public class AuthApi {
  34. private final AuthService authService;
  35. /**
  36. * 授权列表
  37. */
  38. @ApiOperation("授权列表")
  39. @ApiImplicitParams({
  40. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
  41. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  42. @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
  43. @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
  44. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  45. @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
  46. @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
  47. @ApiImplicitParam(name = "sendStatus", required = false, value = "寄送状态:0未寄送,1已寄送"),
  48. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  49. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  50. })
  51. @GetMapping("/list")
  52. public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
  53. Integer status, Integer auditStatus, Integer lowerAuditStatus,
  54. Integer shopAuditStatus, Integer sendStatus,
  55. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  56. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  57. return authService.getAuthList(listType, authUserId, authParty, status, auditStatus, lowerAuditStatus, shopAuditStatus, sendStatus, pageNum, pageSize);
  58. }
  59. @ApiOperation("机构下拉框列表")
  60. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  61. @GetMapping("/select")
  62. public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
  63. if (null == authUserId) {
  64. return ResponseJson.error("参数异常,供应商用户id不能为空", null);
  65. }
  66. return authService.getAuthSelectList(authUserId);
  67. }
  68. /**
  69. * 更新授权状态
  70. */
  71. @ApiOperation("更新授权状态")
  72. @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
  73. @PostMapping("/update/status")
  74. public ResponseJson updateAuthStatus(@RequestBody Map<String,Integer> params) {
  75. Integer authId = params.get("authId");
  76. Integer status = params.get("status");
  77. return authService.updateAuthStatus(authId, status);
  78. }
  79. /**
  80. * 删除授权
  81. */
  82. @ApiOperation("删除授权")
  83. @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
  84. @PostMapping("/delete")
  85. public ResponseJson deleteAuth(@RequestBody Map<String,Integer> params) {
  86. Integer authId = params.get("authId");
  87. return authService.deleteAuth(authId);
  88. }
  89. /**
  90. * 授权机构回显数据
  91. */
  92. @ApiOperation("授权机构回显数据")
  93. @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
  94. @GetMapping("/form/data")
  95. public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
  96. return authService.getAuthFormData(authId);
  97. }
  98. /**
  99. * 添加/编辑授权
  100. */
  101. @ApiOperation("添加/编辑授权")
  102. @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
  103. "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
  104. "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
  105. "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
  106. "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
  107. "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id;source:1供应商保存,2机构保存", required = true)
  108. @PostMapping("/save")
  109. public ResponseJson saveAuth(@RequestBody String params) {
  110. JSONObject paramsMap = JSONObject.parseObject(params);
  111. Integer authId = paramsMap.getInteger("authId");
  112. Integer authUserId = paramsMap.getInteger("authUserId");
  113. Integer provinceId = paramsMap.getInteger("provinceId");
  114. Integer cityId = paramsMap.getInteger("cityId");
  115. Integer townId = paramsMap.getInteger("townId");
  116. String address = paramsMap.getString("address");
  117. String lngAndLat = paramsMap.getString("lngAndLat");
  118. String mobile = paramsMap.getString("mobile");
  119. String userMobile = paramsMap.getString("userMobile");
  120. Integer firstClubType = paramsMap.getInteger("firstClubType");
  121. Integer secondClubType = paramsMap.getInteger("secondClubType");
  122. String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
  123. Integer empNum = paramsMap.getInteger("empNum");
  124. String logo = paramsMap.getString("logo");
  125. Integer customFlag = paramsMap.getInteger("customFlag");
  126. String remarks = paramsMap.getString("remarks");
  127. List<String> bannerList = (List<String>) paramsMap.get("bannerList");
  128. String authParty = paramsMap.getString("authParty");
  129. Integer createBy = paramsMap.getInteger("createBy");
  130. Integer source = paramsMap.getInteger("source");
  131. if (null == source) {
  132. // 默认供应商保存
  133. source = 1;
  134. }
  135. /*
  136. 组装授权数据
  137. */
  138. CmBrandAuthPo auth = new CmBrandAuthPo();
  139. auth.setId(authId);
  140. auth.setAuthUserId(authUserId);
  141. auth.setAuthParty(authParty);
  142. auth.setProvinceId(provinceId);
  143. auth.setCityId(cityId);
  144. auth.setTownId(townId);
  145. auth.setAddress(address);
  146. auth.setCustomFlag(customFlag);
  147. auth.setRemarks(remarks);
  148. if (StringUtils.isEmpty(lngAndLat)) {
  149. return ResponseJson.error("参数异常,经纬度不能为空");
  150. }
  151. String[] split = lngAndLat.split(",");
  152. auth.setLng(new BigDecimal(split[0]));
  153. auth.setLat(new BigDecimal(split[1]));
  154. auth.setMobile(mobile);
  155. auth.setUserMobile(userMobile);
  156. auth.setFirstClubType(firstClubType);
  157. auth.setSecondClubType(secondClubType);
  158. auth.setMedicalLicenseImage(medicalLicenseImage);
  159. auth.setEmpNum(empNum);
  160. auth.setLogo(logo);
  161. auth.setCreateBy(createBy);
  162. return authService.saveAuth(auth, bannerList, false, source);
  163. }
  164. /**
  165. * 审核品牌授权
  166. */
  167. @ApiOperation("审核品牌授权")
  168. @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
  169. "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
  170. @PostMapping("/audit")
  171. public ResponseJson auditAuth(@RequestBody String params) {
  172. JSONObject paramsMap = JSONObject.parseObject(params);
  173. Integer authId = paramsMap.getInteger("authId");
  174. Integer auditStatus = paramsMap.getInteger("auditStatus");
  175. String invalidReason = paramsMap.getString("invalidReason");
  176. Integer auditBy = paramsMap.getInteger("auditBy");
  177. Integer source = paramsMap.getInteger("source");
  178. return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
  179. }
  180. @ApiOperation("excel导入")
  181. @ApiImplicitParams({
  182. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  183. @ApiImplicitParam(name = "createBy", required = true, value = "创建人用户id"),
  184. @ApiImplicitParam(name = "file", required = true, value = "代理声明文件"),
  185. })
  186. @PostMapping("/import/excel")
  187. public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
  188. if (null == authUserId) {
  189. return ResponseJson.error("参数异常,请输入供应商id");
  190. }
  191. if (null == createBy) {
  192. return ResponseJson.error("参数异常,请输入创建人id");
  193. }
  194. if (null == file) {
  195. return ResponseJson.error("参数异常,请选择文件");
  196. }
  197. return authService.importDataByExcel(file, authUserId, createBy);
  198. }
  199. @ApiOperation("ldm导入")
  200. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  201. @PostMapping("/ldm/import")
  202. public ResponseJson importLdmData(Integer authUserId) {
  203. return authService.importLdmData(authUserId);
  204. }
  205. @ApiOperation("excel导出")
  206. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
  207. @GetMapping("/export/excel")
  208. public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
  209. if (null == authUserId) {
  210. return ResponseJson.error("参数异常,请输入供应商id");
  211. }
  212. return authService.exportDataByExcel(authUserId, response);
  213. }
  214. }