package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.common.core.utils.DateUtils;
import cn.cecep.talroad.common.core.utils.StringUtils;
import cn.cecep.talroad.domain.BEnterpriseIrNotifierproNotice;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import java.text.ParseException;
import java.util.Date;


/**
 * 通知提醒-通知公告对象 b_enterprise_ir_notifierpro_notice
 *
 * @author szhpt
 * @date 2023-03-14*/
@ApiModel(value = "通知提醒-通知公告")
@EqualsAndHashCode(callSuper = false)
@Data
public class BEnterpriseIrNotifierproNoticeQuery extends PageQuery
{

    @ApiModelProperty(value = "通知公告主键")
    private Long noticeId;
    @ApiModelProperty(value = "企业id")
    @NotBlank(message = "请指定查询企业主键")
    private String factoryId;
    @ApiModelProperty(value = "公告类型")
    private String announcementType;
    @ApiModelProperty(value = "公告标题")
    private String announcementTitle;
    @ApiModelProperty(value = "公告内容")
    private String announcementDetails;
    @ApiModelProperty(value = "公告发布时间")
    private Date announcementTime;
    @ApiModelProperty(value = "状态")
    private String status;

    @ApiModelProperty(value = "检索开始时间(yyyy-MM-dd)")
    private String searchBeginTime;

    @ApiModelProperty(value = "检索截至时间(yyyy-MM-dd)")
    private String searchEndTime;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BEnterpriseIrNotifierproNotice> createLambdaQueryWrapper(BEnterpriseIrNotifierproNoticeQuery query) throws ParseException {
        QueryWrapper<BEnterpriseIrNotifierproNotice> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotNull(query.getNoticeId()), "notice_id", query.getNoticeId());
        wrapper.eq(StringUtils.isNotEmpty(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.eq(StringUtils.isNotEmpty(query.getAnnouncementType()), "announcement_type", query.getAnnouncementType());
        wrapper.like(StringUtils.isNotEmpty(query.getAnnouncementTitle()), "announcement_title", query.getAnnouncementTitle());
        wrapper.eq(StringUtils.isNotEmpty(query.getAnnouncementDetails()), "announcement_details", query.getAnnouncementDetails());
        wrapper.eq(ObjectUtil.isNotNull(query.getAnnouncementTime()), "announcement_time", query.getAnnouncementTime());
        wrapper.eq(StringUtils.isNotEmpty(query.getStatus()), "status", query.getStatus());
        wrapper.eq("del_flag", "0");
        wrapper.between(StringUtils.isNotEmpty(query.getSearchBeginTime()) && StringUtils.isNotEmpty(query.getSearchEndTime()), "announcement_time", StringUtils.isNotEmpty(query.getSearchBeginTime()) ? DateUtils.parseDate(query.getSearchBeginTime(), DateUtils.YYYY_MM_DD) : query.getSearchBeginTime(), StringUtils.isNotEmpty(query.getSearchEndTime()) ? DateUtils.parseDate(query.getSearchEndTime()+" 23:59:59", DateUtils.YYYY_MM_DD_HH_MM_SS) : query.getSearchEndTime());
        wrapper.orderByDesc("announcement_time");
        return wrapper;
        }
}
