소스 검색

Merge branch 'master' of http://49.234.186.218:9000/root/ieplus

mingfu 1 개월 전
부모
커밋
35f078f1e8

+ 4 - 1
back-ui/src/views/dz/cards/components/AssignDialog.vue

@@ -129,8 +129,11 @@ const emit = defineEmits(['refresh'])
 const handleConfirm = () => {
   formRef.value.validate(async (valid) => {
     if (valid) {
-      const { cardType, agentId, begin, end, location, assignExamType, schoolId, days } = form.value;
+      let { cardType, agentId, begin, end, location, assignExamType, schoolId, days } = form.value;
       modalRef.value.showLoading()
+      if (cardType !== '9') {
+        days = undefined;
+      }
       assignCard(cardType, agentId, begin, end, location, assignExamType, schoolId, days).then(res => {
         proxy.$modal.msgSuccess('分配卡成功')
         close();

+ 26 - 4
back-ui/src/views/dz/teacher/index.vue

@@ -70,7 +70,7 @@
           v-hasPermi="['dz:teacher:add']"
         >新增</el-button>
       </el-col>
-      <el-col :span="1.5">
+      <!-- <el-col :span="1.5">
         <el-button
           type="success"
           plain
@@ -78,7 +78,7 @@
           :disabled="single"
           @click="handleUpdate"
           v-hasPermi="['dz:teacher:edit']"
-        >修改</el-button>
+        >修改</el-button> -->
       </el-col>
       <!-- <el-col :span="1.5">
         <el-button
@@ -155,7 +155,7 @@
           <el-input v-model="form.name" placeholder="请输入教师姓名" />
         </el-form-item>
         <el-form-item label="所在学校" prop="schoolId">
-          <el-select v-model="form.schoolId" placeholder="请选择所在学校" style="width: 100%" filterable clearable @change="handleSchoolChange">
+          <el-select v-model="form.schoolId" placeholder="请选择所在学校" style="width: 100%" filterable clearable :disabled="!form.teacherId && !!form.campusId" @change="handleSchoolChange">
             <el-option
                     v-for="item in schoolOptions"
                     :key="item.id"
@@ -175,7 +175,7 @@
           </el-select>
         </el-form-item>
         <el-form-item label="培训校区" prop="campusId">
-          <el-select v-model="form.campusId" placeholder="请选择培训校区" style="width: 100%" filterable clearable @change="handleCampusChange">
+          <el-select v-model="form.campusId" placeholder="请选择培训校区" style="width: 100%" filterable clearable :disabled="!form.teacherId && !!form.schoolId" @change="handleCampusChange">
             <el-option
                     v-for="item in campusOptions"
                     :key="item.id"
@@ -538,6 +538,17 @@ function handleUpdate(row) {
 
 /** 学校变化处理 */
 function handleSchoolChange() {
+  // 如果选择了学校,清空校区
+  if (form.value.schoolId) {
+    form.value.campusId = null
+    form.value.campusClassIds = []
+    campusClassOptions.value = []
+  } else {
+    // 如果清空了学校,清空学校班级
+    form.value.schoolClassIds = []
+    schoolClassOptions.value = []
+    return
+  }
   // 如果是编辑模式,不清空已选班级,只更新选项列表
   if (!form.value.teacherId) {
     form.value.schoolClassIds = []
@@ -556,6 +567,17 @@ function handleSchoolChange() {
 
 /** 校区变化处理 */
 function handleCampusChange() {
+  // 如果选择了校区,清空学校
+  if (form.value.campusId) {
+    form.value.schoolId = null
+    form.value.schoolClassIds = []
+    schoolClassOptions.value = []
+  } else {
+    // 如果清空了校区,清空校区班级
+    form.value.campusClassIds = []
+    campusClassOptions.value = []
+    return
+  }
   // 如果是编辑模式,不清空已选班级,只更新选项列表
   if (!form.value.teacherId) {
     form.value.campusClassIds = []

+ 2 - 2
back-ui/src/views/system/user/indexCard.vue

@@ -36,11 +36,11 @@
                   <el-option v-for="dict in exam_type" :key="dict.value" :label="dict.label" :value="dict.value" />
                 </el-select>
               </el-form-item>
-              <el-form-item label="用户类型" prop="usercardType">
+              <!-- <el-form-item label="用户类型" prop="usercardType">
                 <el-select v-model="queryParams.usercardType" placeholder="请选择用户类型" clearable style="width: 240px">
                   <el-option v-for="dict in usercard_type" :key="dict.value" :label="dict.label" :value="dict.value" />
                 </el-select>
-              </el-form-item>
+              </el-form-item> -->
               <el-form-item label="邀请机构" prop="inviteDeptId">
                 <IeInstitutionSelect v-model="queryParams.inviteDeptId" placeholder="请选择邀请机构" clearable style="width: 240px" />
               </el-form-item>

+ 55 - 2
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzTeacherController.java

@@ -36,6 +36,7 @@ import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.dz.service.IDzTeacherService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.page.TableDataInfo;
+import javax.validation.ValidationException;
 
 /**
  * 老师Controller
@@ -131,7 +132,7 @@ public class DzTeacherController extends BaseController
     {
         Long teacherId = dzTeacherService.insertDzTeacher(dzTeacher);
 
-        processTeacherClass(dzTeacher);
+        processTeacherClass2(dzTeacher);
 
         return AjaxResult.success(teacherId);
     }
@@ -167,7 +168,59 @@ public class DzTeacherController extends BaseController
         }
     }
 
+    /**
+     * 处理教师班级关系(先删除所有,再重新插入)
+     * 删除该老师下面所有的班级后,重新插入页面上填写的内容
+     */
+    private void processTeacherClass2(DzTeacher dzTeacher) {
+        // 1. 验证:学校班级和校区班级不能同时有值
+        boolean hasSchoolClasses = dzTeacher.getSchoolId()!=null || (dzTeacher.getSchoolClassIds() != null && dzTeacher.getSchoolClassIds().length > 0);
+        boolean hasCampusClasses = dzTeacher.getCampusClass()!=null || (dzTeacher.getCampusClassIds() != null && dzTeacher.getCampusClassIds().length > 0);
+        if (hasSchoolClasses && hasCampusClasses) {
+            throw new ValidationException("学校和培训校区只能二选一,不能同时选择学校班级和校区班级");
+        }
 
+        Long teacherId = dzTeacher.getTeacherId();
+        if (teacherId != null) {
+            // 2. 查询该老师的所有班级关系
+            DzTeacherClass queryCondition = new DzTeacherClass();
+            queryCondition.setTeacherId(teacherId);
+            List<DzTeacherClass> existingList = dzTeacherClassService.selectDzTeacherClassList(queryCondition);
+            
+            // 3. 删除该老师的所有班级关系
+            if (CollectionUtils.isNotEmpty(existingList)) {
+                String[] ids = existingList.stream()
+                        .map(DzTeacherClass::getId)
+                        .filter(id -> id != null)
+                        .map(String::valueOf)
+                        .toArray(String[]::new);
+                if (ids.length > 0) {
+                    dzTeacherClassService.deleteDzTeacherClassByIds(ids);
+                }
+            }
+            
+            // 4. 合并学校班级和校区班级ID(只能有一个有值)
+            List<Long> allClassIds = new java.util.ArrayList<>();
+            Long schoolId = null;
+            if (dzTeacher.getSchoolClassIds()!=null&&dzTeacher.getSchoolClassIds().length > 0) {
+                schoolId = dzTeacher.getSchoolId();
+                allClassIds.addAll(Arrays.asList(dzTeacher.getSchoolClassIds()));
+            } else if (dzTeacher.getCampusClassIds()!=null && dzTeacher.getCampusClassIds().length > 0) {
+                schoolId = dzTeacher.getCampusId();
+                allClassIds.addAll(Arrays.asList(dzTeacher.getCampusClassIds()));
+            }
+            
+            // 5. 重新插入页面上填写的内容
+            if (!allClassIds.isEmpty()) {
+                DzTeacherClass dzTeacherClass = new DzTeacherClass();
+                dzTeacherClass.setTeacherId(teacherId);
+                dzTeacherClass.setClassIds(allClassIds.toArray(new Long[0]));
+                // 如果选择的是校区班级,使用campusId作为schoolId;否则使用schoolId
+                dzTeacherClass.setSchoolId(schoolId);
+                dzTeacherClassService.batchBindTeacherClass(dzTeacherClass);
+            }
+        }
+    }
 
     /**
      * 修改老师
@@ -179,7 +232,7 @@ public class DzTeacherController extends BaseController
     {
         dzTeacherService.updateDzTeacher(dzTeacher);
         //处理班级关联
-        processTeacherClass(dzTeacher);
+        processTeacherClass2(dzTeacher);
         //同时修改sys_user表的nickName
         SysUser user = userService.selectUserByUserName(String.valueOf(dzTeacher.getTeacherId()));
         if (null != user) {

+ 23 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java

@@ -109,6 +109,29 @@ public class SysProfileController extends BaseController
         LoginUser loginUser = getLoginUser();
         Long userId = loginUser.getUserId();
         String password = loginUser.getPassword();
+        
+        // 如果缓存中的密码为空,从数据库重新查询用户信息获取密码
+        if (StringUtils.isEmpty(password))
+        {
+            SysUser dbUser = userService.selectUserById(userId);
+            if (dbUser == null)
+            {
+                return error("用户不存在");
+            }
+            password = dbUser.getPassword();
+            // 更新缓存中的用户密码信息
+            if (loginUser.getUser() != null)
+            {
+                loginUser.getUser().setPassword(password);
+            }
+        }
+        
+        // 验证旧密码是否为空
+        if (StringUtils.isEmpty(password))
+        {
+            return error("修改密码失败,无法获取用户密码信息");
+        }
+        
         if (!SecurityUtils.matchesPassword(oldPassword, password))
         {
             return error("修改密码失败,旧密码错误");

+ 1 - 1
ie-system/src/main/java/com/ruoyi/dz/service/impl/DzTeacherServiceImpl.java

@@ -63,7 +63,7 @@ public class DzTeacherServiceImpl implements IDzTeacherService
                             (existing, replacement) -> existing  // 如果key重复,保留已存在的
                     ));
             for (DzTeacher teacher : list) {
-                if (schoolMap.containsKey(teacher.getCampusId())){
+                if (teacher.getCampusId()!=null && schoolMap.containsKey(teacher.getCampusId())){
                     teacher.setCampusName(schoolMap.get(teacher.getCampusId()).getName());
                 }
             }

+ 2 - 2
ie-system/src/main/resources/mapper/dz/DzTeacherMapper.xml

@@ -68,8 +68,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id = #{userId},</if>
             <if test="deptId != null">dept_id = #{deptId},</if>
             <if test="agentId != null">agent_id = #{agentId},</if>
-            <if test="schoolId != null">school_id = #{schoolId},</if>
-            <if test="campusId != null">campus_id = #{campusId},</if>
+            school_id = #{schoolId},
+            campus_id = #{campusId},
             <if test="name != null">name = #{name},</if>
         </trim>
         where teacher_id = #{teacherId}

+ 4 - 2
ie-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -170,8 +170,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</if>
 		<if test="agentId != null and agentId != ''"> and (c.agent_id = #{agentId} or c.leaf_agent_id = #{agentId} or a.agent_id = #{agentId} OR a.agent_id IN ( SELECT t.agent_id FROM dz_agent t WHERE t.parent_id = #{agentId}))</if>
 		<if test="deptId != null and deptId != 0">
-			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) )
-			<if test="inviteDeptId != null and inviteDeptId != 0"> OR a.dept_id = #{inviteDeptId}</if>)
+			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
+		</if>
+		<if test="inviteDeptId != null and inviteDeptId != 0">
+			AND a.dept_id = #{inviteDeptId}
 		</if>
 		<if test="userType != null and userType != ''">
 			AND u.user_type = #{userType}