package com.yida.data.user.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.apply.enums.DelFlagType;
import com.yida.data.common.core.entity.message.EduMessageStrategy;
import com.yida.data.user.service.EduMessageStrategyService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 校园自动回复消息接口管理(不鉴权)
 *
 * @author ZYJ
 * @date 2021/8/25
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/in/schoolMessage")
@Api(tags = "校园自动回复消息")
public class InEduSchoolMessageController {

    private final EduMessageStrategyService eduMessageStrategyService;

    /**
     * 根据学校id查询当前学校的自动回复消息
     *
     * @param schoolId 学校id
     * @return com.yida.data.common.core.common.ResultBean<com.yida.data.common.core.entity.message.EduMessageStrategy>
     * @author ZYJ
     * @date 2021/8/25 17:41
     */
    @ApiOperation("根据学校id查询当前学校的自动回复消息")
    @GetMapping("/getEduMessageStrategyBySchoolId")
    public ResultBean<EduMessageStrategy> getEduMessageStrategyBySchoolId(
            @ApiParam(value = "学校id", required = true) @RequestParam("schoolId") Long schoolId) {
        return ResultBean.buildSuccess(eduMessageStrategyService.getOne(Wrappers.lambdaQuery(new EduMessageStrategy())
                .eq(EduMessageStrategy::getSchoolId, schoolId)
                .eq(EduMessageStrategy::getType, 1)
                .eq(EduMessageStrategy::getSubType, 1)
                .eq(EduMessageStrategy::getDelFlag, DelFlagType.NORMAL_TYPE.getValue())));
    }
}
