package com.example.service;
import com.example.mapper.UserMapper;
import com.example.pojo.Student;
import com.example.pojo.Teacher;
import com.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
public int getByUser(String username, String password, String position) {
return userMapper.getByUser(username, password, position);
}
public void add(User user) {
String userName = user.getUserName();
String password = user.getPassword();
String position = user.getPosition();
userMapper.add(userName, password, position);
}
public void addTea(Teacher teacher) {
String teacherID = teacher.getTeacherID();
String teacherName=teacher.getTeacherName();
String teacherSex=teacher.getTeacherSex();
String teacherCollege = teacher.getTeacherCollege();
String position=teacher.getPosition();
userMapper.addTea(teacherID, teacherName, teacherSex,teacherCollege, position);
}
public void addStu(Student student) {
String studentID = student.getStudentID();
String studentName = student.getStudentName();
String studentSex = student.getStudentSex();
String studentClass = student.getStudentClass();
String studentMajor = student.getStudentMajor();
userMapper.addStu(studentID, studentName, studentSex, studentClass, studentMajor);
}
}
TeacherService
package com.example.service; import com.example.mapper.TeacherMapper; import com.example.pojo.Course; import com.example.pojo.Information; import com.example.pojo.Teacher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class TeacherService { @Autowired private TeacherMapper teacherMapper; public Teacher getName(String username) { return teacherMapper.getName(username); } public void addCourse(Course course) { String courseID = course.getCourseID(); String courseName = course.getCourseName(); int courseCount = course.getCourseCount(); String courseTeacher = course.getCourseTeacher(); int count = course.getCount(); teacherMapper.addCourse(courseID, courseName, courseCount, courseTeacher, count); } public void updateTea(Teacher teacher) { String teacherID = teacher.getTeacherID(); String teacherName = teacher.getTeacherName(); String teacherSex = teacher.getTeacherSex(); String teacherCollege = teacher.getTeacherCollege(); String position = teacher.getPosition(); teacherMapper.updateTea(teacherID, teacherName, teacherSex, teacherCollege, position); } public Teacher getByName(String name) { return teacherMapper.getByName(name); } public Teacher getAll(String username) { return teacherMapper.getAll(username); } public List<Course> getCourse(String name) { return teacherMapper.getCourse(name); } }
StudentService
package com.example.service; import com.example.mapper.StudentMapper; import com.example.pojo.Course; import com.example.pojo.Information; import com.example.pojo.Student; import com.example.pojo.Teacher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class StudentService { @Autowired private StudentMapper studentMapper; ; public Student getName(String username) { return studentMapper.getName(username); } public void update(Student student) { String studentID = student.getStudentID(); String studentName = student.getStudentName(); String studentSex = student.getStudentSex(); String studentClass = student.getStudentClass(); String studentMajor = student.getStudentMajor(); studentMapper.update(studentID, studentName, studentSex, studentClass, studentMajor); } public Course selectCourse(String name) { return studentMapper.selectCourse(name); } public Teacher selectAll(String name) { return studentMapper.selectAll(name); } public List<Course> select() { return studentMapper.select(); } public void choose1(Information information) { String courseID = information.getCourseID(); String TeacherID = information.getTeacherID(); String studentID = information.getStudentID(); studentMapper.choose1(courseID, TeacherID, studentID); } public void updateCourse(String id, String count) { studentMapper.updateCourse(id, count); } public Course cc(String id) { return studentMapper.cc(id); } public List<Information> getInformation(String name) { return studentMapper.getInformation(name); } }标签:String,teacher,public,12.1,import,com,example From: https://www.cnblogs.com/gjsgjs/p/17912303.html