package com.eitc.patient.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.eitc.common.core.controller.BaseController;
import com.eitc.common.core.domain.AjaxResult;
import com.eitc.common.utils.StringUtils;
import com.eitc.patient.domain.NoticeManage;
import com.eitc.patient.enums.NoticeManageDisplayStatusEnum;
import com.eitc.patient.enums.NoticeManagePublishStatusEnum;
import com.eitc.patient.service.INoticeManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * AppNoticeManageController
 *
 * @author mtx
 * @date: 2024/07/31 15:03
 */
@Api(tags = "APP公告管理")
@RestController
@RequestMapping("/app/notice-manage")
public class AppNoticeManageController extends BaseController {

    @Resource
    private INoticeManageService noticeManageService;

    /**
     * 查询公告管理
     */
    @GetMapping("/list")
    @ApiOperation("查询公告管理")
    public AjaxResult list(NoticeManage noticeManage) {
        LambdaQueryWrapper<NoticeManage> wrapper = Wrappers.<NoticeManage>lambdaQuery().orderByDesc(NoticeManage::getCreateDate)
                .like(StringUtils.isNotBlank(noticeManage.getNoticeTitle()), NoticeManage::getNoticeTitle, noticeManage.getNoticeTitle())
                .like(NoticeManage::getPublishStatus, NoticeManagePublishStatusEnum.PUBLISH.getCode())
                .like(NoticeManage::getDisplayStatus, NoticeManageDisplayStatusEnum.DISPLAY_PROGRESS.getCode());
        List<NoticeManage> list = noticeManageService.list(wrapper);
        return success(list);
    }

}
