package cn.axzo.msg.center.notices.client.controller;


import cn.axzo.msg.center.notices.client.annotation.PlatCheckSign;
import cn.axzo.msg.center.notices.common.lang.Page;
import cn.axzo.msg.center.notices.manager.api.dto.request.plat.CreateTemplateRequestDto;
import cn.axzo.msg.center.notices.manager.api.dto.request.plat.QueryTemplateRequestDto;
import cn.axzo.msg.center.notices.manager.api.dto.response.plat.QueryTemplateResponseDto;
import cn.axzo.msg.center.notices.service.api.PlatService;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/plat")
@RestController
@PlatCheckSign
public class PlatController {

    @Resource
    private PlatService platService;

    @PostMapping("/create")
    public CommonResponse<Object> createTemplate(@RequestBody CreateTemplateRequestDto request){
        platService.createTemplate(request);
        return CommonResponse.success();
    }

    @RequestMapping("/getByTemplateNo")
    public CommonResponse<QueryTemplateResponseDto> getByTemplateNo(String templateNo){
        return CommonResponse.success(platService.getByTemplateNo(templateNo));
    }

    @PostMapping("/list")
    public CommonResponse<Page<QueryTemplateResponseDto>> list(@RequestBody QueryTemplateRequestDto request){
        return CommonResponse.success(platService.list(request));
    }

    @GetMapping("/delete")
    public CommonResponse<Object> delete(String templateNo){
        platService.delete(templateNo);
        return CommonResponse.success();
    }

}
