3 次代码提交 73ca3b7d0f ... 5ccea6e1c1

作者 SHA1 备注 提交日期
  sakura 5ccea6e1c1 feat:恢复客户端家长登入需要手机号验证码 1 年之前
  sakura a9a4ccff1f feat:完成客户端家长登入后查看绑定学生的详情 1 年之前
  sakura 1cfedeee16 feat:完成客户端家长登入后获取绑定的学生列表 1 年之前

+ 40 - 0
school-in-out-admin/src/main/java/com/schoolinout/web/controller/api/Api_StudentController.java

@@ -0,0 +1,40 @@
+package com.schoolinout.web.controller.api;
+
+import com.schoolinout.api.service.IApiStudentService;
+import com.schoolinout.common.core.controller.BaseController;
+import com.schoolinout.common.core.domain.AjaxResult;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author sakura
+ * @date 2024/1/11 14:14:15 Thu
+ */
+@Tag(name = "用户端-学生接口")
+@RestController
+@RequestMapping("/app/student")
+public class Api_StudentController extends BaseController {
+
+    @Autowired
+    private IApiStudentService studentService;
+
+    @Operation(summary = "获取绑定学生列表")
+    @GetMapping("/list")
+    public AjaxResult list() {
+        Long parentId = getLoginUser().getParentLogin().getId();
+        return success(studentService.listStudent(parentId));
+    }
+
+    @Operation(summary = "获取绑定学生详情")
+    @GetMapping("/info/{studentId}")
+    public AjaxResult getEditInfo(@PathVariable Long studentId) {
+        Long parentId = getLoginUser().getParentLogin().getId();
+        return success(studentService.listStudentEditInfo(parentId, studentId));
+    }
+
+}

+ 95 - 0
school-in-out-system/src/main/java/com/schoolinout/api/domain/vo/Api_StudentInfoVo.java

