dzx 1 рік тому
батько
коміт
6a9632eecb

+ 31 - 0
src/main/java/com/xjrsoft/common/utils/ImageUtil.java

@@ -1,5 +1,11 @@
 package com.xjrsoft.common.utils;
 
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.xjrsoft.common.exception.MyException;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.web.multipart.MultipartFile;
+
 import javax.imageio.ImageIO;
 import javax.imageio.stream.FileImageOutputStream;
 import java.awt.*;
@@ -14,6 +20,8 @@ import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
 
 public class ImageUtil {
     public static byte[] getByteByPic(String imageUrl) throws IOException {
@@ -107,4 +115,27 @@ public class ImageUtil {
                 .replace("data:image/png;base64,", "");
     }
 
+    // 图片处理
+    public static String ImageHandler(@NotNull MultipartFile file) throws IOException {
+        String filename = file.getOriginalFilename();
+        String suffix = StringUtils.substringAfterLast(filename, StringPool.DOT);
+        String[] imgSuffix = new String[]{"png", "jpg", "jpeg"};
+
+        if (!Arrays.asList(imgSuffix).contains(suffix)) {
+            throw new MyException("图片格式不正确!");
+        }
+        Map<String, String> map = new HashMap<String, String>() {
+            {
+                put("jpg", "data:image/jpg;base64,");
+                put("jpeg", "data:image/jpeg;base64,");
+                put("png", "data:image/png;base64,");
+            }
+        };
+
+        Long maxSize = 1048576L; // 最大文件1M
+        byte[] resultImg = ImageUtil.compressUnderSize(file.getBytes(), maxSize);
+
+        return map.get(suffix) + ImageUtil.bytesEncode2Base64(resultImg);
+    }
+
 }

+ 57 - 0
src/main/java/com/xjrsoft/module/base/entity/BaseUserStudent.java

@@ -0,0 +1,57 @@
+package com.xjrsoft.module.base.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 学生和家庭成员关系表
+ * </p>
+ *
+ */
+@Data
+@TableName("base_user_student")
+@ApiModel(value = "BaseUserStudent", description = "学生和家庭成员关系表")
+public class BaseUserStudent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("主键")
+    private Long id;
+
+    @ApiModelProperty("家长ID(xjr_user)")
+    private Long userId;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("修改时间")
+    private Date modifyDate;
+
+    @ApiModelProperty("家长手机号")
+    private String userPhone;
+
+    @ApiModelProperty("学生ID(xjr_user)")
+    private Long studentId;
+
+    @ApiModelProperty("学生姓名")
+    private String studentNane;
+
+    @ApiModelProperty("学生身份证号")
+    private String studentIdentity;
+
+    @ApiModelProperty("学生班级id(base_class)")
+    private Long classId;
+
+    @ApiModelProperty("学生班主任id(xjr_user)")
+    private Long teacher_id;
+
+    @ApiModelProperty("流程状态(0:审核中,1:通过,2:拒绝)")
+    private Integer status;
+
+}

+ 0 - 2
src/main/java/com/xjrsoft/module/liteflow/node/ImportStudentFaceNode.java

@@ -41,8 +41,6 @@ public class ImportStudentFaceNode extends NodeComponent {
             String result = FaceImportUtil.ImportStudentFace(hikvisionDataMapper.getStudentHikvisionId(dataObj.getUserId()), fileUrl);
             dataObj.setHikvisionResult(result);
             stundentFaceProcessService.updateById(dataObj);
-
-
         }
     }
 }

+ 10 - 25
src/main/java/com/xjrsoft/module/personnel/controller/FaceManagementController.java

