123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- package com.caimei.controller.auth;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.po.CmBrandAuthPo;
- import com.caimei.model.vo.AuthFormVo;
- import com.caimei.model.vo.AuthVo;
- import com.caimei.model.vo.ProductTypeListVo;
- import com.caimei.service.auth.AuthService;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletResponse;
- import java.math.BigDecimal;
- import java.util.List;
- import java.util.Map;
- /**
- * 供应商API
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
- @Api(tags = "认证机构API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/auth")
- public class AuthApi {
- private final AuthService authService;
- /**
- * 授权列表
- */
- @ApiOperation("授权列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1授权列表,2授权审核列表,3供应商审核列表,4授权牌物流列表"),
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
- @ApiImplicitParam(name = "authParty", required = false, value = "授权机构"),
- @ApiImplicitParam(name = "status", required = false, value = "上线状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "lowerAuditStatus", required = false, value = "商品信息审核状态:0未完成审核,1已完成审核"),
- @ApiImplicitParam(name = "shopAuditStatus", required = false, value = "供应商审核状态:0未审核,1已审核"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
- Integer status, Integer auditStatus, Integer lowerAuditStatus,
- Integer shopAuditStatus,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return authService.getAuthList(listType, authUserId, authParty, status, auditStatus, lowerAuditStatus, shopAuditStatus, pageNum, pageSize);
- }
- @ApiOperation("机构下拉框列表")
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
- @GetMapping("/select")
- public ResponseJson<List<AuthVo>> getAuthSelectList(Integer authUserId) {
- if (null == authUserId) {
- return ResponseJson.error("参数异常,供应商用户id不能为空", null);
- }
- return authService.getAuthSelectList(authUserId);
- }
- /**
- * 更新授权状态
- */
- @ApiOperation("更新授权状态")
- @ApiImplicitParam(name = "params", value = "authId:授权id;status:授权状态:0停用 1启用;", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateAuthStatus(@RequestBody Map<String,Integer> params) {
- Integer authId = params.get("authId");
- Integer status = params.get("status");
- return authService.updateAuthStatus(authId, status);
- }
- /**
- * 删除授权
- */
- @ApiOperation("删除授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id", required = true)
- @PostMapping("/delete")
- public ResponseJson deleteAuth(@RequestBody Map<String,Integer> params) {
- Integer authId = params.get("authId");
- return authService.deleteAuth(authId);
- }
- /**
- * 授权机构回显数据
- */
- @ApiOperation("授权机构回显数据")
- @ApiImplicitParam(name = "authId", required = true, value = "机构用户id")
- @GetMapping("/form/data")
- public ResponseJson<AuthFormVo> getAuthFormData(Integer authId) {
- return authService.getAuthFormData(authId);
- }
- /**
- * 添加/编辑授权
- */
- @ApiOperation("添加/编辑授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;authUserId:供应商用户id;authParty:授权机构;provinceId;cityId;" +
- "townId;address;lngAndLat;mobile;userMobile:对应机构用户手机号;" +
- "firstClubType:一级分类为医美=1,生美=2,项目公司=3,个人=4,其他=5;" +
- "secondClubType:医美的二级分类为诊所=1、门诊=2、医院=3,其他=4。生美二级分类,美容院=5,养生馆=6,其他=7;" +
- "medicalLicenseImage:医疗许可证图;empNum:员工人数;"+
- "logo;customFlag:是否需要自定义属性:0否,1是;remarks:店铺备注;createBy:创建人id", required = true)
- @PostMapping("/save")
- public ResponseJson saveAuth(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- Integer authUserId = paramsMap.getInteger("authUserId");
- Integer provinceId = paramsMap.getInteger("provinceId");
- Integer cityId = paramsMap.getInteger("cityId");
- Integer townId = paramsMap.getInteger("townId");
- String address = paramsMap.getString("address");
- String lngAndLat = paramsMap.getString("lngAndLat");
- String mobile = paramsMap.getString("mobile");
- String userMobile = paramsMap.getString("userMobile");
- Integer firstClubType = paramsMap.getInteger("firstClubType");
- Integer secondClubType = paramsMap.getInteger("secondClubType");
- String medicalLicenseImage = paramsMap.getString("medicalLicenseImage");
- Integer empNum = paramsMap.getInteger("empNum");
- String logo = paramsMap.getString("logo");
- Integer customFlag = paramsMap.getInteger("customFlag");
- String remarks = paramsMap.getString("remarks");
- List<String> bannerList = (List<String>) paramsMap.get("bannerList");
- String authParty = paramsMap.getString("authParty");
- Integer createBy = paramsMap.getInteger("createBy");
- /*
- 组装授权数据
- */
- CmBrandAuthPo auth = new CmBrandAuthPo();
- auth.setId(authId);
- auth.setAuthUserId(authUserId);
- auth.setAuthParty(authParty);
- auth.setProvinceId(provinceId);
- auth.setCityId(cityId);
- auth.setTownId(townId);
- auth.setAddress(address);
- auth.setCustomFlag(customFlag);
- auth.setRemarks(remarks);
- if (StringUtils.isEmpty(lngAndLat)) {
- return ResponseJson.error("参数异常,经纬度不能为空");
- }
- String[] split = lngAndLat.split(",");
- auth.setLng(new BigDecimal(split[0]));
- auth.setLat(new BigDecimal(split[1]));
- auth.setMobile(mobile);
- auth.setUserMobile(userMobile);
- auth.setFirstClubType(firstClubType);
- auth.setSecondClubType(secondClubType);
- auth.setMedicalLicenseImage(medicalLicenseImage);
- auth.setEmpNum(empNum);
- auth.setLogo(logo);
- auth.setCreateBy(createBy);
- return authService.saveAuth(auth, bannerList, false, 1);
- }
- /**
- * 审核品牌授权
- */
- @ApiOperation("审核品牌授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;" +
- "invalidReason:审核不通过原因;auditBy:审核人用户id;source:来源:1管理员审核,2供应商审核", required = true)
- @PostMapping("/audit")
- public ResponseJson auditAuth(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- Integer auditStatus = paramsMap.getInteger("auditStatus");
- String invalidReason = paramsMap.getString("invalidReason");
- Integer auditBy = paramsMap.getInteger("auditBy");
- Integer source = paramsMap.getInteger("source");
- return authService.auditAuth(authId, auditStatus, invalidReason, auditBy, source);
- }
- @ApiOperation("寄送授权牌")
- @ApiImplicitParam(name = "params", value = "authId:授权id;logisticsCompany:快递公司;logisticsNumber:快递单号;" +
- "image:图片备注;remarks:备注", required = true)
- @PostMapping("certificate/send")
- public ResponseJson send(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authId = paramsMap.getInteger("authId");
- String logisticsCompany = paramsMap.getString("logisticsCompany");
- String logisticsNumber = paramsMap.getString("logisticsNumber");
- String image = paramsMap.getString("image");
- String remarks = paramsMap.getString("remarks");
- return authService.sendCertificate(authId, logisticsCompany, logisticsNumber, image, remarks);
- }
- @ApiOperation("excel导入")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
- @ApiImplicitParam(name = "createBy", required = true, value = "创建人用户id"),
- @ApiImplicitParam(name = "file", required = true, value = "代理声明文件"),
- })
- @PostMapping("/import/excel")
- public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
- if (null == authUserId) {
- return ResponseJson.error("参数异常,请输入供应商id");
- }
- if (null == createBy) {
- return ResponseJson.error("参数异常,请输入创建人id");
- }
- if (null == file) {
- return ResponseJson.error("参数异常,请选择文件");
- }
- return authService.importDataByExcel(file, authUserId, createBy);
- }
- @ApiOperation("ldm导入")
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
- @PostMapping("/ldm/import")
- public ResponseJson importLdmData(Integer authUserId) {
- return authService.importLdmData(authUserId);
- }
- @ApiOperation("excel导出")
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
- @GetMapping("/export/excel")
- public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
- if (null == authUserId) {
- return ResponseJson.error("参数异常,请输入供应商id");
- }
- return authService.exportDataByExcel(authUserId, response);
- }
- }
|