From 4a48b675ac14ab22c08b5ac881292f590cdc72ca Mon Sep 17 00:00:00 2001 From: PeterAlbus Date: Tue, 21 Dec 2021 12:10:52 +0800 Subject: [PATCH] Improved functionality for faculty management activities. --- .../controller/TeacherController.java | 40 +++- .../java/com/peteralbus/entity/Group.java | 15 +- .../peteralbus/service/ActivityService.java | 11 + .../com/peteralbus/service/GroupService.java | 4 + .../com/peteralbus/service/UserService.java | 7 + .../webapp/css/teacher/modifyActivity.css | 7 + src/main/webapp/jsp/student/activities.jsp | 13 +- src/main/webapp/jsp/teacher/activity.jsp | 25 +- .../webapp/jsp/teacher/activityDetail.jsp | 20 +- .../webapp/jsp/teacher/modifyActivity.jsp | 214 +++++++++++++++--- 10 files changed, 300 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/peteralbus/controller/TeacherController.java b/src/main/java/com/peteralbus/controller/TeacherController.java index 6ecdd03..7b346dd 100644 --- a/src/main/java/com/peteralbus/controller/TeacherController.java +++ b/src/main/java/com/peteralbus/controller/TeacherController.java @@ -1,8 +1,10 @@ package com.peteralbus.controller; import com.peteralbus.entity.Activity; +import com.peteralbus.entity.Group; import com.peteralbus.entity.User; import com.peteralbus.service.ActivityService; +import com.peteralbus.service.GroupService; import com.peteralbus.service.UserService; import com.peteralbus.util.PrincipalUtil; import net.bytebuddy.implementation.bytecode.Throw; @@ -31,6 +33,8 @@ public class TeacherController ActivityService activityService; @Autowired UserService userService; + @Autowired + GroupService groupService; @RequiresRoles(value={"teacher"}, logical= Logical.OR) @RequestMapping("/activities") public ModelAndView activities() @@ -66,7 +70,11 @@ public class TeacherController throw new UnauthorizedException(); } Activity activity=activityService.getActivityById(activityId); + List groupList=groupService.getGroupListByActivity(activityId); + List teacherList=userService.getTeacherList(); + modelAndView.addObject("groupList",groupList); modelAndView.addObject("activity",activity); + modelAndView.addObject("teacherList",teacherList); modelAndView.setViewName("/jsp/teacher/modifyActivity.jsp"); return modelAndView; } @@ -76,7 +84,28 @@ public class TeacherController { try { - int result=activityService.addActivity(activity); + int result=activityService.updateActivity(activity); + if(result>0) + { + return "success"; + } + else + { + return "error"; + } + } + catch (Exception e) + { + return "error:"+e.getMessage(); + } + } + @ResponseBody + @RequestMapping("/updateActivity") + public String updateActivity(Activity activity) + { + try + { + int result=activityService.updateActivity(activity); if(result>0) { return activity.getActivityId().toString(); @@ -93,10 +122,13 @@ public class TeacherController } @ResponseBody @RequestMapping("/addTeacherToActivity") - public String addTeacherToActivity(String teacherName,Long activityId) + public String addTeacherToActivity(Long userId,Long activityId) { - User user=userService.queryByUsername(teacherName); - int result=activityService.addTeacherToActivity(user.getUserId(),activityId); + if(activityService.checkIsManage(userId,activityId)) + { + return "exist"; + } + int result=activityService.addTeacherToActivity(userId,activityId); if(result>0) { return "success"; diff --git a/src/main/java/com/peteralbus/entity/Group.java b/src/main/java/com/peteralbus/entity/Group.java index 40abce8..b69919d 100644 --- a/src/main/java/com/peteralbus/entity/Group.java +++ b/src/main/java/com/peteralbus/entity/Group.java @@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.List; /** * The type Group. @@ -22,7 +23,9 @@ public class Group implements Serializable @TableField(exist = false) private String leaderName; @TableField(exist = false) - public Long memberCount; + private Long memberCount; + @TableField(exist = false) + private List memberList; private Long activityId; @Version private Integer version; @@ -142,6 +145,16 @@ public class Group implements Serializable this.memberCount = memberCount; } + public List getMemberList() + { + return memberList; + } + + public void setMemberList(List memberList) + { + this.memberList = memberList; + } + @Override public String toString() { diff --git a/src/main/java/com/peteralbus/service/ActivityService.java b/src/main/java/com/peteralbus/service/ActivityService.java index bb30404..d1ac6fa 100644 --- a/src/main/java/com/peteralbus/service/ActivityService.java +++ b/src/main/java/com/peteralbus/service/ActivityService.java @@ -50,6 +50,17 @@ public class ActivityService return manageDao.insert(manage); } + /** + * Update activity int. + * + * @param activity the activity + * @return the int + */ + public int updateActivity(Activity activity) + { + return activityDao.updateById(activity); + } + /** * Add teacher to activity int. * diff --git a/src/main/java/com/peteralbus/service/GroupService.java b/src/main/java/com/peteralbus/service/GroupService.java index d1d6591..4b6a81b 100644 --- a/src/main/java/com/peteralbus/service/GroupService.java +++ b/src/main/java/com/peteralbus/service/GroupService.java @@ -52,6 +52,10 @@ public class GroupService { User user=userDao.selectById(group.getLeaderId()); group.setLeaderName(user.getRealName()); + List memberList=this.getGroupMember(group.getGroupId()); + group.setMemberList(memberList); + Long memberCount=this.getMemberCount(group.getGroupId()); + group.setMemberCount(memberCount); } return groupList; } diff --git a/src/main/java/com/peteralbus/service/UserService.java b/src/main/java/com/peteralbus/service/UserService.java index 9625c1a..81f80d8 100644 --- a/src/main/java/com/peteralbus/service/UserService.java +++ b/src/main/java/com/peteralbus/service/UserService.java @@ -72,4 +72,11 @@ public class UserService { return userDao.deleteById(user); } + + public List getTeacherList() + { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("user_class",2); + return userDao.selectList(queryWrapper); + } } diff --git a/src/main/webapp/css/teacher/modifyActivity.css b/src/main/webapp/css/teacher/modifyActivity.css index 0fc6a5f..5eb9841 100644 --- a/src/main/webapp/css/teacher/modifyActivity.css +++ b/src/main/webapp/css/teacher/modifyActivity.css @@ -5,6 +5,13 @@ align-items: center; } +.group-list-top{ + width:95%; + display: flex; + justify-content: space-between; + align-items: center; +} + .button-group{ float: right; } diff --git a/src/main/webapp/jsp/student/activities.jsp b/src/main/webapp/jsp/student/activities.jsp index b35dafa..0e87299 100644 --- a/src/main/webapp/jsp/student/activities.jsp +++ b/src/main/webapp/jsp/student/activities.jsp @@ -100,15 +100,10 @@ 参加的活动
- -
负责老师:{{i.realName}} 
-

要求人数:{{item.minPeople}}-{{item.maxPeople}}人

-
{{item.activityIntroduction}}
+
+ {{item.activityName}}{{item.activityType}}已完成 + 管理 +
所有活动 diff --git a/src/main/webapp/jsp/teacher/activity.jsp b/src/main/webapp/jsp/teacher/activity.jsp index 1c382b6..1429037 100644 --- a/src/main/webapp/jsp/teacher/activity.jsp +++ b/src/main/webapp/jsp/teacher/activity.jsp @@ -49,7 +49,7 @@ direction="rtl" >
- + @@ -80,18 +80,18 @@ 负责的活动
- -
-

要求人数:{{item.minPeople}}-{{item.maxPeople}}人

-

{{item.activityIntroduction}}

+
+ {{item.activityName}}{{item.activityType}} + 管理
+
+ +
+ 添加活动 +
+
所有活动
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> @@ -63,6 +64,12 @@ {{activity.minPeople}}-{{activity.maxPeople}}人 + + + {{i.realName}}  +