gzq
This commit is contained in:
parent
79264a79a1
commit
96dad0ce76
@ -9,7 +9,7 @@ import java.util.Date;
|
||||
@Entity
|
||||
@Table
|
||||
@Data
|
||||
public class Exercise {
|
||||
public class Excercise {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@ -15,4 +15,5 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Parent extends User {
|
||||
|
||||
private int studentId;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.codesdream.ase.repository.parent;
|
||||
|
||||
import com.codesdream.ase.model.parent.Exercise;
|
||||
import com.codesdream.ase.model.parent.Excercise;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ExerciseRepository extends JpaRepository<Exercise, Integer> {
|
||||
List<Exercise> findByStudentId(int studentId);
|
||||
public interface ExcerciseRepository extends JpaRepository<Excercise, Integer> {
|
||||
List<Excercise> findByStudentId(int studentId);
|
||||
}
|
@ -11,7 +11,7 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ParentRepository extends JpaRepository<Parent,Integer> {
|
||||
List<Parent> findByStudentId(String studentId);
|
||||
List<Parent> findByStudentId(String studentId, Sort sort);
|
||||
List<Parent> findByStudentId(int studentId);
|
||||
List<Parent> findByStudentId(int studentId, Sort sort);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import java.util.Optional;
|
||||
@Repository
|
||||
public interface StudentRepository extends JpaRepository<Student, Integer> {
|
||||
|
||||
Student findByParentId(String parentId);
|
||||
Student findByParentId(String parentId, Sort sort);
|
||||
|
||||
Student findByParentId(int parentId);
|
||||
Student findByStudentId(int studentId);
|
||||
}
|
||||
|
76
src/main/java/com/codesdream/ase/service/ParentService.java
Normal file
76
src/main/java/com/codesdream/ase/service/ParentService.java
Normal file
@ -0,0 +1,76 @@
|
||||
package com.codesdream.ase.service;
|
||||
|
||||
import com.codesdream.ase.model.message.Notification;
|
||||
import com.codesdream.ase.model.parent.Parent;
|
||||
import com.codesdream.ase.model.student.Student;
|
||||
import com.codesdream.ase.repository.message.MessageRepository;
|
||||
import com.codesdream.ase.repository.parent.ParentRepository;
|
||||
import com.codesdream.ase.repository.student.StudentRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ParentService {
|
||||
|
||||
@Resource
|
||||
ParentRepository parentRepository;
|
||||
|
||||
@Resource
|
||||
StudentRepository studentRepository;
|
||||
|
||||
@Resource
|
||||
MessageRepository messageRepository;
|
||||
|
||||
/**
|
||||
* 用于创建一个家长账号
|
||||
* @param studentId 学生ID
|
||||
* @param parentId 家长id,一般为家长的电话
|
||||
* @param parentName 家长姓名
|
||||
* @return 创建的家长实体
|
||||
*/
|
||||
public Parent createParent(int studentId, int parentId, String parentName){
|
||||
|
||||
Parent parent=new Parent();
|
||||
parent.setUsername(parentName);
|
||||
parent.setId(parentId);
|
||||
parent.setStudentId(studentId);
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个家长的孩子
|
||||
* @param parentId 家长ID
|
||||
* @param
|
||||
* @return 这个家长的孩子
|
||||
*/
|
||||
public Student getStudent(int parentId){
|
||||
|
||||
return studentRepository.findByParentId(parentId);
|
||||
}
|
||||
/**
|
||||
* (用于绑定家长与学生账号)家长输入学生学号与姓名,若都正确,返回真。
|
||||
* @param studentId 学生ID
|
||||
* @param studentName 姓名
|
||||
* @return 学号与姓名是否一致
|
||||
*/
|
||||
public boolean startIdentify(int studentId, String studentName){
|
||||
Student s0=studentRepository.findByStudentId(studentId);
|
||||
if(s0!=null){
|
||||
if(s0.getUsername().equals(studentName))
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -3,14 +3,14 @@ package com.codesdream.ase.service;
|
||||
import com.codesdream.ase.component.student.SubjectScore;
|
||||
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||
import com.codesdream.ase.model.message.Notification;
|
||||
import com.codesdream.ase.model.parent.Exercise;
|
||||
import com.codesdream.ase.model.parent.Excercise;
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import com.codesdream.ase.model.permission.UserDetail;
|
||||
import com.codesdream.ase.model.student.Course;
|
||||
import com.codesdream.ase.model.student.Honor;
|
||||
import com.codesdream.ase.model.student.Student;
|
||||
import com.codesdream.ase.model.student.StudentCourse;
|
||||
import com.codesdream.ase.repository.parent.ExerciseRepository;
|
||||
import com.codesdream.ase.repository.parent.ExcerciseRepository;
|
||||
import com.codesdream.ase.repository.permission.UserRepository;
|
||||
import com.codesdream.ase.repository.student.*;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@ -43,7 +43,7 @@ public class StaticsService {
|
||||
NotificationRepository notificationRepository;
|
||||
|
||||
@Resource
|
||||
ExerciseRepository exerciseRepository;
|
||||
ExcerciseRepository exerciseRepository;
|
||||
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ public class StaticsService {
|
||||
* @param studentId 学生id
|
||||
* @return 锻炼情况列表
|
||||
*/
|
||||
public List<Exercise> displayExercise(int studentId){
|
||||
public List<Excercise> displayExercise(int studentId){
|
||||
if(!checkStudentExistence(studentId)){
|
||||
throw new NotFoundException("No such student.");
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.codesdream.ase.model.permission.UserDetail;
|
||||
import com.codesdream.ase.model.student.Honor;
|
||||
import com.codesdream.ase.model.message.Notification;
|
||||
import com.codesdream.ase.model.student.Student;
|
||||
import com.codesdream.ase.repository.parent.ExcerciseRepository;
|
||||
import com.codesdream.ase.repository.student.HonorRepository;
|
||||
import com.codesdream.ase.repository.student.NotificationRepository;
|
||||
import com.codesdream.ase.repository.student.StudentRepository;
|
||||
@ -37,6 +38,8 @@ public class StudentService {
|
||||
@Resource
|
||||
HonorRepository honorRepository;
|
||||
|
||||
@Resource
|
||||
ExcerciseRepository excerciseRepository;
|
||||
/**
|
||||
* 用于创建一个公告
|
||||
* @see Notification
|
||||
|
Loading…
Reference in New Issue
Block a user