当前位置:   article > 正文

学生管理系统带前端页面(springboot+mybatis+MySQL)_管理系统前端页面

管理系统前端页面

本人负责后端,本次完成了user的查询所有和添加功能

后端代码

数据层(Dao层)

  1. @Mapper
  2. public interface UserDao {
  3. User selectByNameId(User user); //根据username和password查询
  4. List<User> selectAll();//查询所有
  5. int addUser(User user);//添加user
  6. int deleteUser(String id);//通过工号删除(修改逻辑删除字段0为删除)
  7. }
  1. <insert id="addUser">
  2. insert into studentsystem.tb_user values (#{id},#{name},#{college},#{tel},#{email},#{username},#{password},#{status},#{deleted})
  3. </insert>
  4. <update id="deleteUser">
  5. update studentsystem.tb_user set deleted = 0 where id = #{id};
  6. </update>
  7. <select id="selectByNameId" resultType="com.example.studentsystem.pojo.User">
  8. select * from studentsystem.tb_user where username = #{username} and password = #{password}
  9. </select>
  10. <select id="selectAll" resultType="com.example.studentsystem.pojo.User">
  11. select * from studentsystem.tb_user where deleted = 1
  12. </select>

业务层(Service)

  1. @Transactional
  2. public interface UserService {
  3. boolean login(User user); //登录
  4. List<User> selectAll(); //查询所有
  5. boolean addUser(User user);//添加
  6. boolean deleteUser(String id);
  7. }
  1. @Service
  2. public class UserServiceImpl implements UserService {
  3. @Autowired
  4. private UserDao userDao;
  5. @Override
  6. public boolean login(User user) {
  7. User user1 = userDao.selectByNameId(user);
  8. if(user1 == null){
  9. return false;
  10. }
  11. return user1.getDeleted() != 0 && user1.getStatus() != 0;
  12. }
  13. @Override
  14. public List<User> selectAll() {
  15. List<User> users = userDao.selectAll();
  16. return users;
  17. }
  18. @Override
  19. public boolean addUser(User user) {
  20. if(user == null){
  21. return false;
  22. }
  23. user.setStatus(1);
  24. user.setDeleted(1);
  25. int i = userDao.addUser(user);
  26. return i>0;
  27. }
  28. @Override
  29. public boolean deleteUser(String id) {
  30. int i = userDao.deleteUser(id);
  31. return i>0;
  32. }
  33. }

表现层(Controller)

  1. @Slf4j
  2. @RestController
  3. @RequestMapping("/users")
  4. public class UserController {
  5. @Autowired
  6. private UserService userService;
  7. @PostMapping("/login")
  8. public Result login(@RequestBody User user) {
  9. boolean flag = userService.login(user);
  10. return new Result(flag ? Code.SUCCESS : Code.FAIL, flag);
  11. }
  12. @PostMapping("/selectAll")
  13. public Result selectAll() {
  14. List<User> users = userService.selectAll();
  15. boolean flag = !users.isEmpty();
  16. log.info(users.toString());
  17. return new Result(flag ? Code.SUCCESS : Code.FAIL,users);
  18. }
  19. @PostMapping("/addUser")
  20. public Result addUser(@RequestBody User user) {
  21. boolean flag = userService.addUser(user);
  22. return new Result(flag ? Code.SUCCESS : Code.FAIL,flag);
  23. }
  24. @GetMapping("/deleteUser")
  25. public Result deleteUser(String id){
  26. boolean flag = userService.deleteUser(id);
  27. return new Result(flag ? Code.SUCCESS : Code.FAIL,flag);
  28. }
  29. }

页面展示

数据库设计

 SQL脚本

  1. create table studentsystem.tb_administrativeclass
  2. (
  3. name varchar(32) not null comment '班级名称'
  4. primary key,
  5. teacherid varchar(32) null comment '班主任工号',
  6. count int null comment '班级总人数',
  7. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  8. constraint fk_administrativeclass_teacherid
  9. foreign key (teacherid) references studentsystem.tb_user (id)
  10. )
  11. comment '行政班';
  12. create table studentsystem.tb_college
  13. (
  14. name varchar(32) not null comment '学院名称'
  15. primary key,
  16. deleted int default 1 null comment '逻辑删除字段0表示已删除'
  17. )
  18. comment '学院表';
  19. create table studentsystem.tb_course
  20. (
  21. id varchar(32) not null comment '课程ID'
  22. primary key,
  23. name varchar(32) null comment '课程名称',
  24. deleted int default 1 null comment '逻辑删除字段0表示已删除'
  25. )
  26. comment '课程表';
  27. create table studentsystem.tb_courseaim
  28. (
  29. id bigint not null comment '主键id'
  30. primary key,
  31. description varchar(1024) null comment '课程目标描述',
  32. courseid varchar(32) null comment '课程ID',
  33. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  34. constraint fk_courseaim_courseid
  35. foreign key (courseid) references studentsystem.tb_course (id)
  36. )
  37. comment '课程目标表';
  38. create table studentsystem.tb_courseaim_evaluationbasis
  39. (
  40. id bigint not null comment '主键ID'
  41. primary key,
  42. courseaimid bigint null comment '课程目标ID',
  43. evaluationbasis bigint null comment '评价标准ID',
  44. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  45. constraint fk_courseaim_evaluationbasis_courseaimid
  46. foreign key (courseaimid) references studentsystem.tb_courseaim (id),
  47. constraint fk_courseaim_evaluationbasis_evaluationbasis
  48. foreign key (evaluationbasis) references studentsystem.tb_evaluationbasis (id)
  49. )
  50. comment '课程目标与评价标准中间表';
  51. create table studentsystem.tb_evaluationbasis
  52. (
  53. id bigint not null comment '主键ID'
  54. primary key,
  55. name varchar(16) null comment '评价标准名称',
  56. deleted int default 1 null comment '逻辑删除字段0表示已删除'
  57. )
  58. comment '评价标准表';
  59. create table studentsystem.tb_student
  60. (
  61. id bigint not null comment '学号'
  62. primary key,
  63. name varchar(12) null comment '姓名',
  64. sex char null comment '性别',
  65. classname varchar(32) null comment '行政班级名称',
  66. college varchar(32) null comment '学院名称',
  67. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  68. constraint fk_student_classname
  69. foreign key (classname) references studentsystem.tb_administrativeclass (name),
  70. constraint fk_student_college
  71. foreign key (college) references studentsystem.tb_college (name)
  72. )
  73. comment '学生表';
  74. create table studentsystem.tb_student_course
  75. (
  76. id bigint not null comment '主键ID'
  77. primary key,
  78. studentid bigint null comment '学生ID',
  79. courseid varchar(32) null comment '课程ID',
  80. score double null comment '总分',
  81. jsonscore varchar(2048) null comment '各评价标准成绩',
  82. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  83. constraint fk_student_course_courseid
  84. foreign key (courseid) references studentsystem.tb_course (id),
  85. constraint fk_student_course_studentid
  86. foreign key (studentid) references studentsystem.tb_student (id)
  87. )
  88. comment '学生与课程中间表';
  89. create table studentsystem.tb_student_course
  90. (
  91. id bigint not null comment '主键ID'
  92. primary key,
  93. studentid bigint null comment '学生ID',
  94. courseid varchar(32) null comment '课程ID',
  95. score double null comment '总分',
  96. jsonscore varchar(2048) null comment '各评价标准成绩',
  97. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  98. constraint fk_student_course_courseid
  99. foreign key (courseid) references studentsystem.tb_course (id),
  100. constraint fk_student_course_studentid
  101. foreign key (studentid) references studentsystem.tb_student (id)
  102. )
  103. comment '学生与课程中间表';
  104. create table studentsystem.tb_teachclass
  105. (
  106. id bigint not null comment '主键id'
  107. primary key,
  108. teacherid varchar(32) null comment '老师工号',
  109. couseid varchar(32) null comment '课程ID',
  110. name varchar(32) null comment '班级名称',
  111. count int null comment '班级总人数',
  112. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  113. constraint fk_teachclass_couseid
  114. foreign key (couseid) references studentsystem.tb_course (id),
  115. constraint fk_teachclass_teacherid
  116. foreign key (teacherid) references studentsystem.tb_user (id)
  117. )
  118. comment '教学班';
  119. create table studentsystem.tb_user
  120. (
  121. id varchar(32) not null comment '教职工工号'
  122. primary key,
  123. name varchar(12) null comment '老师姓名',
  124. college varchar(32) null comment '学院名称',
  125. tel char(11) null comment '电话号码',
  126. email varchar(32) null comment '邮箱',
  127. username varchar(32) null comment '用户名',
  128. password varchar(32) null comment '密码',
  129. status int default 1 null comment '账号状态1正常,0异常',
  130. deleted int default 1 null comment '逻辑删除字段0表示已删除',
  131. constraint username
  132. unique (username),
  133. constraint fk_user_college
  134. foreign key (college) references studentsystem.tb_college (name)
  135. )
  136. comment '用户表';

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/625377
推荐阅读
相关标签
  

闽ICP备14008679号