package cn.reghao.oss.web.app.controller.page;

import cn.reghao.jutil.jdk.result.WebResult;
import cn.reghao.oss.web.app.model.dto.UploadChannelDto;
import cn.reghao.oss.web.app.service.UploadChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2024-02-23 15:05:30
 */
@Slf4j
@Api(tags = "上传通道接口")
@RestController
@RequestMapping("/api/store/channel")
public class StoreChannelController {
    private final UploadChannelService uploadChannelService;

    public StoreChannelController(UploadChannelService uploadChannelService) {
        this.uploadChannelService = uploadChannelService;
    }

    @ApiOperation(value = "添加上传通道")
    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    public String addUploadChannel(@Validated UploadChannelDto uploadChannelDto) {
        uploadChannelService.add(uploadChannelDto);
        return WebResult.success();
    }

    @ApiOperation(value = "删除上传通道")
    @DeleteMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
    public String deleteUploadChannel(@Validated UploadChannelDto uploadChannelDto) {
        uploadChannelService.add(uploadChannelDto);
        return WebResult.success();
    }
}