@@ -93,11 +93,15 @@ public class FaceManagementController {
     @GetMapping(value = "/detail")
     @ApiOperation(value = "根据当前用户查询人脸信息")
     @SaCheckPermission("facemanager:detail")
-    public RT<FaceManagementVo> detail() {
+    public RT<FaceManagementVo> detail(@RequestParam Long id) {
+        Long userId = StpUtil.getLoginIdAsLong();
+        if(id != null){
+            userId = id;
+        }
         FaceManagement faceManagement = faceManagementService.getOneDeep(
                 MPJWrappers.<FaceManagement>lambdaJoin()
                 .eq(FaceManagement::getDeleteMark, DeleteMark.NODELETE.getCode())
-                .eq(FaceManagement::getUserId, StpUtil.getLoginIdAsLong())
+                .eq(FaceManagement::getUserId, userId)
         );
         if (faceManagement == null) {
             return RT.error("找不到此数据!");
@@ -154,7 +158,7 @@ public class FaceManagementController {
     public RT<Boolean> add(AddFaceManagementDto dto, @RequestParam("file") MultipartFile file) {
         FaceManagement faceManagement = BeanUtil.toBean(dto, FaceManagement.class);
         try {
-            faceManagement.setRegisterBase64(ImageHandler(file));
+            faceManagement.setRegisterBase64(ImageUtil.ImageHandler(file));
         } catch (Exception e) {
             return RT.error(e.getMessage());
         }
@@ -164,6 +168,8 @@ public class FaceManagementController {
 
     }
 
+
+
     @PostMapping(value = "/update")
     @ApiOperation(value = "修改人脸")
     @SaCheckPermission("facemanager:edit")
@@ -171,7 +177,7 @@ public class FaceManagementController {
         FaceManagement faceManagement = BeanUtil.toBean(dto, FaceManagement.class);
         if (file != null) {
             try {
-                faceManagement.setRegisterBase64(ImageHandler(file));
+                faceManagement.setRegisterBase64(ImageUtil.ImageHandler(file));
             } catch (Exception e) {
                 return RT.error(e.getMessage());
             }
@@ -202,26 +208,5 @@ public class FaceManagementController {
         return RT.ok(faceManagementService.remove(Wrappers.<FaceManagement>query().lambda().eq(FaceManagement::getUserId,StpUtil.getLoginIdAsLong())));
     }
 
-    // 图片处理
-    public String ImageHandler(@NotNull MultipartFile file) throws IOException {
-        String filename = file.getOriginalFilename();
-        String suffix = StringUtils.substringAfterLast(filename, StringPool.DOT);
-        String[] imgSuffix = new String[]{"png", "jpg", "jpeg"};
-
-        if (!Arrays.asList(imgSuffix).contains(suffix)) {
-            throw new MyException("图片格式不正确!");
-        }
-        Map<String, String> map = new HashMap<String, String>() {
-            {
-                put("jpg", "data:image/jpg;base64,");
-                put("jpeg", "data:image/jpeg;base64,");
-                put("png", "data:image/png;base64,");
-            }
-        };
 
-        Long maxSize = 1048576L; // 最大文件1M
-        byte[] resultImg = ImageUtil.compressUnderSize(file.getBytes(), maxSize);
-
-        return map.get(suffix) + ImageUtil.bytesEncode2Base64(resultImg);
-    }
 }

+ 13 - 4
src/main/java/com/xjrsoft/module/personnel/controller/StundentFaceProcessController.java

@@ -28,12 +28,12 @@ import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.base.vo.StudentClassVo;
 import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
+import com.xjrsoft.module.personnel.dto.AddFaceManagementDto;
 import com.xjrsoft.module.personnel.dto.AddStundentFaceProcessDto;
 import com.xjrsoft.module.personnel.dto.StundentFaceProcessPageDto;
 import com.xjrsoft.module.personnel.dto.UpdateStundentFaceProcessDto;
 import com.xjrsoft.module.personnel.entity.FaceManagement;
 import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
-import com.xjrsoft.module.personnel.entity.TeacherFaceProcess;
 import com.xjrsoft.module.personnel.service.IFaceManagementService;
 import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
 import com.xjrsoft.module.personnel.vo.StundentFaceProcessPageVo;
@@ -94,6 +94,8 @@ public class StundentFaceProcessController {
     private final IFaceManagementService faceManagementService;
     private final IBaseClassService classService;
     private final HikvisionDataMapper hikvisionDataMapper;
+
+
     @GetMapping(value = "/page")
     @ApiOperation(value="学生人脸信息审核列表(分页)")
     @SaCheckPermission("stundentfaceprocess:detail")
@@ -189,9 +191,6 @@ public class StundentFaceProcessController {
     @ApiOperation(value = "批量新增学生人脸")
     @SaCheckPermission("stundentfaceprocess:batch-upload")
     public RT<Boolean> batchUpload(@RequestParam("file") MultipartFile file) throws Exception {
-
-
-
         List<BaseStudentUser> list = studentManagerService.list(
             new MPJLambdaWrapper<BaseStudentUser>().distinct()
             .select(BaseStudentUser::getId)
@@ -420,4 +419,14 @@ public class StundentFaceProcessController {
         return RT.ok(true);
     }
 
+
+    @PostMapping(value = "/ns-upload-face")
+    @ApiOperation(value = "新生账号激活上传人脸信息")
+    @SaCheckPermission("stundentfaceprocess:add")
+    public RT<Boolean> nsUploadFace(AddFaceManagementDto dto, @RequestParam("file") MultipartFile file) {
+        Boolean isSuccess = stundentFaceProcessService.nsUploadFace(dto, file);
+        return RT.ok(isSuccess);
+
+    }
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/personnel/service/IStundentFaceProcessService.java

@@ -1,7 +1,9 @@
 package com.xjrsoft.module.personnel.service;
 
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.personnel.dto.AddFaceManagementDto;
 import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -15,4 +17,6 @@ import java.util.List;
 public interface IStundentFaceProcessService extends MPJBaseService<StundentFaceProcess> {
 
     Boolean removeByIds(List<Long> ids);
+
+    Boolean nsUploadFace(AddFaceManagementDto dto, MultipartFile file);
 }

+ 59 - 1
src/main/java/com/xjrsoft/module/personnel/service/impl/StundentFaceProcessServiceImpl.java

@@ -1,21 +1,34 @@
 package com.xjrsoft.module.personnel.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.ImageUtil;
 import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
+import com.xjrsoft.module.hikvision.util.FaceImportUtil;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.personnel.dto.AddFaceManagementDto;
 import com.xjrsoft.module.personnel.entity.FaceManagement;
 import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
 import com.xjrsoft.module.personnel.mapper.StundentFaceProcessMapper;
 import com.xjrsoft.module.personnel.service.IFaceManagementService;
 import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
+import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.vo.BaseStudentSompleInfoVo;
+import com.xjrsoft.module.system.entity.File;
+import com.xjrsoft.module.system.service.IFileService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.Date;
 import java.util.List;
@@ -33,7 +46,9 @@ public class StundentFaceProcessServiceImpl extends MPJBaseServiceImpl<StundentF
     private final HikvisionDataMapper hikvisionDataMapper;
 
     private final IFaceManagementService faceManagementService;
-
+    private final IUserService userService;
+    private final IBaseStudentSchoolRollService rollService;
+    private final IFileService fileService;
 
     //删除人脸后,移除海康那边的人脸
     @Override
@@ -88,4 +103,47 @@ public class StundentFaceProcessServiceImpl extends MPJBaseServiceImpl<StundentF
         }
         return true;
     }
+
+    @Override
+    public Boolean nsUploadFace(AddFaceManagementDto dto, MultipartFile file) {
+        //新增人脸管理数据
+        FaceManagement faceManagement = BeanUtil.toBean(dto, FaceManagement.class);
+        try {
+            faceManagement.setRegisterBase64(ImageUtil.ImageHandler(file));
+        } catch (Exception e) {
+            throw new MyException(e.getMessage());
+        }
+        boolean isSuccess = faceManagementService.add(faceManagement);
+
+        User user = userService.getById(dto.getUserId());
+
+        List<BaseStudentSompleInfoVo> infosByParam = rollService.getInfosByParam(new BaseStudentSimpleInfoDto() {{
+            setUserId(user.getId());
+        }});
+        BaseStudentSompleInfoVo infoVo = new BaseStudentSompleInfoVo();
+        if(!infosByParam.isEmpty()){
+            infoVo = infosByParam.get(0);
+        }
+        //新生学生人俩流程数据
+        StundentFaceProcess studentFace = new StundentFaceProcess();
+        studentFace.setFacePhoto(dto.getFileId());
+        studentFace.setName(dto.getName());
+        studentFace.setStatus(1);
+        studentFace.setUserId(dto.getUserId());
+        studentFace.setIdentityCard(user.getCredentialNumber());
+        studentFace.setGender(user.getGender());
+        studentFace.setClassId(infoVo.getClassId());
+        studentFace.setTeacherId(infoVo.getTeahcerId());
+
+        File xjrFile = fileService.getOne(
+                new QueryWrapper<File>().lambda().eq(File::getFolderId, dto.getFileId())
+        );
+
+
+        String result = FaceImportUtil.ImportStudentFace(hikvisionDataMapper.getStudentHikvisionId(user.getId()), xjrFile.getFileUrl());
+        studentFace.setHikvisionResult(result);
+
+        this.save(studentFace);
+        return true;
+    }
 }

+ 51 - 3
src/main/java/com/xjrsoft/module/student/controller/BaseNewStudentController.java

@@ -4,14 +4,21 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.enums.EnabledMark;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.common.utils.RedisUtil;
+import com.xjrsoft.module.base.entity.BaseUserStudent;
 import com.xjrsoft.module.base.entity.WhitelistManagement;
 import com.xjrsoft.module.base.service.IWhitelistManagementService;
 import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserDeptRelation;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.ActiveAccountDto;
 import com.xjrsoft.module.student.dto.AddBaseNewStudentDto;
@@ -48,6 +55,7 @@ import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
 * @title: 新生维护信息
@@ -65,7 +73,8 @@ public class BaseNewStudentController {
     private final IBaseNewStudentService baseNewStudentService;
     private final IBaseStudentFamilyMemberService familyMemberService;
     private final IWhitelistManagementService whitelistManagementService;
-
+    private final IUserRoleRelationService userRoleRelationService;
+    private final RedisUtil redisUtil;
     @GetMapping(value = "/page")
     @ApiOperation(value="新生维护信息列表(分页)")
     @SaCheckPermission("basenewstudent:detail")
@@ -212,18 +221,47 @@ public class BaseNewStudentController {
                         .eq(BaseStudentFamilyMember::getUserId, dto.getId())
                         .eq(BaseStudentFamilyMember::getMobile, dto.getParentMobile())
         );
-
+        BaseStudentFamilyMember member;
         if(list.isEmpty()){
-            BaseStudentFamilyMember member = new BaseStudentFamilyMember();
+            member = new BaseStudentFamilyMember();
             member.setUserId(user.getId());
             member.setName(dto.getParentName());
             member.setMobile(dto.getParentMobile());
             member.setCreateDate(LocalDateTime.now());
             member.setCreateUserId(StpUtil.getLoginIdAsLong());
             familyMemberService.save(member);
+        }else{
+            member = list.get(0);
         }
+        List<User> parents = userService.list(
+                new QueryWrapper<User>().lambda()
+                        .eq(User::getUserName, dto.getParentMobile())
+                        .eq(User::getName, dto.getParentName())
+        );
+        if(parents.isEmpty()){
+            User parentUser = new User() {{
+                setUserName(dto.getParentMobile());
+                setName(dto.getParentName());
+                setIsChangePassword(1);
+                setDeleteMark(0);
+                setEnabledMark(1);
+                setMobile(dto.getMobile());
+            }};
+            userService.save(parentUser);
 
+            userRoleRelationService.save(new UserRoleRelation(){{
+                setUserId(parentUser.getId());
+                setRoleId(4L);
+            }});
 
+            BaseUserStudent userStudent = new BaseUserStudent();
+            userStudent.setStudentId(user.getId());
+            userStudent.setStudentNane(user.getName());
+            userStudent.setStudentIdentity(user.getCredentialNumber());
+            userStudent.setCreateDate(new Date());
+            userStudent.setUserId(parentUser.getId());
+            familyMemberService.save(member);
+        }
 
         //新增白名单信息
         List<WhitelistManagement> managementList = whitelistManagementService.list(
@@ -241,6 +279,16 @@ public class BaseNewStudentController {
             whitelistManagementService.save(whitelistManagement);
         }
 
+        CompletableFuture.runAsync(() -> {
+            List<User> userList = userService.list();
+            redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
+
+            List<UserRoleRelation> userRoleRelationList = userRoleRelationService.list(Wrappers.lambdaQuery(UserRoleRelation.class));
+            redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
+
+            whitelistManagementService.loadCaches();
+        });
+
         return RT.ok(true);
     }
 

+ 3 - 0
src/main/java/com/xjrsoft/module/student/dto/BaseStudentSimpleInfoDto.java

@@ -12,4 +12,7 @@ public class BaseStudentSimpleInfoDto {
 
     @ApiModelProperty("关键字")
     private String keyword;
+
+    @ApiModelProperty("用户id")
+    private Long userId;
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/student/entity/BaseNewStudent.java

@@ -134,12 +134,12 @@ public class BaseNewStudent implements Serializable {
     * 第一志愿
     */
     @ApiModelProperty("第一志愿")
-    private String firstAmbition;
+    private Long firstAmbition;
     /**
     * 第二志愿
     */
     @ApiModelProperty("第二志愿")
-    private String secondAmbition;
+    private Long secondAmbition;
     /**
     * 班级状态(0:未分配, 1:已分配)
     */

+ 4 - 4
src/main/java/com/xjrsoft/module/student/service/impl/BaseNewStudentServiceImpl.java

@@ -142,9 +142,9 @@ public class BaseNewStudentServiceImpl extends MPJBaseServiceImpl<BaseNewStudent
                 student.setSource(dictMap.get(objectMap.get(7).toString()));
                 student.setStduyStatus(dictMap.get(objectMap.get(8).toString()));
                 student.setMobile(objectMap.get(9).toString());
-                student.setFirstAmbition(majorSetMap.get(objectMap.get(10).toString()).toString());
+                student.setFirstAmbition(majorSetMap.get(objectMap.get(10).toString()));
                 student.setFirstAmbitionId(majorSetMap.get(objectMap.get(10).toString()));
-                student.setSecondAmbition(majorSetMap.get(objectMap.get(11).toString()).toString());
+                student.setSecondAmbition(majorSetMap.get(objectMap.get(11).toString()));
                 student.setSecondAmbitionId(majorSetMap.get(objectMap.get(11).toString()));
                 student.setIsAdjust(YesOrNoEnum.getCode(objectMap.get(12).toString()));
                 if(objectMap.get(13) != null){
@@ -174,9 +174,9 @@ public class BaseNewStudentServiceImpl extends MPJBaseServiceImpl<BaseNewStudent
                     setSource(dictMap.get(objectMap.get(7).toString()));
                     setStduyStatus(dictMap.get(objectMap.get(8).toString()));
                     setMobile(objectMap.get(9).toString());
-                    setFirstAmbition(majorSetMap.get(objectMap.get(10).toString()).toString());
+                    setFirstAmbition(majorSetMap.get(objectMap.get(10).toString()));
                     setFirstAmbitionId(majorSetMap.get(objectMap.get(10).toString()));
-                    setSecondAmbition(majorSetMap.get(objectMap.get(11).toString()).toString());
+                    setSecondAmbition(majorSetMap.get(objectMap.get(11).toString()));
                     setSecondAmbitionId(majorSetMap.get(objectMap.get(11).toString()));
                     setIsAdjust(YesOrNoEnum.getCode(objectMap.get(12).toString()));
                     if(objectMap.get(13) != null){

+ 14 - 0
src/main/java/com/xjrsoft/module/student/vo/BaseStudentSompleInfoVo.java

@@ -43,4 +43,18 @@ public class BaseStudentSompleInfoVo {
     @ApiModelProperty("班级名称")
     private String className;
 
+    @ApiModelProperty("家长名称")
+    private String parentName;
+
+    @ApiModelProperty("家长电话")
+    private String parentMobile;
+
+    @ApiModelProperty("性别")
+    private String gender;
+
+    @ApiModelProperty("班级id")
+    private Long classId;
+
+    @ApiModelProperty("班主任id")
+    private Long teahcerId;
 }

+ 12 - 2
src/main/resources/mapper/organization/UserMapper.xml

@@ -16,10 +16,20 @@
         </if>
     </select>
     <select id="getInfosByParam" parameterType="com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto" resultType="com.xjrsoft.module.student.vo.BaseStudentSompleInfoVo">
-        SELECT t1.id, t1.name as student_name, t1.enabled_mark, t1.credential_number, t4.name AS class_name FROM xjr_user t1
+        SELECT t1.id, t1.name as student_name, t1.enabled_mark, t1.credential_number, t4.name AS class_name,
+        (SELECT name FROM base_student_family_member WHERE delete_mark = 0 AND user_id = t1.id ORDER BY create_date ASC LIMIT 0,1) as parent_name,
+        (SELECT mobile FROM base_student_family_member WHERE delete_mark = 0 AND user_id = t1.id ORDER BY create_date ASC LIMIT 0,1) as parent_mobile,
+        t1.gender,t4.id as class_id, t4.teacher_id
+        FROM xjr_user t1
         INNER JOIN base_student t2 ON t1.id = t2.user_id
         INNER JOIN base_student_school_roll t3 ON t1.id = t3.user_id
         INNER JOIN base_class t4 ON t4.id = t3.class_id
-        WHERE t1.delete_mark = 0 AND (t1.name = #{dto.keyword} OR t1.credential_number = #{dto.keyword})
+        WHERE t1.delete_mark = 0
+        <if test="dto.keyword != null and dto.keyword != ''">
+            AND (t1.name = #{dto.keyword} OR t1.credential_number = #{dto.keyword})
+        </if>
+        <if test="dto.userId != null">
+            AND t1.id = #{dto.userId}
+        </if>
     </select>
 </mapper>