
package com.tmerclub.cloud.biz.controller.app;

import com.tmerclub.cloud.biz.dto.NotifyTemplateRemindDTO;
import com.tmerclub.cloud.biz.model.NotifyTemplateRemind;
import com.tmerclub.cloud.biz.service.NotifyTemplateRemindService;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.util.BeanUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 消息提醒设置
 *
 * @author tmerclub
 * @date 2022-10-24 13:48:38
 */
@RestController("appNotifyTemplateRemindController")
@RequestMapping("/notifyRemind")
@Tag(name = "消息提醒设置")
public class NotifyTemplateRemindController {

    @Autowired
    private NotifyTemplateRemindService notifyTemplateRemindService;



    @GetMapping
    @Operation(summary = "获取消息提醒设置", description = "根据notifyTemplateRemindId获取消息提醒设置")
    public ServerResponseEntity<NotifyTemplateRemind> getByNotifyTemplateRemindId(@RequestParam Long notifyTemplateRemindId) {
        return ServerResponseEntity.success(notifyTemplateRemindService.getByNotifyTemplateRemindId(notifyTemplateRemindId));
    }

    @PostMapping
    @Operation(summary = "保存消息提醒设置", description = "保存消息提醒设置")
    public ServerResponseEntity<Void> save(@Valid @RequestBody NotifyTemplateRemindDTO notifyTemplateRemindDTO) {
        NotifyTemplateRemind notifyTemplateRemind = BeanUtil.map(notifyTemplateRemindDTO, NotifyTemplateRemind.class);
        notifyTemplateRemindService.save(notifyTemplateRemind);
        return ServerResponseEntity.success();
    }

    @PutMapping
    @Operation(summary = "更新消息提醒设置", description = "更新消息提醒设置")
    public ServerResponseEntity<Void> update(@Valid @RequestBody NotifyTemplateRemindDTO notifyTemplateRemindDTO) {
        NotifyTemplateRemind notifyTemplateRemind = BeanUtil.map(notifyTemplateRemindDTO, NotifyTemplateRemind.class);
        notifyTemplateRemindService.update(notifyTemplateRemind);
        return ServerResponseEntity.success();
    }

    @DeleteMapping
    @Operation(summary = "删除消息提醒设置", description = "根据消息提醒设置id删除消息提醒设置")
    public ServerResponseEntity<Void> delete(@RequestParam Long notifyTemplateRemindId) {
        notifyTemplateRemindService.deleteById(notifyTemplateRemindId);
        return ServerResponseEntity.success();
    }
}
