|
@@ -1,35 +1,42 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.SysArea;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
|
+import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantStaffMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysAreaService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.enums.SysUserType;
|
|
|
+import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.MessageFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -88,7 +95,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
for (int i = 0; i < tenantInfos.size(); i++) {
|
|
|
TenantInfoWrapper.TenantInfo info = tenantInfos.get(i);
|
|
|
long id = info.getId();
|
|
|
- listId.add(i,(int)id);
|
|
|
+ listId.add(i, (int) id);
|
|
|
}
|
|
|
//查询对应机构的老师数量
|
|
|
List<Integer> listTeacher = new ArrayList<>();
|
|
@@ -117,7 +124,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
@@ -126,7 +132,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean add(TenantInfo tenantInfo) {
|
|
|
- getOrCreateAccount(tenantInfo);
|
|
|
+ SysUser sysUser = getOrCreateAccount(tenantInfo);
|
|
|
+
|
|
|
+ TenantStaff tenantStaff = new TenantStaff();
|
|
|
+ tenantStaff.setTenantId(tenantStaff.getTenantId());
|
|
|
+ tenantStaff.setUserId(sysUser.getId());
|
|
|
+ tenantStaff.setAvatar(sysUser.getAvatar());
|
|
|
+ tenantStaff.setNickname(tenantInfo.getUsername());
|
|
|
+ tenantStaff.setStatus(UserLockFlag.NORMAL);
|
|
|
+ tenantStaffMapper.insert(tenantStaff);
|
|
|
+
|
|
|
tenantInfo.setEnableFlag(true);
|
|
|
tenantInfoMapper.insert(tenantInfo);
|
|
|
return true;
|
|
@@ -140,7 +155,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
//若存在信息
|
|
|
if (!sysUsers.isEmpty()) {
|
|
|
sysUser = sysUsers.get(0);
|
|
|
- TenantStaff tenantStaff = tenantStaffMapper.getByPhone(tenantInfo.getPhone());
|
|
|
+ TenantStaff tenantStaff = tenantStaffMapper.selectById(sysUser.getId());
|
|
|
if (tenantStaff != null) {
|
|
|
throw new BizException("手机号已经注册机构账号");
|
|
|
}
|
|
@@ -156,8 +171,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
//更新当前账号的用户名
|
|
|
sysUser.setUsername(tenantInfo.getUsername());
|
|
|
- //更新当前账号的手机号
|
|
|
- sysUser.setPhone(tenantInfo.getPhone());
|
|
|
|
|
|
sysUserMapper.updateById(sysUser);
|
|
|
} else {
|
|
@@ -170,17 +183,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
String password = new BCryptPasswordEncoder().encode(newPassword);
|
|
|
sysUser.setPassword(password);
|
|
|
sysUserMapper.insert(sysUser);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- TenantStaff tenantStaff = new TenantStaff();
|
|
|
- tenantStaff.setTenantId(tenantStaff.getTenantId());
|
|
|
- tenantStaff.setUserId(sysUser.getId());
|
|
|
- tenantStaff.setAvatar(sysUser.getAvatar());
|
|
|
- tenantStaff.setNickname(tenantInfo.getUsername());
|
|
|
- tenantStaff.setStatus("ACTIVE");
|
|
|
- tenantStaffMapper.insert(tenantStaff);
|
|
|
return sysUser;
|
|
|
}
|
|
|
|
|
@@ -259,7 +262,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 更新
|
|
|
*
|
|
@@ -268,20 +270,37 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean updateTenantInfo(TenantInfo info) {
|
|
|
- getOrCreateAccount(info);
|
|
|
- Boolean bool = tenantInfoMapper.updateInfo(info);
|
|
|
- return bool;
|
|
|
+ SysUser sysUser = getOrCreateAccount(info);
|
|
|
+
|
|
|
+ TenantInfo oldTenantInfo = this.getById(info.getId());
|
|
|
+ tenantStaffMapper.update(null, Wrappers.<TenantStaff>lambdaUpdate()
|
|
|
+ .set(TenantStaff::getUserId, sysUser.getId())
|
|
|
+ .set(TenantStaff::getNickname, info.getUsername())
|
|
|
+ .eq(TenantStaff::getUserId, oldTenantInfo.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ tenantInfoMapper.update(null, Wrappers.<TenantInfo>lambdaUpdate()
|
|
|
+ .set(TenantInfo::getName, info.getName())
|
|
|
+ .set(TenantInfo::getLogo, info.getLogo())
|
|
|
+ .set(TenantInfo::getBriefIntroduction, info.getBriefIntroduction())
|
|
|
+ .set(TenantInfo::getProvinceCode, info.getProvinceCode())
|
|
|
+ .set(TenantInfo::getCityCode, info.getCityCode())
|
|
|
+ .set(TenantInfo::getRegionCode, info.getRegionCode())
|
|
|
+ .eq(TenantInfo::getId, info.getId())
|
|
|
+ );
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 机构申请分页查询
|
|
|
+ *
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public IPage<TenantInfoWrapper.TenantInfo> applyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ public IPage<TenantInfoWrapper.TenantInfo> applyPage(IPage<TenantInfoWrapper.TenantInfo> page,
|
|
|
+ TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
//分页查询
|
|
|
List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectApplyPage(page, query);
|
|
|
List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
|
|
@@ -291,11 +310,13 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
/**
|
|
|
* 机构入驻审核历史记录查询
|
|
|
+ *
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
+ public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page,
|
|
|
+ TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
long id = query.getId();
|
|
|
//分页查询
|
|
|
List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectHistoryPage(page, id);
|
|
@@ -307,6 +328,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
/**
|
|
|
* 机构入驻审核本次提交查询
|
|
|
+ *
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
@@ -341,7 +363,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
public Boolean entry(TenantInfoWrapper.TenantInfoQuery query) {
|
|
|
Integer pass = query.getIfPass();
|
|
|
//审核通过
|
|
|
- if (pass == 1){
|
|
|
+ if (pass == 1) {
|
|
|
//查询本次提交记录,并插入审核表
|
|
|
TenantInfoWrapper.TenantInfo info = queryNow(query);
|
|
|
tenantInfoMapper.insertNow(info);
|
|
@@ -359,6 +381,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
|
|
|
|
|
|
/**
|
|
|
* 匹配地区码与省市区
|
|
|
+ *
|
|
|
* @param tenantInfos
|
|
|
* @return
|
|
|
*/
|