package com.ym.mec.web.controller;

import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
import com.ym.mec.biz.dal.entity.SysEmail;
import com.ym.mec.biz.service.SysEmailService;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.tenant.TenantContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ym.mec.common.controller.BaseController;

import javax.annotation.Resource;

/**
 * (SysEmail)表控制层
 *
 * @author makejava
 * @since 2022-01-04 17:07:43
 */
@RestController
@Api(tags = "系统邮件服务")
@RequestMapping("sysEmail")
public class SysEmailController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private SysEmailService sysEmailService;


    @ApiOperation(value = "修改")
    @PostMapping("/update")
    @PreAuthorize("@pcs.hasPermissions('sysEmail/update')")
    public HttpResponseResult<SysEmail> update(@RequestBody SysEmail sysEmail) {
        sysEmailService.updateById(sysEmail);
        return succeed(sysEmail);
    }

    @ApiOperation(value = "查询")
    @GetMapping("/query")
    @PreAuthorize("@pcs.hasPermissions('sysEmail/query')")
    public HttpResponseResult<SysEmail> query() {
        Integer tenantId = TenantContextHolder.getTenantId();
        return succeed(sysEmailService.query(tenantId));
    }

}

