package com.zteits.sys.dao.impl; import java.util.Date; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.zteits.clouds.api.dto.sys.param.OpAdviceNumOfReadStateQueryReq; import com.zteits.clouds.api.dto.sys.param.OpAdviceReadStateUpdateReq; import com.zteits.clouds.api.dto.sys.param.SysOpAdviceForPageQueryReq; import com.zteits.sys.dao.SysOpAdviceDao; import com.zteits.sys.domain.SysOpAdvice; import com.zteits.sys.domain.SysOpAdviceExample; import com.zteits.sys.domain.SysOpAdviceExample.Criteria; import com.zteits.sys.mapper.SysOpAdviceMapper; import com.zteits.sys.mapper.smapper.SysOpAdviceSMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * Copyright: Copyright (c) 2018 zteits * * @ClassName: com.zteits.sys.dao.impl * @Description:职工系统通知接口 * @version: v1.0.0 * @author: atao * @date: 2018/8/7 下午3:07 * Modification History: * Date Author Version Description * ---------------------------------------------------------* * 2018/8/7 atao v1.0.0 创建 */ @Component public class SysOpAdviceDaoImpl implements SysOpAdviceDao { @Autowired private SysOpAdviceMapper sysOpAdviceMapper; @Autowired private SysOpAdviceSMapper sysOpAdviceSMapper; @Override public PageInfo querySysOpAdviceForPage(SysOpAdviceForPageQueryReq req) { SysOpAdviceExample example = new SysOpAdviceExample(); example.setOrderByClause("create_date desc "); Criteria criteria = example.createCriteria(); // criteria.andOpIdEqualTo(req.getOpId()); if (null != req.getStartCreateDate()) { criteria.andCreateDateGreaterThanOrEqualTo(req.getStartCreateDate()); } if (null != req.getEndCreateDate()) { criteria.andCreateDateLessThanOrEqualTo(req.getEndCreateDate()); } /**消息类型 1 待办消息 2 异常消息*/ if (null != req.getAdviceType() && req.getAdviceType() == 1) { criteria.andAdviceTypeGreaterThan(0); } if (null != req.getAdviceType() && req.getAdviceType() == 2) { criteria.andAdviceTypeLessThan(0); } if (null != req.getReadState()) { criteria.andReadStateEqualTo(req.getReadState()); } PageHelper.startPage(req.getBaseRequest().getPageNum(), req.getBaseRequest().getPageSize()); List list = sysOpAdviceMapper.selectByExample(example); return new PageInfo<>(list); } @Override public Integer batchSaveSysOpAdvice(List sysOpAdviceList) { return sysOpAdviceSMapper.batchSaveSysOpAdvice(sysOpAdviceList); } @Override public Integer updateOpAdviceReadState(OpAdviceReadStateUpdateReq req) { SysOpAdviceExample example = new SysOpAdviceExample(); Criteria criteria = example.createCriteria(); criteria.andOpIdEqualTo(req.getOpId()); if (CollectionUtils.isNotEmpty(req.getIds())) { criteria.andIdIn(req.getIds()); } SysOpAdvice opAdvice = new SysOpAdvice(); opAdvice.setReadState(req.getReadState()); opAdvice.setModfiyDate(new Date()); opAdvice.setModfiyEmpid(req.getsOpId() + ""); Integer num = sysOpAdviceMapper.updateByExampleSelective(opAdvice, example); return num; } @Override public Integer queryOpAdviceNumOfReadState(OpAdviceNumOfReadStateQueryReq req) { SysOpAdviceExample example = new SysOpAdviceExample(); Criteria criteria = example.createCriteria(); criteria.andOpIdEqualTo(req.getOpId()); criteria.andReadStateEqualTo(req.getReadState()); Long num = sysOpAdviceMapper.countByExample(example); return num.intValue(); } @Override public Boolean saveSysOpAdvice(SysOpAdvice sysOpAdvice) { return sysOpAdviceMapper.insertSelective(sysOpAdvice) > 0; } }