package com.caimei.controller; import com.caimei.model.ResponseJson; import com.caimei.model.dto.ShopSaveDto; import com.caimei.model.vo.BrandVo; import com.caimei.model.vo.CountryVo; import com.caimei.model.vo.ShopFormVo; import com.caimei.model.vo.ShopListVo; 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.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; 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> 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 ShopVo */ @ApiOperation("供应商表单数据") @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id") @GetMapping("/form/data") public ResponseJson getShopFormData(Integer authUserId) { return shopService.getShopFormData(authUserId); } /** * 添加供应商 * @param shopSaveDto { * shopType 供应商类型:1代理商,2品牌方 * brandId 品牌id * shopName 供应商名称 * mobile 手机号 * linkMan 联系人 * countryId 产地国家id * brandAuthLogo 品牌授权logo * shopStatus 供应商状态:0停用 1启用 * securityLink 官网认证链接 * statementType 代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf) * statementContent 声明弹窗内容 * statementLink 声明链接 * statementImage 声明图片 * statementFileId 声明文件id * createBy 创建人用户id * } */ @ApiOperation("添加/编辑供应商") @PostMapping("/save") public ResponseJson saveShop(@RequestBody ShopSaveDto shopSaveDto) { return shopService.saveShop(shopSaveDto); } /** * 更新供应商状态 */ @ApiOperation("更新供应商状态") @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;status:供应商状态:0停用 1启用", required = true) @PostMapping("/update/status") public ResponseJson updateShopStatus(@RequestBody Map 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 params) { Integer authUserId = params.get("authUserId"); return shopService.resetShopPassword(authUserId); } /** * 代理声明文件上传 * * @param authUserId:供应商用户id * @param file:代理声明文件 * @return */ @ApiOperation("代理声明文件上传") @ApiImplicitParams({ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"), @ApiImplicitParam(name = "file", required = false, value = "代理声明文件"), }) @PostMapping("/upload/file") public ResponseJson uploadFile(Integer authUserId, MultipartFile file) { return shopService.uploadFile(authUserId, file); } /** * 品牌列表 * @param type 1品牌方品牌列表,2代理商品牌列表 * @return AuthVo */ @ApiOperation("品牌列表") @ApiImplicitParam(name = "type", value = "1品牌方品牌列表,2代理商品牌列表", required = true) @GetMapping("/brand/list") public ResponseJson> getBrandList(Integer type){ return shopService.getBrandList(type); } /** * 产地国家列表 */ @ApiOperation("产地国家列表") @GetMapping("/country/list") public ResponseJson> getCountryList(){ return shopService.getCountryList(); } }