package com.ffii.fpsms.modules.common.mail.web

import com.ffii.fpsms.modules.common.mail.service.MailReminderService
import com.ffii.fpsms.modules.common.mail.service.MailService
import com.ffii.fpsms.modules.common.mail.web.models.MailSave
import com.ffii.fpsms.modules.settings.entity.Settings
import com.ffii.fpsms.modules.settings.service.SettingsService
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/mails")
class MailController(
    private val settingsService: SettingsService,
    private val mailService: MailService,
    private val mailReminderService: MailReminderService,
) {
    @GetMapping("/setting")
    fun mailSetting(): List<Settings> {
        return settingsService.findAllByCategory("MAIL")
    }

    @PostMapping("/save")
    fun saveMail(@Valid @RequestBody mailSave: MailSave): List<Settings> {
        return mailService.saveMail(mailSave)
    }
}