package com.tzld.piaoquan.api.controller.wecom;


import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
import com.tzld.piaoquan.growth.common.model.po.PreSpecialSendMessage;
import com.tzld.piaoquan.growth.common.model.vo.GuaranteedParam;
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
import com.tzld.piaoquan.growth.common.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/wecom/message")
public class MessageController {

    @Autowired
    private MessageAttachmentService messageAttachmentService;

    @Autowired
    private MessageService messageService;

    //创建保底小程序
    @PostMapping("/miniprogram/guaranteed/create")
    public CommonResponse<Void> createGuaranteedMiniProgram(@RequestBody GuaranteedParam guaranteedParam) {
        return messageAttachmentService.createGuaranteedMiniProgram(guaranteedParam);
    }

    //创建保底小程序
    @PostMapping("/preSpecialAssembleSendMessage/create")
    public CommonResponse<Void> createPreSpecialAssembleSendMessage(@RequestBody List<PreSpecialSendMessage> preSpecialSendMessage) {
        return messageService.createPreSpecialAssembleSendMessage(preSpecialSendMessage);
    }

    //创建保底附件
    @PostMapping("/attachment/create")
    public CommonResponse<Long> createAttachment(@RequestParam Integer type,
                                                 @RequestParam(required = false) MultipartFile file,
                                                 @RequestParam(required = false) String url,
                                                 @RequestParam(required = false) String picUrl,
                                                 @RequestParam(required = false) String page,
                                                 @RequestParam(required = false) String title,
                                                 @RequestParam(required = false) String desc,
                                                 @RequestParam(required = false) String appId,
                                                 @RequestParam(required = false) Integer extType
    ) {
        return messageAttachmentService.createAttachment(type, file, url, picUrl, page, title, desc, appId, extType);
    }

}
