package com.zcxk.controller;

import com.zcxk.entity.MessageTemplate;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import com.zcxk.service.MessageTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (MessageTemplate)控制层
 *
 * @author makejava
 * @since 2020-11-13 10:48:57
 */
@RestController
@RequestMapping("/messageTemplate")
@Api(tags = "模板管理")
public class MessageTemplateController {
    /**
     * 服务对象
     */
    @Autowired
    private MessageTemplateService messageTemplateService;



    /**
     * 新增一条数据
     *
     * @param messageTemplate 实体类
     * @return Response对象
     */
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    @ApiOperation(value = "增加模板")
    public AjaxMessage<Integer> insert(@ApiParam(value = "设置配置", required = true) @RequestBody MessageTemplate messageTemplate) {
        int result = messageTemplateService.insert(messageTemplate);

        return new AjaxMessage<>(ResultStatus.OK, result);
    }

    /**
     * 修改一条数据
     *
     * @param templateName 名称
     * @return Response对象
     */
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除模板")
    public AjaxMessage<Integer> update(@ApiParam(value = "设置配置", required = true) @RequestParam Integer id) {
        MessageTemplate messageTemplate=new MessageTemplate();
        messageTemplate.setStatus(0);
        messageTemplate.setId(id);
        int result = messageTemplateService.update(messageTemplate);
        return new AjaxMessage<>(ResultStatus.OK, result);

    }





}