|
@@ -0,0 +1,158 @@
|
|
|
+package com.zhongzheng.modules.top.financial.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.top.financial.bo.TopInformSysUserAddBo;
|
|
|
+import com.zhongzheng.modules.top.financial.bo.TopInformSysUserEditBo;
|
|
|
+import com.zhongzheng.modules.top.financial.bo.TopInformSysUserQueryBo;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopInformRemind;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopInformSysUser;
|
|
|
+import com.zhongzheng.modules.top.financial.mapper.TopInformSysUserMapper;
|
|
|
+import com.zhongzheng.modules.top.financial.service.ITopInformRemindService;
|
|
|
+import com.zhongzheng.modules.top.financial.service.ITopInformSysUserService;
|
|
|
+import com.zhongzheng.modules.top.financial.vo.TopInformSysUserVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 通知绑定系统用户Service业务层处理
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2023-05-29
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TopInformSysUserServiceImpl extends ServiceImpl<TopInformSysUserMapper, TopInformSysUser> implements ITopInformSysUserService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITopInformRemindService iInformRemindService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TopInformSysUserVo queryById(Long id){
|
|
|
+ TopInformSysUser db = this.baseMapper.selectById(id);
|
|
|
+ TopInformSysUserVo vo = BeanUtil.toBean(db, TopInformSysUserVo.class);
|
|
|
+ if (ObjectUtils.isNotNull(vo.getRemindId())){
|
|
|
+ TopInformRemind informRemind = iInformRemindService.getById(vo.getRemindId());
|
|
|
+ vo.setType(informRemind.getType());
|
|
|
+ }else {
|
|
|
+ vo.setType(1);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TopInformSysUserVo> queryList(TopInformSysUserQueryBo bo) {
|
|
|
+ LambdaQueryWrapper<TopInformSysUser> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(bo.getUserId() != null, TopInformSysUser::getUserId, bo.getUserId());
|
|
|
+ lqw.eq(bo.getSendTime() != null, TopInformSysUser::getSendTime, bo.getSendTime());
|
|
|
+ lqw.eq(bo.getSendStatus() != null, TopInformSysUser::getSendStatus, bo.getSendStatus());
|
|
|
+ lqw.eq(bo.getReceiptStatus() != null, TopInformSysUser::getReceiptStatus, bo.getReceiptStatus());
|
|
|
+ lqw.eq(bo.getInformId() != null, TopInformSysUser::getInformId, bo.getInformId());
|
|
|
+ lqw.eq(bo.getSystemStatus() != null, TopInformSysUser::getSystemStatus, bo.getSystemStatus());
|
|
|
+ lqw.eq(bo.getRemindId() != null, TopInformSysUser::getRemindId, bo.getRemindId());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getText()), TopInformSysUser::getText, bo.getText());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getRemind()), TopInformSysUser::getRemind, bo.getRemind());
|
|
|
+ lqw.eq(bo.getGoodsId() != null, TopInformSysUser::getGoodsId, bo.getGoodsId());
|
|
|
+ lqw.eq(bo.getPlanId() != null, TopInformSysUser::getPlanId, bo.getPlanId());
|
|
|
+ lqw.eq(bo.getGradeId() != null, TopInformSysUser::getGradeId, bo.getGradeId());
|
|
|
+ lqw.eq(bo.getOrderGoodsId() != null, TopInformSysUser::getOrderGoodsId, bo.getOrderGoodsId());
|
|
|
+ lqw.eq(bo.getStatus() != null, TopInformSysUser::getStatus, bo.getStatus());
|
|
|
+ List<TopInformSysUserVo> informSysUserVos = entity2Vo(this.list(lqw));
|
|
|
+ if (CollectionUtils.isEmpty(informSysUserVos)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ informSysUserVos.forEach(item -> {
|
|
|
+ if (ObjectUtils.isNotNull(item.getRemindId())){
|
|
|
+ TopInformRemind informRemind = iInformRemindService.getById(item.getRemindId());
|
|
|
+ item.setType(informRemind.getType());
|
|
|
+ }else {
|
|
|
+ item.setType(1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return informSysUserVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TopInformSysUserVo> entity2Vo(Collection<TopInformSysUser> collection) {
|
|
|
+ List<TopInformSysUserVo> voList = collection.stream()
|
|
|
+ .map(any -> BeanUtil.toBean(any, TopInformSysUserVo.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collection instanceof Page) {
|
|
|
+ Page<TopInformSysUser> page = (Page<TopInformSysUser>)collection;
|
|
|
+ Page<TopInformSysUserVo> pageVo = new Page<>();
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
+ pageVo.addAll(voList);
|
|
|
+ voList = pageVo;
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean insertByAddBo(TopInformSysUserAddBo bo) {
|
|
|
+ TopInformSysUser add = BeanUtil.toBean(bo, TopInformSysUser.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return this.save(add);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer informUnReadSum(Long userId) {
|
|
|
+ return count(new LambdaQueryWrapper<TopInformSysUser>()
|
|
|
+ .eq(TopInformSysUser::getUserId,userId).eq(TopInformSysUser::getReceiptStatus,0).eq(TopInformSysUser::getSystemStatus,1)
|
|
|
+ .eq(TopInformSysUser::getStatus,1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateReadStatusBatch(TopInformSysUserEditBo bo) {
|
|
|
+ boolean result = false;
|
|
|
+ for(Long id : bo.getIds()){
|
|
|
+ TopInformSysUserEditBo editBo = new TopInformSysUserEditBo();
|
|
|
+ editBo.setId(id);
|
|
|
+ editBo.setReceiptStatus(bo.getReceiptStatus());
|
|
|
+ result = updateByEditBo(editBo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateByEditBo(TopInformSysUserEditBo bo) {
|
|
|
+ TopInformSysUser update = BeanUtil.toBean(bo, TopInformSysUser.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ *
|
|
|
+ * @param entity 实体类数据
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(TopInformSysUser entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return this.removeByIds(ids);
|
|
|
+ }
|
|
|
+}
|