@@ -0,0 +1,95 @@
+package com.schoolinout.api.domain.vo;
+
+import com.schoolinout.system.domain.AccessLog;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+import java.util.List;
+
+/**
+ * @author sakura
+ * @date 2024/1/11 15:15:49 Thu
+ */
+@Schema(name = "客户端学生信息详情实体")
+public class Api_StudentInfoVo {
+
+    @Schema(description = "学生id")
+    private Long studentId;
+    @Schema(description = "学生性别")
+    private String studentGender;
+    @Schema(description = "学生姓名")
+    private String studentName;
+    @Schema(description = "学生学号")
+    private String studentNum;
+    @Schema(description = "学生照片")
+    private String studentPic;
+    @Schema(description = "学校姓名")
+    private String schoolName;
+    @Schema(description = "班级姓名")
+    private String className;
+    @Schema(description = "进出学校记录")
+    private List<AccessLog> inoutRecordList;
+
+    public Long getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Long studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getStudentGender() {
+        return studentGender;
+    }
+
+    public void setStudentGender(String studentGender) {
+        this.studentGender = studentGender;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getStudentNum() {
+        return studentNum;
+    }
+
+    public void setStudentNum(String studentNum) {
+        this.studentNum = studentNum;
+    }
+
+    public String getStudentPic() {
+        return studentPic;
+    }
+
+    public void setStudentPic(String studentPic) {
+        this.studentPic = studentPic;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    public List<AccessLog> getInoutRecordList() {
+        return inoutRecordList;
+    }
+
+    public void setInoutRecordList(List<AccessLog> inoutRecordList) {
+        this.inoutRecordList = inoutRecordList;
+    }
+}

+ 103 - 0
school-in-out-system/src/main/java/com/schoolinout/api/domain/vo/Api_StudentListVo.java

@@ -0,0 +1,103 @@
+package com.schoolinout.api.domain.vo;
+
+/**
+ * @author sakura
+ * @date 2024/1/11 15:15:06 Thu
+ */
+public class Api_StudentListVo {
+
+    private Long studentId;
+    private Long parentId;
+    private Long schoolId;
+    private Long classId;
+
+    private String studentGender;
+    private String studentName;
+    private String studentNum;
+    private String studentPic;
+
+
+    private String schoolName;
+    private String className;
+
+    public String getStudentGender() {
+        return studentGender;
+    }
+
+    public void setStudentGender(String studentGender) {
+        this.studentGender = studentGender;
+    }
+
+    public Long getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Long studentId) {
+        this.studentId = studentId;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public Long getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public Long getClassId() {
+        return classId;
+    }
+
+    public void setClassId(Long classId) {
+        this.classId = classId;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getStudentNum() {
+        return studentNum;
+    }
+
+    public void setStudentNum(String studentNum) {
+        this.studentNum = studentNum;
+    }
+
+    public String getStudentPic() {
+        return studentPic;
+    }
+
+    public void setStudentPic(String studentPic) {
+        this.studentPic = studentPic;
+    }
+
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+}

+ 7 - 0
school-in-out-system/src/main/java/com/schoolinout/api/mapper/ApiStudentMapper.java

@@ -1,9 +1,12 @@
 package com.schoolinout.api.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.schoolinout.api.domain.vo.Api_StudentListVo;
 import com.schoolinout.system.domain.Student;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * @author sakura
  * @date 2024/1/10 10:10:11 Wed
@@ -11,4 +14,8 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface ApiStudentMapper extends BaseMapper<Student> {
     Student selectOnlyOne(Student student);
+
+    List<Api_StudentListVo> selectListByParentId(Long parentId);
+
+    Student selectEditInfo(Long studentId);
 }

+ 20 - 0
school-in-out-system/src/main/java/com/schoolinout/api/service/IApiStudentService.java

@@ -1,13 +1,26 @@
 package com.schoolinout.api.service;
 
+import com.schoolinout.api.domain.vo.Api_StudentInfoVo;
+import com.schoolinout.api.domain.vo.Api_StudentListVo;
 import com.schoolinout.system.domain.Student;
 
+import java.util.List;
+
 /**
  * @author sakura
  * @date 2024/1/10 10:10:05 Wed
  */
 public interface IApiStudentService {
     /**
+     * 获取绑定学生详情
+     *
+     * @param parentId  家长id
+     * @param studentId 学生id
+     * @return 结果
+     */
+    public Api_StudentInfoVo listStudentEditInfo(Long parentId, Long studentId);
+
+    /**
      * 查询单个用户
      *
      * @param selectConditionStu 查询条件
@@ -15,4 +28,11 @@ public interface IApiStudentService {
      */
     public Student listStudentSimple(Student selectConditionStu);
 
+    /**
+     * 根据当前登入家长的id 去查询绑定的学生列表
+     *
+     * @param parentId 家长id
+     * @return 结果
+     */
+    public List<Api_StudentListVo> listStudent(Long parentId);
 }

+ 37 - 0
school-in-out-system/src/main/java/com/schoolinout/api/service/impl/ApiStudentServiceImpl.java

@@ -1,11 +1,19 @@
 package com.schoolinout.api.service.impl;
 
+import com.schoolinout.api.domain.vo.Api_StudentInfoVo;
+import com.schoolinout.api.domain.vo.Api_StudentListVo;
 import com.schoolinout.api.mapper.ApiStudentMapper;
 import com.schoolinout.api.service.IApiStudentService;
+import com.schoolinout.common.exception.ServiceException;
+import com.schoolinout.common.utils.bean.BeanUtils;
+import com.schoolinout.system.domain.AccessLog;
 import com.schoolinout.system.domain.Student;
+import com.schoolinout.system.mapper.AccessLogMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author sakura
  * @date 2024/1/10 10:10:06 Wed
@@ -15,9 +23,38 @@ public class ApiStudentServiceImpl implements IApiStudentService {
 
     @Autowired
     private ApiStudentMapper studentMapper;
+    @Autowired
+    private AccessLogMapper accessLogMapper;
+
+
+    @Override
+    public Api_StudentInfoVo listStudentEditInfo(Long parentId, Long studentId) {
+        Student student = studentMapper.selectEditInfo(studentId);
+        if (student == null) {
+            throw new ServiceException("没有对应的学生");
+        }
+
+        Api_StudentInfoVo infoVo = new Api_StudentInfoVo();
+        BeanUtils.copyBeanProp(infoVo, student);
+        infoVo.setStudentId(student.getId());
+
+        // 读取进出记录
+        AccessLog accessLog = new AccessLog();
+        accessLog.setStudentId(studentId);
+        List<AccessLog> accessLogs = accessLogMapper.selectAccessLogList(accessLog);
+        infoVo.setInoutRecordList(accessLogs);
+        return infoVo;
+    }
 
     @Override
     public Student listStudentSimple(Student selectConditionStu) {
         return studentMapper.selectOnlyOne(selectConditionStu);
     }
+
+    @Override
+    public List<Api_StudentListVo> listStudent(Long parentId) {
+        return studentMapper.selectListByParentId(parentId);
+    }
+
+
 }

+ 10 - 0
school-in-out-system/src/main/java/com/schoolinout/system/domain/ParentStudent.java

@@ -8,6 +8,8 @@ public class ParentStudent {
     private Long studentId;
     private Long parentId;
 
+    private String relation;
+
     public ParentStudent() {
     }
 
@@ -31,4 +33,12 @@ public class ParentStudent {
     public void setParentId(Long parentId) {
         this.parentId = parentId;
     }
+
+    public String getRelation() {
+        return relation;
+    }
+
+    public void setRelation(String relation) {
+        this.relation = relation;
+    }
 }

+ 0 - 1
school-in-out-system/src/main/java/com/schoolinout/system/domain/dto/ParentDto.java

@@ -40,7 +40,6 @@ public class ParentDto {
      * 与学生的关系
      */
     @Schema(description = "与学生的关系")
-    @NotBlank(message = "关系不能为空")
     private String relation;
 
     public Long getId() {

+ 30 - 0
school-in-out-system/src/main/resources/mapper/api/ApiStudentMapper.xml

@@ -23,4 +23,34 @@
             </if>
         </where>
     </select>
+    <select id="selectListByParentId" resultType="com.schoolinout.api.domain.vo.Api_StudentListVo">
+        SELECT stu.id as student_id,
+               stu.school_id,
+               stu.class_id,
+               stu.student_name,
+               stu.student_num,
+               stu.student_pic,
+               stu.student_gender,
+               school.school_name,
+               class.class_name
+        FROM tb_school_student stu
+                 LEFT JOIN tb_school_student_parent_relation tsspr
+                           on stu.id = tsspr.student_id AND tsspr.parent_id = #{studentId}
+                 LEFT JOIN tb_school school ON stu.school_id = school.id
+                 LEFT JOIN tb_school_class class ON stu.class_id = class.id
+    </select>
+    <select id="selectEditInfo" resultType="com.schoolinout.system.domain.Student">
+        SELECT stu.id as student_id,
+               stu.student_name,
+               stu.student_num,
+               stu.student_pic,
+               stu.student_gender,
+               school.school_name,
+               class.class_name
+        FROM tb_school_student stu
+                 LEFT JOIN tb_school_student_parent_relation tsspr on stu.id = tsspr.student_id
+                 LEFT JOIN tb_school school ON stu.school_id = school.id
+                 LEFT JOIN tb_school_class class ON stu.class_id = class.id
+        where stu.id = #{id}
+    </select>
 </mapper>

+ 10 - 10
school-in-out-ui/src/views/system/parent/index.vue

@@ -17,7 +17,7 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="关系" prop="relation">
+      <!-- <el-form-item label="关系" prop="relation">
         <el-select v-model="queryParams.relation" placeholder="请选择与学生的关系" clearable>
           <el-option
             v-for="dict in dict.type.parent_relation"
@@ -26,7 +26,7 @@
             :value="dict.value"
           />
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -92,11 +92,11 @@
       </el-table-column>
       <el-table-column label="家长姓名" align="center" prop="parentName" />
       <el-table-column label="家长电话" align="center" prop="parentPhone" />
-      <el-table-column label="与学生的关系" align="center" prop="relation">
+      <!-- <el-table-column label="与学生的关系" align="center" prop="relation">
         <template slot-scope="scope">
           <dict-tag :options="dict.type.parent_relation" :value="scope.row.relation"/>
         </template>
-      </el-table-column>
+      </el-table-column> -->
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -167,7 +167,7 @@
               </el-option>
             </el-select>
         </el-form-item>
-        <el-form-item label="与学生的关系" prop="relation">
+        <!-- <el-form-item label="与学生的关系" prop="relation">
             <el-select v-model="form.relation" placeholder="请选择与学生的关系" clearable style="width: 100%;">
               <el-option
                 v-for="dict in dict.type.parent_relation"
@@ -176,7 +176,7 @@
                 :value="dict.value"
               />
             </el-select>
-        </el-form-item>
+        </el-form-item> -->
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -194,7 +194,7 @@ import { Loading } from 'element-ui';
 export default {
   name: "Parent",
   mixins: [Textyixia],
-  dicts: ['parent_relation'],
+  // dicts: ['parent_relation'],
   data() {
     return {
       // 遮罩层
@@ -237,9 +237,9 @@ export default {
           { required: true, message: "家长电话不能为空", trigger: "blur" },
           { pattern: /^1[34578]\d{9}$/, message: "手机号码格式错误", trigger: "blur" }
         ],
-        relation: [
-          { required: true, message: "与学生的关系不能为空", trigger: "blur" }
-        ],
+        // relation: [
+        //   { required: true, message: "与学生的关系不能为空", trigger: "blur" }
+        // ],
       },
       dictTables: {
         studentDict: [],