This commit is contained in:
parent
f1192045c7
commit
1a05b1922f
|
@ -129,6 +129,8 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||
// 使用 openid 查询绑定用户 如未绑定用户 则根据业务自行处理 例如 创建默认用户
|
||||
return TenantHelper.ignore(() -> {
|
||||
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, phoneNumber));
|
||||
//.eq(SysUser::getStatus, 0)
|
||||
//.eq(SysUser::getDelFlag, 0));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
//newUser.setDeptId(100L);
|
||||
SysUser newUser = new SysUser();
|
||||
|
@ -142,7 +144,14 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||
userMapper.insert(newUser);
|
||||
return newUser;
|
||||
} else {
|
||||
if (user.getOpenId().equals(openid)) {
|
||||
String userOpenId = user.getOpenId();
|
||||
if (StringUtils.isEmpty(userOpenId)) {
|
||||
user.setOpenId(openid);
|
||||
userMapper.updateOpenIdById(openid, user.getUserId());
|
||||
//userMapper.updateById(user);
|
||||
return user;
|
||||
}
|
||||
if (userOpenId.equals(openid)) {
|
||||
return user;
|
||||
} else {
|
||||
throw new UserException("此用户已被其他微信号绑定", phoneNumber);
|
||||
|
|
|
@ -22,7 +22,9 @@ public enum UserType {
|
|||
/**
|
||||
* app端
|
||||
*/
|
||||
APP_USER("app_user");
|
||||
APP_USER("app_user"),
|
||||
|
||||
SYS_COUNSELOR("sys_counselor");
|
||||
|
||||
private final String userType;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.vo.ArchiveStatisticVo;
|
||||
import org.dromara.system.domain.vo.ArchiveVo;
|
||||
|
@ -35,13 +36,14 @@ public class ArchiveController extends BaseController {
|
|||
public TableDataInfo<ArchiveVo> pageList(ArchiveVo vo, PageQuery pageQuery) {
|
||||
return archiveService.queryPageList(vo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取档案静态列表
|
||||
*/
|
||||
@SaCheckPermission("scale:archive:list")
|
||||
@GetMapping("/statistic/pageList")
|
||||
public TableDataInfo<ArchiveStatisticVo> statisticPageList(Long userId, PageQuery pageQuery) {
|
||||
return archiveService.queryStatisticPageList(userId, pageQuery);
|
||||
return TenantHelper.ignore(() -> archiveService.queryStatisticPageList(userId, pageQuery));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SysUserController extends BaseController {
|
|||
@SaCheckPermission("system:user:import")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
||||
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener());
|
||||
return R.ok(result.getAnalysis());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
|
@ -48,7 +49,7 @@ public class WxOrderController extends BaseController {
|
|||
public TableDataInfo<SysScaleOrderVo> scaleOrderList(SysScaleOrderBo bo, PageQuery pageQuery) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
bo.setCreateBy(userId);
|
||||
return scaleOrderService.queryPageList(bo, pageQuery);
|
||||
return TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> scaleOrderService.queryPageList(bo, pageQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +72,13 @@ public class WxOrderController extends BaseController {
|
|||
public R<WxPayMpOrderResult> addScale(@Validated(AddGroup.class) @RequestBody SysScaleOrderBo bo, HttpServletRequest request) throws Exception {
|
||||
String clientIpAddress = getClientIpAddress(request);
|
||||
bo.setSpbillCreateIp(clientIpAddress);
|
||||
return R.ok(scaleOrderService.insertByBo(bo));
|
||||
return R.ok(TenantHelper.dynamic(TenantConstants.DEFAULT_TENANT_ID, () -> {
|
||||
try {
|
||||
return scaleOrderService.insertByBo(bo);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,7 +97,7 @@ public class SysUserBo extends BaseEntity {
|
|||
/**
|
||||
* 角色组
|
||||
*/
|
||||
@Size(min = 1, message = "用户角色不能为空")
|
||||
//@Size(min = 1, message = "用户角色不能为空")
|
||||
private Long[] roleIds;
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,8 @@ public class SysEvaluationConclusionVo implements Serializable {
|
|||
@ExcelProperty(value = "")
|
||||
private Long id;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* td_evaluation_record表id
|
||||
*/
|
||||
|
@ -92,6 +94,4 @@ public class SysEvaluationConclusionVo implements Serializable {
|
|||
private String situationName;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,42 +23,25 @@ public class SysUserImportVo implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@ExcelProperty(value = "用户序号")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@ExcelProperty(value = "部门编号")
|
||||
private Long deptId;
|
||||
@ExcelProperty(value = "部门名称")
|
||||
@ExcelDictFormat(dictType = "dept")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@ExcelProperty(value = "登录名称")
|
||||
@ExcelProperty(value = "登录账号(手机号)")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@ExcelProperty(value = "用户名称")
|
||||
@ExcelProperty(value = "姓名")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@ExcelProperty(value = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@ExcelProperty(value = "手机号码")
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
|
@ -66,11 +49,4 @@ public class SysUserImportVo implements Serializable {
|
|||
@ExcelDictFormat(dictType = "sys_user_sex")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,16 +5,19 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.excel.core.ExcelListener;
|
||||
import org.dromara.common.excel.core.ExcelResult;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysUserImportVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysConfigService;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -32,7 +35,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
|||
|
||||
private final String password;
|
||||
|
||||
private final Boolean isUpdateSupport;
|
||||
private final ISysDeptService deptService;
|
||||
|
||||
private final Long operUserId;
|
||||
|
||||
|
@ -41,41 +44,42 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
|||
private final StringBuilder successMsg = new StringBuilder();
|
||||
private final StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
public SysUserImportListener(Boolean isUpdateSupport) {
|
||||
public SysUserImportListener() {
|
||||
String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
|
||||
this.userService = SpringUtils.getBean(ISysUserService.class);
|
||||
this.deptService = SpringUtils.getBean(ISysDeptService.class);
|
||||
this.password = BCrypt.hashpw(initPassword);
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operUserId = LoginHelper.getUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(SysUserImportVo userVo, AnalysisContext context) {
|
||||
SysUserVo sysUser = this.userService.selectUserByUserName(userVo.getUserName());
|
||||
SysUserVo sysUser = TenantHelper.ignore(() -> this.userService.selectUserByUserName(userVo.getUserName()));
|
||||
|
||||
Long deptId = deptService.selectIdByName(userVo.getDeptName());
|
||||
if (deptId == null) {
|
||||
deptId = deptService.selectId4Parent();
|
||||
}
|
||||
try {
|
||||
if (deptId != null) {
|
||||
// 验证是否存在这个用户
|
||||
if (ObjectUtil.isNull(sysUser)) {
|
||||
SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
|
||||
ValidatorUtils.validate(user);
|
||||
user.setUserType(UserType.APP_USER.getUserType());
|
||||
user.setPassword(password);
|
||||
user.setDeptId(deptId);
|
||||
user.setCreateBy(operUserId);
|
||||
ValidatorUtils.validate(user);
|
||||
userService.insertUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
|
||||
} else if (isUpdateSupport) {
|
||||
Long userId = sysUser.getUserId();
|
||||
SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
|
||||
user.setUserId(userId);
|
||||
ValidatorUtils.validate(user);
|
||||
userService.checkUserAllowed(user.getUserId());
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(operUserId);
|
||||
userService.updateUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(sysUser.getUserName()).append(" 已存在");
|
||||
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 已存在");
|
||||
}
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(userVo.getUserName()).append(" 的部门不存在或没有主公司");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
|
|
|
@ -92,4 +92,5 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
|||
|
||||
List<SysUser> findUserByIds(String userIds);
|
||||
|
||||
int updateOpenIdById(@Param("openId") String openId, @Param("userId") Long userId);
|
||||
}
|
||||
|
|
|
@ -122,4 +122,8 @@ public interface ISysDeptService {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteDeptById(Long deptId);
|
||||
|
||||
Long selectIdByName(String deptName);
|
||||
|
||||
Long selectId4Parent();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.core.service.OssService;
|
||||
|
@ -229,7 +230,7 @@ public class CounselorServiceImpl implements ICounselorService {
|
|||
}
|
||||
user.setNickName(bo.getName());
|
||||
user.setPassword(BCrypt.hashpw("Mz123456!"));
|
||||
user.setUserType("sys_counselor");
|
||||
user.setUserType(UserType.SYS_COUNSELOR.getUserType());
|
||||
userService.insertUser(user);
|
||||
Counselor add = MapstructUtils.convert(bo, Counselor.class);
|
||||
add.setId(user.getUserId());
|
||||
|
|
|
@ -137,7 +137,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
@Override
|
||||
public Map<String, Object> submitAnswer(SubmitAnswerBo bo) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userType = loginUser.getUserType();
|
||||
//String userType = loginUser.getUserType();
|
||||
// if (!UserType.STUDENT.getName().equals(userType)) {
|
||||
// throw new ServiceException("只有学生账户才能测评");
|
||||
// }
|
||||
|
@ -156,6 +156,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
boolean allowQueryResult = true;
|
||||
Long scaleId = bo.getScaleId();
|
||||
SysScale sysScale = scaleMapper.selectById(scaleId);
|
||||
String tenantId = sysScale.getTenantId();
|
||||
Map<String, List<SysScaleAnswerVo>> answerMapByQuestion = scaleAnswerService.getScaleAnswerMap(scaleId);
|
||||
int keySize = answerMapByQuestion.keySet().size();
|
||||
if (ObjectUtil.isEmpty(answerList)) {
|
||||
|
@ -175,10 +176,10 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
List<SysEvaluationConclusionVo> list;
|
||||
if (sysScale.getScaleName().contains("MBTI")) {
|
||||
//MBTI 另外处理
|
||||
list = calculateMBTIResult(scaleId, answerList);
|
||||
list = calculateMBTIResult(scaleId, tenantId, answerList);
|
||||
} else {
|
||||
//计算
|
||||
list = calculateEvaluationResult(scaleId, answerList);
|
||||
list = calculateEvaluationResult(scaleId, tenantId, answerList);
|
||||
}
|
||||
List<SysEvaluationConclusion> conclusionAdd = MapstructUtils.convert(list, SysEvaluationConclusion.class);
|
||||
evaluationConclusionMapper.insertBatch(conclusionAdd);
|
||||
|
@ -248,7 +249,9 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
}
|
||||
|
||||
|
||||
private List<SysEvaluationConclusionVo> calculateEvaluationResult(Long scaleId, List<SysEvaluationAnswerBo> answerList) {
|
||||
private List<SysEvaluationConclusionVo> calculateEvaluationResult(Long scaleId, String tenantId, List<SysEvaluationAnswerBo> answerList) {
|
||||
//LoginUser loginUser = getLoginUser();
|
||||
//String tenantId = loginUser.getTenantId();
|
||||
Long recordId = answerList.get(0).getRecordId();
|
||||
//暂时使用string解决redis转换问题
|
||||
//key为factorId
|
||||
|
@ -265,6 +268,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
|
||||
SysEvaluationConclusionVo evalConclusion = new SysEvaluationConclusionVo();
|
||||
evalConclusion.setFactorName(scaleFactor.getFactorName());
|
||||
evalConclusion.setTenantId(tenantId);
|
||||
evalConclusion.setFactorId(factorId);
|
||||
evalConclusion.setRecordId(recordId);
|
||||
evalConclusion.setStatus(StatusEnum.DISABLED.getValue());
|
||||
|
@ -419,7 +423,9 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<SysEvaluationConclusionVo> calculateMBTIResult(Long scaleId, List<SysEvaluationAnswerBo> answerList) {
|
||||
private List<SysEvaluationConclusionVo> calculateMBTIResult(Long scaleId, String tenantId, List<SysEvaluationAnswerBo> answerList) {
|
||||
//LoginUser loginUser = getLoginUser();
|
||||
//String tenantId = loginUser.getTenantId();
|
||||
Long recordId = answerList.get(0).getRecordId();
|
||||
//key为questionID
|
||||
ConcurrentHashMap<String, Integer> charNumMap = new ConcurrentHashMap<>(8);
|
||||
|
@ -460,6 +466,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
if (Objects.equals(collect, split)) {
|
||||
SysEvaluationConclusionVo evalConclusion = new SysEvaluationConclusionVo();
|
||||
evalConclusion.setFactorName(scaleFactor.getFactorName());
|
||||
evalConclusion.setTenantId(tenantId);
|
||||
evalConclusion.setFactorId(scaleFactor.getFactorId());
|
||||
evalConclusion.setRecordId(recordId);
|
||||
evalConclusion.setStatus(StatusEnum.IN_USE.getValue());
|
||||
|
|
|
@ -334,4 +334,28 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||
return baseMapper.deleteById(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long selectIdByName(String deptName) {
|
||||
SysDept sysDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId)
|
||||
.eq(SysDept::getDeptName, deptName)
|
||||
.eq(SysDept::getStatus, 0));
|
||||
if (ObjectUtil.isNotEmpty(sysDept)) {
|
||||
return sysDept.getDeptId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Long selectId4Parent(){
|
||||
SysDept sysDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId)
|
||||
.eq(SysDept::getParentId, 0)
|
||||
.eq(SysDept::getStatus, 0));
|
||||
if (ObjectUtil.isNotEmpty(sysDept)) {
|
||||
return sysDept.getDeptId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
from sys_user u
|
||||
left join sys_dept d on d.dept_id = u.dept_id
|
||||
where u.user_type = 'app_user'
|
||||
and u.status = 0
|
||||
and u.del_flag = 0
|
||||
<if test="query.nickName != null and query.nickName != ''">
|
||||
and u.nick_name like CONCAT('%', #{query.nickName}, '%')
|
||||
</if>
|
||||
|
|
|
@ -80,5 +80,8 @@
|
|||
<select id="findUserByIds" resultType="org.dromara.system.domain.SysUser">
|
||||
select * from sys_user where find_in_set(user_id, #{userIds})
|
||||
</select>
|
||||
<update id="updateOpenIdById">
|
||||
update sys_user set open_id = #{openId} where user_id= #{userId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue