123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package com.caimei.controller;
- 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.BrandVo;
- import com.caimei.model.vo.ShopFormVo;
- import com.caimei.service.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.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletResponse;
- 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授权审核列表"),
- @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 = "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,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return authService.getAuthList(listType, authUserId, authParty, status, auditStatus, lowerAuditStatus, pageNum, pageSize);
- }
- /**
- * 更新授权状态
- */
- @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:授权机构;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 lonAndLat = paramsMap.getString("lonAndLat");
- String mobile = paramsMap.getString("mobile");
- String logo = paramsMap.getString("logo");
- 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.setLonAndLat(lonAndLat);
- auth.setMobile(mobile);
- auth.setLogo(logo);
- auth.setCreateBy(createBy);
- return authService.saveAuth(auth, bannerList, false);
- }
- /**
- * 审核品牌授权
- */
- @ApiOperation("审核品牌授权")
- @ApiImplicitParam(name = "params", value = "authId:授权id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", 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");
- return authService.auditAuth(authId, auditStatus, invalidReason, auditBy);
- }
- @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("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);
- }
- }
|