//package com.fzm.mall.server.admin.goods_center.controller;
//
//import com.fzm.mall.server.admin.annotation.AdminLog;
//import com.fzm.mall.server.admin.constant.MallResponseError;
//import com.fzm.mall.server.admin.distribution.model.Template;
//import com.fzm.mall.server.admin.distribution.service.ITemplateService;
//import com.fzm.mall.server.admin.enums.log.OperateModuleEnum;
//import com.fzm.mall.server.admin.enums.log.OperateTypeEnum;
//import com.fzm.mall.server.admin.goods_center.entity.dto.GoodsSpuDTO;
//import com.fzm.mall.server.admin.goods_center.service.ISpuService;
//import com.fzm.mall.server.admin.home_page.enums.type.AdminTypeEnum;
//import com.fzm.mall.server.admin.home_page.model.Admin;
//import com.fzm.mall.server.admin.home_page.model.Merchant;
//import com.fzm.mall.server.admin.home_page.service.IAdminService;
//import com.fzm.mall.server.admin.home_page.service.IMerchantService;
//import com.fzm.mall.server.admin.repo.ResponseFactory;
//import com.fzm.mall.server.admin.repo.ResponseVO;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import lombok.RequiredArgsConstructor;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import javax.validation.Valid;
//
///**
// * @author wangp
// * @date 2021/5/27 10:43
// * @description 发布商品
// * @since JDK 1.8
// */
//@Api(tags = "商品中心-发布商品")
//@Validated
//@RestController
//@RequestMapping("/releaseGoods")
//@RequiredArgsConstructor(onConstructor = @__(@Autowired))
//public class ReleaseGoodsController {
//
//    private final IAdminService adminService;
//    private final ISpuService spuService;
//    private final ResponseFactory resFac;
//    private final ITemplateService templateService;
//    private final IMerchantService merchantService;
//
//    @ApiOperation(value = "新增")
//    @AdminLog(description = "商品中心-新增商品", module = OperateModuleEnum.GOODS_CENTER, opType = OperateTypeEnum.ADD_GOODS)
//    @PostMapping("/add")
//    public ResponseVO add(@RequestBody @Valid GoodsSpuDTO pDTO, @ApiParam(name = "adminId", value = "管理员id")
//    @RequestHeader String adminId) {
//        spuService.goodsNameExist(pDTO.getName());
//        adminService.adminAuthChecks(adminId, AdminTypeEnum.getMerchantTypeArr());
//        String merchantId = adminService.getByAdminId(adminId).getMerchantId();
//        Template template = templateService.getByMerchantId(merchantId);
//        if (template == null) {
//            return resFac.getResponse(MallResponseError.NULL_TEMPLATE);
//        }
//        spuService.add(pDTO, merchantId, template.getTemplateId());
//        return resFac.getSimpleSuccessResponse();
//    }
//
//    @ApiOperation(value = "获取商户前缀")
//    @GetMapping("/merchantPrefix")
//    public ResponseVO merchantPrefix(@RequestHeader String adminId) {
//        adminService.adminAuthChecks(adminId, AdminTypeEnum.getMerchantTypeArr());
//        Admin admin = adminService.getByAdminId(adminId);
//        Merchant merchant = merchantService.getByMerchantId(admin.getMerchantId());
//        return resFac.getSuccessResponseWithData(merchant.getPrefix());
//    }
//}
