package com.usky.system.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.system.domain.MceSetting;
import com.usky.system.service.MceSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 * 消息设置表 前端控制器
 * </p>
 *
 * @author han
 * @since 2024-04-19
 */
@RestController
@RequestMapping("/mceSetting")
public class MceSettingController {

    @Autowired
    private MceSettingService mceSettingService;

    /**
     * 消息设置回显
     * @return
     */
    @GetMapping("/mceSettingInfo")
    public ApiResult<Map<String, Object>> mceSettingInfo(){
        return ApiResult.success(mceSettingService.mceSettingInfo());
    }

    /**
     * 消息设置列表
     * @param createBy     创建人
     * @param current      当前页
     * @param size     每页条数
     * @return
     */
    @GetMapping("/mceSettingList")
    public ApiResult<CommonPage<Map<String, Object>>> mceSettingList(@RequestParam(value = "createBy", required = false) String createBy,
                                                                     @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                                                                     @RequestParam(value = "size", required = false, defaultValue = "10") Integer size){
        return ApiResult.success(mceSettingService.mceSettingList(createBy,current,size));
    }

    /**
     * 新增、修改
     * @param mceSetting
     * @return
     */
    @PostMapping("/addMceSetting")
    public ApiResult<Void> add(@RequestBody MceSetting mceSetting){
        mceSettingService.add(mceSetting);
        return ApiResult.success();
    }
}

