/** # __----~~~~~~~~~~~------___ # . . ~~//====...... __--~ ~~ # -. \_|// |||\\ ~~~~~~::::... /~ # ___-==_ _-~o~ \/ ||| \\ _/~~- # __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ # _-~~ .=~ | \\-_ '-~7 /- / || \ / # .~ .~ | \\ -_ / /- / || \ / # / ____ / | \\ ~-_/ /|- _/ .|| \ / # |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ # ' ~-| /| |-~\~~ __--~~ # |-~~-_/ | | ~\_ _-~ /\ # / \ \__ \/~ \__ # _--~ _/ | .-~~____--~-/ ~~==. # ((->/~ '.|||' -_| ~~-/ , . _|| # -_ ~\ ~~---l__i__i__i--~~_/ # _-~-__ ~) \--______________--~~ # //.-~~~-~_--~- |-------~~~~~~~~ # //.-~~~--\ # 神兽保佑 # 永无BUG! */ package com.lunhan.xxx.repository.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.lunhan.xxx.common.PagerResult; import com.lunhan.xxx.common.enums.EYesOrNo; import com.lunhan.xxx.common.util.ListUtil; import com.lunhan.xxx.common.util.NumericUtil; import com.lunhan.xxx.entity.dto.OrderByDTO; import com.lunhan.xxx.entity.dto.SearchBasicDTO; import com.lunhan.xxx.entity.enums.EOrderBy; import com.lunhan.xxx.entity.search.SearchNotice; import com.lunhan.xxx.repository.BasicMapperImpl; import com.lunhan.xxx.repository.mapper.NoticeMapper; import com.lunhan.xxx.repository.po.NoticePO; import org.springframework.stereotype.Repository; import java.util.ArrayList; /** * 公告 * @author lin.liu * @description 公告 */ @Repository public class NoticeMapperImpl extends BasicMapperImpl { NoticeMapperImpl(NoticeMapper mapper) { super(mapper); } @Override public PagerResult search(SearchBasicDTO request) { // 还原查询条件真实类型 SearchNotice search = (SearchNotice)request; // 查询条件 LambdaQueryWrapper queryWrapper = this.query(); // 非逻辑删除 queryWrapper.eq(NoticePO::getIsDelete, EYesOrNo.NO.getValue()); // 状态 //queryWrapper.eq(NumericUtil.tryParseInt(search.getStatus()).compareTo(0) > 0, NoticePO::getStatus, search.getStatus()); // 状态列表 //queryWrapper.in(ListUtil.isNotNullOrEmpty(search.getListStatus()), NoticePO::getStatus, search.getListStatus()); // 数据创建时间-起始 queryWrapper.ge(NumericUtil.tryParseLong(search.getCreateTimeStart()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeStart()); // 数据创建时间-截止 queryWrapper.le(NumericUtil.tryParseLong(search.getCreateTimeEnd()).compareTo(0L) > 0, NoticePO::getCreateTime, search.getCreateTimeEnd()); // 关键字 //if (StringUtil.isNotNullOrEmpty(search.getKeywords())) { // queryWrapper.and(q -> // q.like(NoticePO::getName, search.getKeywords()) // .or().like(NoticePO::getPhone, search.getKeywords()) // ); //} // 排序处理 if (ListUtil.isNotNullOrEmpty(search.getOrderBy())) { for (OrderByDTO item : search.getOrderBy()) { EOrderBy orderBy = EOrderBy.getByValue(item.getOrderBy()); // 顺序排序 if (item.getIsAsc()) { switch (orderBy) { // 主键 case ID: queryWrapper.orderByAsc(NoticePO::getId); break; // 数据创建时间 case CREATE_TIME: queryWrapper.orderByAsc(NoticePO::getCreateTime); break; // 最后更新时间 case UPDATE_TIME: queryWrapper.orderByAsc(NoticePO::getUpdateTime); break; } } else { // 倒叙排序 switch (orderBy) { // 主键 case ID: queryWrapper.orderByDesc(NoticePO::getId); break; // 数据创建时间 case CREATE_TIME: queryWrapper.orderByDesc(NoticePO::getCreateTime); break; // 最后更新时间 case UPDATE_TIME: queryWrapper.orderByDesc(NoticePO::getUpdateTime); break; } } } } else { queryWrapper.orderByDesc(NoticePO::getId); } return new PagerResult<>(search.getLimit(), search.getPage(), 0L, new ArrayList<>()); // DB.selectCount() // Page pageResult = DB.selectObjs(new Page<>(search.getPage(), search.getLimit()), queryWrapper); // return new PagerResult<>(pageResult.getSize(), pageResult.getCurrent(), pageResult.getTotal(), pageResult.getRecords()); }}