Merge remote-tracking branch 'CEES-CMD/new-1.0' into new-1.0
# Conflicts: # jeecg-module-system/jeecg-system-start/src/main/java/org/jeecg/modules/service/ICeesUserService.java # jeecg-module-system/jeecg-system-start/src/main/java/org/jeecg/modules/service/impl/CeesUserServiceImpl.java
This commit is contained in:
commit
461705254b
|
@ -0,0 +1,155 @@
|
||||||
|
package org.jeecg.modules.contoller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.modules.entity.CeesAdminInfo;
|
||||||
|
import org.jeecg.modules.service.ICeesAdminInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cees_admin_info
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-04-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Api(tags="cees_admin_info")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cees/ceesAdminInfo")
|
||||||
|
@Slf4j
|
||||||
|
public class CeesAdminInfoController extends JeecgController<CeesAdminInfo, ICeesAdminInfoService> {
|
||||||
|
@Autowired
|
||||||
|
private ICeesAdminInfoService ceesAdminInfoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param ceesAdminInfo
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "cees_admin_info-分页列表查询")
|
||||||
|
@ApiOperation(value="cees_admin_info-分页列表查询", notes="cees_admin_info-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<CeesAdminInfo>> queryPageList(CeesAdminInfo ceesAdminInfo,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<CeesAdminInfo> queryWrapper = QueryGenerator.initQueryWrapper(ceesAdminInfo, req.getParameterMap());
|
||||||
|
Page<CeesAdminInfo> page = new Page<CeesAdminInfo>(pageNo, pageSize);
|
||||||
|
IPage<CeesAdminInfo> pageList = ceesAdminInfoService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param ceesAdminInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cees_admin_info-添加")
|
||||||
|
@ApiOperation(value="cees_admin_info-添加", notes="cees_admin_info-添加")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody CeesAdminInfo ceesAdminInfo) {
|
||||||
|
ceesAdminInfoService.save(ceesAdminInfo);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param ceesAdminInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cees_admin_info-编辑")
|
||||||
|
@ApiOperation(value="cees_admin_info-编辑", notes="cees_admin_info-编辑")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody CeesAdminInfo ceesAdminInfo) {
|
||||||
|
ceesAdminInfoService.updateById(ceesAdminInfo);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cees_admin_info-通过id删除")
|
||||||
|
@ApiOperation(value="cees_admin_info-通过id删除", notes="cees_admin_info-通过id删除")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
ceesAdminInfoService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "cees_admin_info-批量删除")
|
||||||
|
@ApiOperation(value="cees_admin_info-批量删除", notes="cees_admin_info-批量删除")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.ceesAdminInfoService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "cees_admin_info-通过id查询")
|
||||||
|
@ApiOperation(value="cees_admin_info-通过id查询", notes="cees_admin_info-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<CeesAdminInfo> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
|
CeesAdminInfo ceesAdminInfo = ceesAdminInfoService.getById(id);
|
||||||
|
if(ceesAdminInfo==null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(ceesAdminInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param ceesAdminInfo
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, CeesAdminInfo ceesAdminInfo) {
|
||||||
|
return super.exportXls(request, ceesAdminInfo, CeesAdminInfo.class, "cees_admin_info");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, CeesAdminInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -78,11 +78,11 @@ public class CeesUserController extends JeecgController<CeesUser, ICeesUserServi
|
||||||
@PostMapping("/createAccount")
|
@PostMapping("/createAccount")
|
||||||
public Result<?> createAccount(@RequestBody CreateAccountDto createAccountDto) {
|
public Result<?> createAccount(@RequestBody CreateAccountDto createAccountDto) {
|
||||||
try {
|
try {
|
||||||
ceesUserService.createAccount(createAccountDto);
|
return Result.OK(ceesUserService.createAccount(createAccountDto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Result.error(e.getMessage());
|
return Result.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return Result.OK();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cees_admin_info
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-04-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cees_admin_info")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="cees_admin_info对象", description="cees_admin_info")
|
||||||
|
public class CeesAdminInfo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**id*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
/**工号*/
|
||||||
|
@Excel(name = "工号", width = 15)
|
||||||
|
@ApiModelProperty(value = "工号")
|
||||||
|
private String workNumber;
|
||||||
|
/**姓名*/
|
||||||
|
@Excel(name = "姓名", width = 15)
|
||||||
|
@ApiModelProperty(value = "姓名")
|
||||||
|
private String userName;
|
||||||
|
/**用户id*/
|
||||||
|
@Excel(name = "用户id", width = 15)
|
||||||
|
@ApiModelProperty(value = "用户id")
|
||||||
|
private String userId;
|
||||||
|
/**用户专业id*/
|
||||||
|
@Excel(name = "用户专业id", width = 15)
|
||||||
|
@ApiModelProperty(value = "用户专业id")
|
||||||
|
private String userMajorId;
|
||||||
|
/**专业id,0表示未选择*/
|
||||||
|
@Excel(name = "专业id,0表示未选择", width = 15)
|
||||||
|
@ApiModelProperty(value = "专业id,0表示未选择")
|
||||||
|
private Integer majorId;
|
||||||
|
/**组别*/
|
||||||
|
@Excel(name = "组别", width = 15)
|
||||||
|
@ApiModelProperty(value = "组别")
|
||||||
|
private String groupId;
|
||||||
|
/**组级别*/
|
||||||
|
@Excel(name = "组级别", width = 15)
|
||||||
|
@ApiModelProperty(value = "组级别")
|
||||||
|
private String beforeGroupLevel;
|
||||||
|
/**组级别*/
|
||||||
|
@Excel(name = "组级别", width = 15)
|
||||||
|
@ApiModelProperty(value = "组级别")
|
||||||
|
private String groupLevel;
|
||||||
|
/**之前的职务*/
|
||||||
|
@Excel(name = "之前的职务", width = 15)
|
||||||
|
@ApiModelProperty(value = "之前的职务")
|
||||||
|
private String beforeDuty;
|
||||||
|
/**职务*/
|
||||||
|
@Excel(name = "职务", width = 15)
|
||||||
|
@ApiModelProperty(value = "职务")
|
||||||
|
private String duty;
|
||||||
|
/**部门*/
|
||||||
|
@Excel(name = "部门", width = 15)
|
||||||
|
@ApiModelProperty(value = "部门")
|
||||||
|
private String department;
|
||||||
|
/**岗位*/
|
||||||
|
@Excel(name = "岗位", width = 15)
|
||||||
|
@ApiModelProperty(value = "岗位")
|
||||||
|
private String job;
|
||||||
|
/**时间*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "时间")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jeecg.modules.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.entity.CeesAdminInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cees_admin_info
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-04-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface CeesAdminInfoMapper extends BaseMapper<CeesAdminInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.jeecg.modules.mapper.CeesAdminInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.jeecg.modules.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.entity.CeesAdminInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cees_admin_info
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-04-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface ICeesAdminInfoService extends IService<CeesAdminInfo> {
|
||||||
|
|
||||||
|
}
|
|
@ -22,9 +22,10 @@ public interface ICeesUserService extends IService<CeesUser> {
|
||||||
|
|
||||||
Result<?> getGroupName(String groupId);
|
Result<?> getGroupName(String groupId);
|
||||||
|
|
||||||
void createAccount(CreateAccountDto createAccountDto);
|
// void createAccount(CreateAccountDto createAccountDto);
|
||||||
|
|
||||||
Result<?> getGenerativeRules();
|
Result<?> getGenerativeRules();
|
||||||
|
|
||||||
Result<?> updateGenerateRule(Long id, Integer groupType, Integer majorId);
|
Result<?> updateGenerateRule(Long id, Integer groupType, Integer majorId);
|
||||||
|
Result<?> createAccount(CreateAccountDto createAccountDto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.modules.entity.CeesAdminInfo;
|
||||||
|
import org.jeecg.modules.mapper.CeesAdminInfoMapper;
|
||||||
|
import org.jeecg.modules.service.ICeesAdminInfoService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: cees_admin_info
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-04-27
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CeesAdminInfoServiceImpl extends ServiceImpl<CeesAdminInfoMapper, CeesAdminInfo> implements ICeesAdminInfoService {
|
||||||
|
|
||||||
|
}
|
|
@ -39,6 +39,8 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
@Resource
|
@Resource
|
||||||
CeesGroupMapper ceesGroupMapper;
|
CeesGroupMapper ceesGroupMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
CeesAdminInfoMapper ceesAdminInfoMapper;
|
||||||
|
@Resource
|
||||||
CeesLocalTeacherMapper ceesLocalTeacherMapper;
|
CeesLocalTeacherMapper ceesLocalTeacherMapper;
|
||||||
@Resource
|
@Resource
|
||||||
CeesWaiTeacherMapper ceesWaiTeacherMapper;
|
CeesWaiTeacherMapper ceesWaiTeacherMapper;
|
||||||
|
@ -116,9 +118,20 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
}
|
}
|
||||||
// 检查四个身份
|
// 检查四个身份
|
||||||
switch (user.getIdentity().toString()) {
|
switch (user.getIdentity().toString()) {
|
||||||
//1管理员
|
//1行政人员
|
||||||
case "1":
|
case "1":
|
||||||
|
LambdaQueryWrapper<CeesAdminInfo> adminInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
adminInfoLambdaQueryWrapper.eq(CeesAdminInfo::getUserId, user.getUserId());
|
||||||
|
CeesAdminInfo ceesAdminInfo = ceesAdminInfoMapper.selectOne(adminInfoLambdaQueryWrapper);
|
||||||
|
if (ceesAdminInfo != null) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("userId", user.getUserId());
|
||||||
|
jsonObject.put("router", "/leaderShip");
|
||||||
|
jsonObject.put("status", "2"); //无需填写信息
|
||||||
|
return Result.ok(jsonObject);
|
||||||
|
} else {
|
||||||
|
return Result.error("管理员账号还未申请通过!");
|
||||||
|
}
|
||||||
// 2学生
|
// 2学生
|
||||||
case "2":
|
case "2":
|
||||||
LambdaQueryWrapper<Student> studentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Student> studentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
@ -194,6 +207,19 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if (ceesUser.getIdentity() == 1) {
|
if (ceesUser.getIdentity() == 1) {
|
||||||
// 管理员
|
// 管理员
|
||||||
|
jsonObject.put("show0", false);
|
||||||
|
jsonObject.put("show1", true);
|
||||||
|
jsonObject.put("show3", false);
|
||||||
|
jsonObject.put("show5", false);
|
||||||
|
jsonObject.put("show6", true);
|
||||||
|
jsonObject.put("show7", true);
|
||||||
|
jsonObject.put("show8", false);
|
||||||
|
LambdaQueryWrapper<CeesAdminInfo> adminInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
adminInfoLambdaQueryWrapper.eq(CeesAdminInfo::getUserId, userId);
|
||||||
|
CeesAdminInfo ceesAdminInfo = ceesAdminInfoMapper.selectOne(adminInfoLambdaQueryWrapper);
|
||||||
|
if (ceesAdminInfo != null) {
|
||||||
|
jsonObject.put("user", ceesAdminInfo);
|
||||||
|
}
|
||||||
} else if (ceesUser.getIdentity() == 2) {
|
} else if (ceesUser.getIdentity() == 2) {
|
||||||
// 学生
|
// 学生
|
||||||
jsonObject.put("show0", true);
|
jsonObject.put("show0", true);
|
||||||
|
@ -258,19 +284,18 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param createAccountDto
|
* @param createAccountDto
|
||||||
* @param groupType
|
|
||||||
* @param majorId
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createAccount(CreateAccountDto createAccountDto) {
|
public Result<?> createAccount(CreateAccountDto createAccountDto) {
|
||||||
Integer groupType = createAccountDto.getGroup();
|
Integer groupType = createAccountDto.getGroup();
|
||||||
Integer num = createAccountDto.getNum();
|
Integer num = createAccountDto.getNum();
|
||||||
Integer majorId = createAccountDto.getMajorId();
|
Integer majorId = createAccountDto.getMajorId();
|
||||||
// 参数校验
|
if (groupType != 1) {
|
||||||
if (groupType == null || num == null || majorId == null || num <= 0) {
|
// 参数校验
|
||||||
throw new IllegalArgumentException("参数无效");
|
if (groupType == null || num == null || majorId == null || num <= 0) {
|
||||||
}
|
throw new IllegalArgumentException("参数无效");
|
||||||
|
}
|
||||||
|
|
||||||
// 获取生成规则
|
// 获取生成规则
|
||||||
CeesGenerativeRules rules = GetGenerativeRules();
|
CeesGenerativeRules rules = GetGenerativeRules();
|
||||||
|
@ -278,32 +303,32 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
throw new IllegalArgumentException("找不到对应的账号生成规则");
|
throw new IllegalArgumentException("找不到对应的账号生成规则");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 存储已存在的用户ID
|
// 存储已存在的用户ID
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
// 存储与majorID相关的用户专业id
|
// 存储与majorID相关的用户专业id
|
||||||
List<String> userMIDList = new ArrayList<>();
|
List<String> userMIDList = new ArrayList<>();
|
||||||
// 存储新生成的用户对象
|
// 存储新生成的用户对象
|
||||||
List<CeesUser> h5Users = new ArrayList<>();
|
List<CeesUser> h5Users = new ArrayList<>();
|
||||||
// 获取所有用户
|
// 获取所有用户
|
||||||
List<CeesUser> list = this.list();
|
List<CeesUser> list = this.list();
|
||||||
|
|
||||||
// 遍历现有用户
|
// 遍历现有用户
|
||||||
list.forEach(item -> {
|
list.forEach(item -> {
|
||||||
set.add(item.getUserId());
|
set.add(item.getUserId());
|
||||||
if (Objects.equals(item.getMajorId(), majorId)) {
|
if (Objects.equals(item.getMajorId(), majorId)) {
|
||||||
userMIDList.add(item.getUserMajorId());
|
userMIDList.add(item.getUserMajorId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 根据专业 ID 生成账号
|
// 根据专业 ID 生成账号
|
||||||
String prefix = getPrefixByMajorId(majorId);
|
String prefix = getPrefixByMajorId(majorId);
|
||||||
String startId = userMIDList.isEmpty() ? getDefaultStartId(majorId) : userMIDList.get(userMIDList.size() - 1);
|
String startId = userMIDList.isEmpty() ? getDefaultStartId(majorId) : userMIDList.get(userMIDList.size() - 1);
|
||||||
saveAccount(num, set, groupType, h5Users, majorId, startId, prefix, rules);
|
saveAccount(num, set, groupType, h5Users, majorId, startId, prefix, rules);
|
||||||
|
|
||||||
// 保存生成的用户账号
|
// 保存生成的用户账号
|
||||||
this.saveBatch(h5Users);
|
this.saveBatch(h5Users);
|
||||||
|
|
||||||
//TODO 邀请函生成
|
//TODO 邀请函生成
|
||||||
// if (groupType == 9) {
|
// if (groupType == 9) {
|
||||||
// List<H5Invitation> h5Invitations = h5Users.stream()
|
// List<H5Invitation> h5Invitations = h5Users.stream()
|
||||||
// .map(item -> new H5Invitation(item.getUserId(), item.getGroupId(), item.getUserMajorId(), item.getMajorId()))
|
// .map(item -> new H5Invitation(item.getUserId(), item.getGroupId(), item.getUserMajorId(), item.getMajorId()))
|
||||||
|
@ -311,10 +336,16 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
// h5InvitationService.saveBatch(h5Invitations);
|
// h5InvitationService.saveBatch(h5Invitations);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 清理资源
|
// 清理资源
|
||||||
h5Users.clear();
|
h5Users.clear();
|
||||||
set.clear();
|
set.clear();
|
||||||
userMIDList.clear();
|
userMIDList.clear();
|
||||||
|
return Result.ok("生成账号成功!");
|
||||||
|
} else {
|
||||||
|
//行政人员账号生成
|
||||||
|
createAdminAccount(num, groupType);
|
||||||
|
return Result.ok("生成账号成功!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取生成规则---用户前端获取rule
|
// 获取生成规则---用户前端获取rule
|
||||||
|
@ -463,4 +494,102 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
|
||||||
h5User.setUpdateTime(LocalDateTime.now());
|
h5User.setUpdateTime(LocalDateTime.now());
|
||||||
return h5User;
|
return h5User;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 生成行政人员账号
|
||||||
|
* @param num 生成数量
|
||||||
|
* @param groupType 账号类型(1表示行政人员)
|
||||||
|
*/
|
||||||
|
private void createAdminAccount(Integer num, Integer groupType) {
|
||||||
|
// 参数校验
|
||||||
|
if (num == null || num <= 0) {
|
||||||
|
throw new IllegalArgumentException("生成数量必须大于0");
|
||||||
|
}
|
||||||
|
if (groupType == null || groupType != 1) {
|
||||||
|
throw new IllegalArgumentException("账号类型必须是行政人员(1)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取生成规则
|
||||||
|
CeesGenerativeRules rules = getGenerativeRules();
|
||||||
|
if (rules == null) {
|
||||||
|
throw new IllegalArgumentException("找不到对应的账号生成规则");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储已存在的用户ID
|
||||||
|
Set<String> existingAccounts = new HashSet<>();
|
||||||
|
// 存储新生成的用户对象
|
||||||
|
List<CeesUser> newUsers = new ArrayList<>();
|
||||||
|
|
||||||
|
// 获取所有已有账号
|
||||||
|
this.list().forEach(user -> existingAccounts.add(user.getUserId()));
|
||||||
|
|
||||||
|
// 生成账号
|
||||||
|
while (num > 0) {
|
||||||
|
String randomNum = getRandomNum(8);
|
||||||
|
// 生成账号 - 只考虑groupType,不需要majorId
|
||||||
|
String account = generateAdminAccount(randomNum, groupType, rules);
|
||||||
|
|
||||||
|
if (!existingAccounts.contains(account)) {
|
||||||
|
num--;
|
||||||
|
CeesUser adminUser = createAdminUser(account, groupType);
|
||||||
|
newUsers.add(adminUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量保存新账号
|
||||||
|
if (!newUsers.isEmpty()) {
|
||||||
|
this.saveBatch(newUsers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成行政人员账号
|
||||||
|
* @param randomNum 随机数
|
||||||
|
* @param groupType 账号类型
|
||||||
|
* @param rules 生成规则
|
||||||
|
* @return 生成的账号
|
||||||
|
*/
|
||||||
|
private String generateAdminAccount(String randomNum, Integer groupType, CeesGenerativeRules rules) {
|
||||||
|
char[] accountParts = new char[8]; // 账号长度为8
|
||||||
|
char[] randomDigits = randomNum.toCharArray();
|
||||||
|
|
||||||
|
// 填充随机数部分
|
||||||
|
int randomIndex = 0;
|
||||||
|
for (int i = 0; i < accountParts.length; i++) {
|
||||||
|
// 检查当前位置是否被规则占用(只需要处理groupType位置)
|
||||||
|
boolean isGroupTypePos = (i + 1) == rules.getGroupType();
|
||||||
|
|
||||||
|
if (isGroupTypePos) {
|
||||||
|
accountParts[i] = groupType.toString().charAt(0);
|
||||||
|
} else {
|
||||||
|
// 使用随机数填充
|
||||||
|
if (randomIndex < randomDigits.length) {
|
||||||
|
accountParts[i] = randomDigits[randomIndex++];
|
||||||
|
} else {
|
||||||
|
accountParts[i] = '0'; // 默认值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(accountParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建行政人员用户对象
|
||||||
|
* @param account 账号
|
||||||
|
* @param groupType 账号类型(1)
|
||||||
|
* @return 用户对象
|
||||||
|
*/
|
||||||
|
private CeesUser createAdminUser(String account, Integer groupType) {
|
||||||
|
CeesUser adminUser = new CeesUser();
|
||||||
|
adminUser.setUserId(account);
|
||||||
|
adminUser.setIdentity(groupType);
|
||||||
|
adminUser.setUserName(""); // 初始为空,后续由用户填写
|
||||||
|
adminUser.setMajorId(null); // 行政人员无学科类别
|
||||||
|
adminUser.setUserMajorId("A" + account); // 行政人员专业ID前缀为A
|
||||||
|
adminUser.setStatus(0); // 初始状态
|
||||||
|
adminUser.setWorkload(0); // 初始工作量为0
|
||||||
|
adminUser.setCreateTime(LocalDateTime.now());
|
||||||
|
adminUser.setUpdateTime(LocalDateTime.now());
|
||||||
|
return adminUser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue