123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- package com.caimei.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.dto.ShopInfoDto;
- import com.caimei.model.dto.ShopSaveDto;
- import com.caimei.model.po.ShopInfoPo;
- import com.caimei.model.vo.*;
- import com.caimei.service.ShopService;
- 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 java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- /**
- * 供应商API
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
- @Api(tags = "供应商API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/shop")
- public class ShopApi {
- private final ShopService shopService;
- /**
- * 供应商列表
- */
- @ApiOperation("供应商列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "shopName", required = false, value = "供应商名称"),
- @ApiImplicitParam(name = "shopType", required = false, value = "供应商类型:1品牌方,2代理商"),
- @ApiImplicitParam(name = "brandId", required = false, value = "所属品牌id"),
- @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
- @ApiImplicitParam(name = "linkMan", required = false, value = "联系人"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<ShopListVo>> getShopList(String shopName, Integer shopType, Integer brandId, String mobile, String linkMan,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return shopService.getShopList(shopName, shopType, brandId, mobile, linkMan, pageNum, pageSize);
- }
- /**
- * 获取供应商回显数据
- *
- * @param authUserId 供应商用户id
- * @return ShopFormVo
- */
- @ApiOperation("供应商回显数据")
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
- @GetMapping("/form/data")
- public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
- return shopService.getShopFormData(authUserId);
- }
- /**
- * 添加供应商
- *
- * @param params {
- * authUserId 供应商用户id
- * shopType 供应商类型:1代理商,2品牌方
- * shopName 供应商名称
- * mobile 手机号
- * linkMan 联系人
- * shopStatus 供应商状态:0停用 1启用
- * createBy 创建人用户id
- * shopInfo [
- * {
- * brandId 品牌id
- * countryId 产地国家id
- * brandAuthLogo 品牌授权logo
- * securityLink 官网认证链接
- * statementType 代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
- * statementContent 声明弹窗内容
- * statementLink 声明链接
- * statementImage 声明图片
- * statementFileId 声明文件id
- * }
- * ]
- * }
- */
- @ApiOperation("添加/编辑供应商")
- @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;", required = true)
- @PostMapping("/save")
- public ResponseJson saveShop(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer authUserId = paramsMap.getInteger("authUserId");
- Integer shopType = paramsMap.getInteger("shopType");
- if (null == shopType) {
- return ResponseJson.error("请选择供应商类型", null);
- }
- String shopName = paramsMap.getString("shopName");
- String mobile = paramsMap.getString("mobile");
- if (StringUtils.isBlank(mobile)) {
- return ResponseJson.error("参数异常,请输入手机号");
- }
- String linkMan = paramsMap.getString("linkMan");
- if (StringUtils.isBlank(mobile)) {
- return ResponseJson.error("参数异常,请输入联系人");
- }
- Integer shopStatus = paramsMap.getInteger("shopStatus");
- if (null == shopStatus) {
- return ResponseJson.error("参数异常,请输入供应商状态");
- }
- Integer createBy = paramsMap.getInteger("createBy");
- List<Map<String, Object>> shopInfoData = (List<Map<String, Object>>) paramsMap.get("shopInfo");
- if (null == shopInfoData || shopInfoData.size() <= 0) {
- return ResponseJson.error("参数异常,请输入供应商信息");
- }
- List<ShopInfoDto> shopInfoList = new ArrayList<>();
- for (Map<String, Object> infoMap : shopInfoData) {
- Integer brandId = (Integer) infoMap.get("brandId");
- Integer countryId = (Integer) infoMap.get("countryId");
- String brandAuthLogo = (String) infoMap.get("brandAuthLogo");
- String securityLink = (String) infoMap.get("securityLink");
- Integer statementType = (Integer) infoMap.get("statementType");
- String statementContent = (String) infoMap.get("statementContent");
- String statementLink = (String) infoMap.get("statementLink");
- String statementImage = (String) infoMap.get("statementImage");
- Integer statementFileId = (Integer) infoMap.get("statementFileId");
- if (null == brandId || null == countryId || StringUtils.isEmpty(brandAuthLogo) || null == statementType) {
- return ResponseJson.error("参数异常,供应商信息数据异常");
- }
- ShopInfoDto shopInfo = new ShopInfoDto();
- shopInfo.setBrandId(brandId);
- shopInfo.setCountryId(countryId);
- shopInfo.setBrandAuthLogo(brandAuthLogo);
- shopInfo.setSecurityLink(securityLink);
- shopInfo.setStatementType(statementType);
- shopInfo.setStatementContent(statementContent);
- shopInfo.setStatementLink(statementLink);
- shopInfo.setStatementImage(statementImage);
- shopInfo.setStatementFileId(statementFileId);
- shopInfoList.add(shopInfo);
- }
- return shopService.saveShop(authUserId, shopType, shopName, mobile, linkMan, shopStatus, createBy, shopInfoList);
- }
- /**
- * 更新供应商状态
- */
- @ApiOperation("更新供应商状态")
- @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;status:供应商状态:0停用 1启用", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateShopStatus(@RequestBody Map<String,Integer> params) {
- Integer authUserId = params.get("authUserId");
- Integer status = params.get("status");
- return shopService.updateShopStatus(authUserId, status);
- }
- /**
- * 重置密码
- */
- @ApiOperation("重置密码")
- @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id", required = true)
- @PostMapping("/reset/password")
- public ResponseJson resetShopPassword(@RequestBody Map<String,Integer> params) {
- Integer authUserId = params.get("authUserId");
- return shopService.resetShopPassword(authUserId);
- }
- /**
- * 代理声明文件上传
- *
- * @param authUserId:供应商用户id
- * @param brandId:品牌id
- * @param file:代理声明文件
- * @return Integer
- */
- @ApiOperation("代理声明文件上传")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
- @ApiImplicitParam(name = "brandId", required = false, value = "品牌id"),
- @ApiImplicitParam(name = "file", required = false, value = "代理声明文件"),
- })
- @PostMapping("/upload/file")
- public ResponseJson<FileVo> uploadFile(Integer authUserId, Integer brandId, MultipartFile file) {
- return shopService.uploadFile(authUserId, brandId, file);
- }
- /**
- * 品牌列表
- *
- * @param type 1品牌方可用品牌列表,2代理商可用品牌列表,3供应商可用品牌列表
- * @return AuthVo
- */
- @ApiOperation("品牌列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "type", value = "1品牌方品牌列表,2代理商品牌列表,3供应商可用品牌列表", required = true),
- @ApiImplicitParam(name = "authUserId", value = "供应商用户id", required = false)
- })
- @GetMapping("/brand/list")
- public ResponseJson<List<BrandVo>> getBrandList(Integer type, Integer authUserId) {
- return shopService.getBrandList(type, authUserId);
- }
- /**
- * 产地国家列表
- */
- @ApiOperation("产地国家列表")
- @GetMapping("/country/list")
- public ResponseJson<List<CountryVo>> getCountryList(){
- return shopService.getCountryList();
- }
- }
|