package com.zteits.sys.biz; import com.github.pagehelper.PageInfo; import com.zteits.clouds.api.apibase.bean.BizResult; import com.zteits.clouds.api.apibase.bean.PageBean; import com.zteits.clouds.api.apibase.constants.ErrorType; import com.zteits.clouds.api.apibase.exception.BizException; import com.zteits.clouds.api.dto.sys.SysOpAdviceDTO; 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.clouds.api.dto.sys.param.SysOpAdviceSaveRequest; import com.zteits.clouds.api.service.sys.advice.SysOpAdviceService; import com.zteits.sys.dao.SysOpAdviceDao; import com.zteits.sys.domain.SysOpAdvice; import com.zteits.sys.pagepaper.PageBeanUtil; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * Copyright: Copyright (c) 2018 zteits * * @ClassName: com.zteits.sys.biz * @Description: * @version: v1.0.0 * @author: atao * @date: 2018/8/9 下午3:27 * Modification History: * Date Author Version Description * ---------------------------------------------------------* * 2018/8/9 atao v1.0.0 创建 */ @Component public class SysOpAdviceServiceImpl implements SysOpAdviceService { @Autowired private SysOpAdviceDao sysOpAdviceDao; @Override public BizResult> querySysOpAdviceForPage(SysOpAdviceForPageQueryReq req) { // if (req.getOpId() == null) { // throw new BizException(ErrorType.PARAMM_NULL, "人员编码"); // } PageInfo pageInfo = sysOpAdviceDao.querySysOpAdviceForPage(req); PageBean pageBean = new PageBean<>(); if (null != pageInfo) { PageBeanUtil.copyProperties(pageInfo, pageBean, SysOpAdviceDTO.class); } return new BizResult<>(pageBean); } @Override public BizResult updateOpAdviceReadState(OpAdviceReadStateUpdateReq req) { if (req.getOpId() == null) { throw new BizException(ErrorType.PARAMM_NULL, "人员编码"); } if (req.getReadState() == null) { throw new BizException(ErrorType.PARAMM_NULL, "阅读状态"); } Integer num = sysOpAdviceDao.updateOpAdviceReadState(req); return new BizResult<>(num); } @Override public BizResult queryOpAdviceNumOfReadState(OpAdviceNumOfReadStateQueryReq req) { if (req.getOpId() == null) { throw new BizException(ErrorType.PARAMM_NULL, "人员编码"); } if (req.getReadState() == null) { throw new BizException(ErrorType.PARAMM_NULL, "阅读状态"); } Integer num = sysOpAdviceDao.queryOpAdviceNumOfReadState(req); return new BizResult<>(num); } @Override public BizResult saveOpAdviceInfo(SysOpAdviceSaveRequest req) { if (req.getOpId() == null) { throw new BizException(ErrorType.PARAMM_NULL, "人员编码"); } if (req.getAdviceType() == null) { throw new BizException(ErrorType.PARAMM_NULL, "消息类型"); } SysOpAdvice sysOpAdvice = new SysOpAdvice(); BeanUtils.copyProperties(req, sysOpAdvice); Boolean result = sysOpAdviceDao.saveSysOpAdvice(sysOpAdvice); return new BizResult<>(result); } }