123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package com.fjhx.base;
- import cn.hutool.core.convert.Convert;
- import cn.hutool.core.date.DateUtil;
- import cn.hutool.core.util.ObjectUtil;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fjhx.utils.Assert;
- import com.fjhx.utils.PageUtil;
- import org.springblade.core.log.exception.ServiceException;
- import java.util.Date;
- import java.util.HashMap;
- /**
- * 条件实体
- */
- public class Condition extends HashMap<String, Object> {
- /**
- * 开始时间
- */
- public Date getBeginTime() {
- Object beginTimeObj = this.get("beginTime");
- Assert.notEmpty(beginTimeObj, "开始时间不能为空");
- Date beginTime;
- try {
- beginTime = DateUtil.beginOfDay(DateUtil.parse(beginTimeObj.toString()));
- } catch (Exception e) {
- throw new ServiceException("开始时间格式错误");
- }
- return beginTime;
- }
- /**
- * 结束时间
- */
- public Date getEndTime() {
- Object endTimeObj = this.get("endTime");
- Assert.notEmpty(endTimeObj, "结束时间不能为空");
- Date endTime;
- try {
- endTime = DateUtil.endOfDay(DateUtil.parse(endTimeObj.toString()));
- } catch (Exception e) {
- throw new ServiceException("结束时间格式错误");
- }
- return endTime;
- }
- /**
- * 关键字
- */
- public String getKeyword() {
- return getStr("keyword");
- }
- /**
- * 审批状态
- */
- public Integer getFlowStatus() {
- return getInt("flowStatus");
- }
- /**
- * 类型
- */
- public Integer getType() {
- return getInt("type");
- }
- /**
- * 状态
- */
- public Integer getStatus() {
- return getInt("status");
- }
- /**
- * 获取字符串
- */
- public String getStr(String str) {
- Object value = super.get(str);
- if (ObjectUtil.isEmpty(value)) {
- return null;
- }
- return value.toString();
- }
- /**
- * 获取字符串
- */
- public String getStr(String str, String error) {
- Object value = super.get(str);
- Assert.notEmpty(value, error);
- return value.toString();
- }
- /**
- * 获取int
- */
- public Integer getInt(String str) {
- return Convert.toInt(get(str));
- }
- public Page<Object> getPage() {
- return new Page<>(PageUtil.getCurrent(this), PageUtil.getSize(this));
- }
- }
|