//package com.gree.mall.manager.controller.marketing;
//
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.gree.mall.manager.bean.admin.AdminUserCom;
//import com.gree.mall.manager.bean.marketing.MarketingMaterialsAddReqBean;
//import com.gree.mall.manager.bean.marketing.MarketingMaterialsUpdateReqBean;
//import com.gree.mall.manager.helper.ResponseHelper;
//import com.gree.mall.manager.logic.marketing.MarketingMaterialsLogic;
//import com.gree.mall.manager.plus.entity.MarketingMaterials;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import me.chanjar.weixin.common.error.WxErrorException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//
//@Api(value = "营销素材", tags = {"营销素材"})
//@RestController
//@RequestMapping(value = "/marketing/materials", produces = "application/json; charset=utf-8")
//public class MarketingMaterialsController {
//
//    @Autowired
//    private MarketingMaterialsLogic marketingMaterialsLogic;
//
//
//    @ApiOperation("分页获取营销素材")
//    @GetMapping("/page")
//    public ResponseHelper<IPage<MarketingMaterials>> page(
//            HttpServletRequest request,
//            @ApiParam(value = "标题", required = false) @RequestParam(required = false) String title,
//            @ApiParam(value = "分组id", required = false) @RequestParam(required = false) String groupId,
//            @ApiParam(value = "素材类型: 1:文本  2.图片  3.视屏 4.网页 5.小程序 6.文件", required = true) @RequestParam(required = true) String type,
//            @ApiParam(value = "页号", required = true) @RequestParam(required = true) Integer pageNum,
//            @ApiParam(value = "页大小", required = true) @RequestParam(required = true) Integer pageSize
//    ) throws IOException {
//
//        IPage<MarketingMaterials> page = marketingMaterialsLogic.page(request, title, groupId, type, pageNum, pageSize);
//
//        return ResponseHelper.success(page);
//    }
//
//
//    @ApiOperation("移组")
//    @PostMapping("/moveGroup")
//    public ResponseHelper<Void> moveGroup(
//            HttpServletRequest request,
//            @ApiParam(value = "营销素材id 格式:id1,id2", required = true) @RequestParam(required = true) String marketingMaterialsId,
//            @ApiParam(value = "新营销组id", required = true) @RequestParam(required = true) String newGroupId
//    ) {
//
//        marketingMaterialsLogic.moveGroup(request, marketingMaterialsId, newGroupId);
//
//        return ResponseHelper.success();
//    }
//
//
//    @ApiOperation("重置")
//    @PostMapping("/reset")
//    public ResponseHelper<Void> reset(
//            @ApiParam(value = "营销组id", required = true) @RequestParam(required = true) String groupId,
//            @ApiParam(value = "素材类型: 1:文本  2.图片  3.视屏 4.网页 5.小程序 6.文件", required = true)
//            @RequestParam(required = true) String type
//    ) {
//
//        marketingMaterialsLogic.reset(groupId, type);
//
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation("新增素材")
//    @PostMapping("/add")
//    public ResponseHelper<String> add(
//            HttpServletRequest request, @RequestBody MarketingMaterialsAddReqBean marketingMaterialsAddReqBean
//    ) throws IOException {
//
//        String  id = marketingMaterialsLogic.add(request, marketingMaterialsAddReqBean);
//
//        return ResponseHelper.success(id);
//    }
//
//    @ApiOperation("移除素材")
//    @PostMapping("/deleteById")
//    public ResponseHelper<Void> deleteById(
//            @ApiParam(value = "营销素材id", required = true) @RequestParam(required = true) String marketingMaterialsId
//    ) {
//        marketingMaterialsLogic.deleteById(marketingMaterialsId);
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation("編輯素材")
//    @PostMapping("/update")
//    public ResponseHelper<Void> update(
//            HttpServletRequest request, @RequestBody MarketingMaterialsUpdateReqBean updateReqBean
//    ) throws IOException {
//
//        marketingMaterialsLogic.update(request, updateReqBean);
//
//        return ResponseHelper.success();
//    }
//
//    @ApiOperation("通过id查询編輯详情")
//    @GetMapping("/getUpdateDetailById")
//    public ResponseHelper<MarketingMaterialsUpdateReqBean> getUpdateDetailById(
//            @ApiParam(value = "营销素材id", required = true) @RequestParam(required = true) String marketingMaterialsId
//    ) throws IOException {
//        MarketingMaterialsUpdateReqBean byId = marketingMaterialsLogic.getById(marketingMaterialsId);
//
//        return ResponseHelper.success(byId);
//    }
//
//    @ApiOperation("上传素材至企业微信")
//    @PostMapping("/loadToQyWx")
//    public ResponseHelper<String> loadToQyWx(
//            HttpServletRequest request,
//            @ApiParam(value = "文件url", required = true) @RequestParam(required = true) String fileUrl,
//            @ApiParam(value = "文件类型 图片（image）：10MB，支持JPG,PNG格式\n" +
//                    "语音（voice） ：2MB，播放长度不超过60s，仅支持AMR格式\n" +
//                    "视频（video） ：10MB，支持MP4格式\n" +
//                    "普通文件（file）：20MB", required = true) @RequestParam(required = true) String fileType
//    ) throws IOException, WxErrorException {
//        String s = marketingMaterialsLogic.loadToQyWx(request, fileUrl, fileType);
//        return ResponseHelper.success(s);
//    }
//
//}
