package com.zcxk.controller;

import com.zcxk.entity.MessageType;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import com.zcxk.service.MessageTypeService;

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.*;

/**
 * (MessageType)控制层
 *
 * @author makejava
 * @since 2020-11-12 10:54:08
 */
@RestController
@RequestMapping("/messageType")
@Api(tags = "消息类型管理")
public class MessageTypeController {
    /**
     * 服务对象
     */
    @Autowired
    private MessageTypeService messageTypeService;

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

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

    /**
     * 修改一条数据
     *
     * @param typeName 实体类
     * @return Response对象
     */
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除消息类型")
    public AjaxMessage<Integer> update(@ApiParam(value = "设置配置", required = true) @RequestParam Integer id) {
        MessageType messageType=new MessageType();
        messageType.setStatus(0);
        messageType.setId(id);
        int result = messageTypeService.update(messageType);
        return new AjaxMessage<>(ResultStatus.OK, result);

    }





}