|
|
@@ -0,0 +1,86 @@
|
|
|
+package com.zhongzheng.modules.user.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.user.bo.UserHandleBo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserHandleImportBo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserHandleQueryBo;
|
|
|
+import com.zhongzheng.modules.user.domain.UserHandle;
|
|
|
+import com.zhongzheng.modules.user.mapper.UserHandleMapper;
|
|
|
+import com.zhongzheng.modules.user.service.IUserHandleService;
|
|
|
+import com.zhongzheng.modules.user.vo.UserHandleVo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 高校Service业务层处理
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2021-10-09
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class UserHandleServiceImpl extends ServiceImpl<UserHandleMapper, UserHandle> implements IUserHandleService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<UserHandleVo> queryUserHandleList(UserHandleQueryBo bo) {
|
|
|
+ List<UserHandle> list = list(new LambdaQueryWrapper<UserHandle>()
|
|
|
+ .eq(UserHandle::getStatus, 1)
|
|
|
+ .eq(StringUtils.isNotBlank(bo.getEdu()), UserHandle::getHandleEdu, bo.getEdu())
|
|
|
+ .and(ObjectUtils.isNotNull(bo.getKeyWord()), x -> x.like(UserHandle::getHandleName, bo.getKeyWord())
|
|
|
+ .or().like(UserHandle::getHandleCard, bo.getKeyWord()).or().like(UserHandle::getHandlePhone, bo.getKeyWord()))
|
|
|
+ .orderByDesc(UserHandle::getCreateTime));
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return list.stream().map(item -> BeanUtil.toBean(item,UserHandleVo.class)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean saveUserHandle(UserHandleBo bo) {
|
|
|
+ UserHandle userHandle = BeanUtil.toBean(bo, UserHandle.class);
|
|
|
+ userHandle.setCreateTime(DateUtils.getNowTime());
|
|
|
+ userHandle.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return save(userHandle);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean editUserHandle(UserHandleBo bo) {
|
|
|
+ UserHandle userHandle = BeanUtil.toBean(bo, UserHandle.class);
|
|
|
+ userHandle.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return updateById(userHandle);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean batchDelUserHandle(List<Long> ids) {
|
|
|
+ return update(new LambdaUpdateWrapper<UserHandle>()
|
|
|
+ .in(UserHandle::getId,ids)
|
|
|
+ .set(UserHandle::getStatus,-1)
|
|
|
+ .set(UserHandle::getCreateTime,DateUtils.getNowTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void importUserHandle(List<UserHandleImportBo> userHandles,Long userId) {
|
|
|
+ if (CollectionUtils.isEmpty(userHandles)){
|
|
|
+ throw new CustomException("导入文件有误!请检查文件");
|
|
|
+ }
|
|
|
+ List<UserHandle> handles = userHandles.stream().map(item -> {
|
|
|
+ UserHandle userHandle = BeanUtil.toBean(item, UserHandle.class);
|
|
|
+ userHandle.setHandleSex(StringUtils.isNotBlank(item.getHandleSexStr()) && item.getHandleSexStr().equals("男") ? 1 : 2);
|
|
|
+ userHandle.setUserId(userId);
|
|
|
+ userHandle.setCreateTime(DateUtils.getNowTime());
|
|
|
+ userHandle.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return userHandle;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ saveBatch(handles);
|
|
|
+ }
|
|
|
+}
|