From e8448f7103affd102e2a603b820fa5bb37bf304b Mon Sep 17 00:00:00 2001 From: PeterAlbus Date: Sat, 18 Dec 2021 23:24:05 +0800 Subject: [PATCH] added paging and some student activity method --- .gitignore | 1 + .../controller/StudentController.java | 15 ++ .../java/com/peteralbus/dao/ActivityDao.java | 7 - .../java/com/peteralbus/entity/Activity.java | 24 +++ .../com/peteralbus/entity/Participate.java | 12 ++ .../peteralbus/service/ActivityService.java | 9 +- .../com/peteralbus/service/GroupService.java | 30 ++++ .../service/ParticipateService.java | 17 ++ src/main/resources/mapper/ActivityDao.xml | 9 +- src/main/webapp/css/student/applyActivity.css | 3 + src/main/webapp/jsp/student/activities.jsp | 16 +- src/main/webapp/jsp/student/applyActivity.jsp | 170 ++++++++++++++++++ src/main/webapp/jsp/teacher/activity.jsp | 27 ++- .../webapp/jsp/teacher/activityDetail.jsp | 2 +- 14 files changed, 313 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/peteralbus/service/GroupService.java create mode 100644 src/main/java/com/peteralbus/service/ParticipateService.java create mode 100644 src/main/webapp/css/student/applyActivity.css create mode 100644 src/main/webapp/jsp/student/applyActivity.jsp diff --git a/.gitignore b/.gitignore index 1e660e7..b9fc8a7 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ *.zip *.tar.gz *.rar +jdbcConfig.properties # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/src/main/java/com/peteralbus/controller/StudentController.java b/src/main/java/com/peteralbus/controller/StudentController.java index 8de686a..c488629 100644 --- a/src/main/java/com/peteralbus/controller/StudentController.java +++ b/src/main/java/com/peteralbus/controller/StudentController.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.util.PrincipalUtil; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; @@ -23,6 +25,8 @@ public class StudentController { @Autowired ActivityService activityService; + @Autowired + GroupService groupService; @RequestMapping("/activities") public ModelAndView activities() { @@ -36,4 +40,15 @@ public class StudentController modelAndView.setViewName("/jsp/student/activities.jsp"); return modelAndView; } + @RequestMapping("/applyActivity") + public ModelAndView applyActivity(Long activityId) + { + ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView(); + Activity activity= activityService.getActivityById(activityId); + modelAndView.addObject("activity",activity); + List groupList=groupService.getGroupListByActivity(activityId); + modelAndView.addObject(groupList); + modelAndView.setViewName("/jsp/student/applyActivity.jsp"); + return modelAndView; + } } diff --git a/src/main/java/com/peteralbus/dao/ActivityDao.java b/src/main/java/com/peteralbus/dao/ActivityDao.java index 84a2d79..c5ac9b9 100644 --- a/src/main/java/com/peteralbus/dao/ActivityDao.java +++ b/src/main/java/com/peteralbus/dao/ActivityDao.java @@ -39,13 +39,6 @@ public interface ActivityDao extends BaseMapper */ List getTeacherList(Long activityId); - /** - * Gets activities. - * - * @return the activities - */ - List getActivities(); - /** * Gets count. * diff --git a/src/main/java/com/peteralbus/entity/Activity.java b/src/main/java/com/peteralbus/entity/Activity.java index 24ed3a2..92447cc 100644 --- a/src/main/java/com/peteralbus/entity/Activity.java +++ b/src/main/java/com/peteralbus/entity/Activity.java @@ -21,6 +21,8 @@ public class Activity implements Serializable private String activityName; private String activityType; private String activityIntroduction; + private Integer minPeople; + private Integer maxPeople; @Version private Integer version; @TableField(fill = FieldFill.INSERT) @@ -131,6 +133,26 @@ public class Activity implements Serializable this.teacherList = teacherList; } + public Integer getMinPeople() + { + return minPeople; + } + + public void setMinPeople(Integer minPeople) + { + this.minPeople = minPeople; + } + + public Integer getMaxPeople() + { + return maxPeople; + } + + public void setMaxPeople(Integer maxPeople) + { + this.maxPeople = maxPeople; + } + @Override public String toString() { @@ -139,6 +161,8 @@ public class Activity implements Serializable ", activityName='" + activityName + '\'' + ", activityType='" + activityType + '\'' + ", activityIntroduction='" + activityIntroduction + '\'' + + ", minPeople=" + minPeople + + ", maxPeople=" + maxPeople + ", version=" + version + ", gmtCreate=" + gmtCreate + ", gmtModified=" + gmtModified + diff --git a/src/main/java/com/peteralbus/entity/Participate.java b/src/main/java/com/peteralbus/entity/Participate.java index 3d26f8a..330eb3f 100644 --- a/src/main/java/com/peteralbus/entity/Participate.java +++ b/src/main/java/com/peteralbus/entity/Participate.java @@ -20,6 +20,7 @@ public class Participate implements Serializable private Long activityId; private Long groupId; private Boolean isFinished; + private Boolean isAccept; @Version private Integer version; @TableField(fill = FieldFill.INSERT) @@ -123,6 +124,16 @@ public class Participate implements Serializable this.isDelete = isDelete; } + public Boolean getAccept() + { + return isAccept; + } + + public void setAccept(Boolean accept) + { + isAccept = accept; + } + @Override public String toString() { @@ -132,6 +143,7 @@ public class Participate implements Serializable ", activityId=" + activityId + ", groupId=" + groupId + ", isFinished=" + isFinished + + ", isAccept=" + isAccept + ", version=" + version + ", gmtCreate=" + gmtCreate + ", gmtModified=" + gmtModified + diff --git a/src/main/java/com/peteralbus/service/ActivityService.java b/src/main/java/com/peteralbus/service/ActivityService.java index bc23133..9420259 100644 --- a/src/main/java/com/peteralbus/service/ActivityService.java +++ b/src/main/java/com/peteralbus/service/ActivityService.java @@ -2,6 +2,7 @@ package com.peteralbus.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.peteralbus.dao.ActivityDao; +import com.peteralbus.dao.GroupDao; import com.peteralbus.dao.ManageDao; import com.peteralbus.entity.Activity; import com.peteralbus.entity.Manage; @@ -26,6 +27,8 @@ public class ActivityService @Autowired private ActivityDao activityDao; @Autowired + private GroupDao groupDao; + @Autowired private ManageDao manageDao; public int addActivity(Activity activity) { @@ -46,7 +49,9 @@ public class ActivityService } public Activity getActivityById(Long activityId) { - return activityDao.selectById(activityId); + Activity activity=activityDao.selectById(activityId); + activity.setTeacherList(activityDao.getTeacherList(activityId)); + return activity; } public Boolean checkIsManage(Long teacherId,Long activityId) { @@ -78,7 +83,7 @@ public class ActivityService } public List getActivities() { - List activityList=activityDao.getActivities(); + List activityList=activityDao.selectList(null); for(Activity activity:activityList) { List teacherList=activityDao.getTeacherList(activity.getActivityId()); diff --git a/src/main/java/com/peteralbus/service/GroupService.java b/src/main/java/com/peteralbus/service/GroupService.java new file mode 100644 index 0000000..697fd80 --- /dev/null +++ b/src/main/java/com/peteralbus/service/GroupService.java @@ -0,0 +1,30 @@ +package com.peteralbus.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.peteralbus.dao.GroupDao; +import com.peteralbus.entity.Group; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * The type Group service. + * @author peteralbus + */ +@Service +public class GroupService +{ + @Autowired + GroupDao groupDao; + public List getGroupListByActivity(Long activityId) + { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("activity_id",activityId); + return groupDao.selectList(queryWrapper); + } + public int insertGroup(Group group) + { + return groupDao.insert(group); + } +} diff --git a/src/main/java/com/peteralbus/service/ParticipateService.java b/src/main/java/com/peteralbus/service/ParticipateService.java new file mode 100644 index 0000000..b1d27eb --- /dev/null +++ b/src/main/java/com/peteralbus/service/ParticipateService.java @@ -0,0 +1,17 @@ +package com.peteralbus.service; + +import com.peteralbus.dao.ParticipateDao; +import com.peteralbus.entity.Participate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ParticipateService +{ + @Autowired + ParticipateDao participateDao; + public int insertParticipate(Participate participate) + { + return participateDao.insert(participate); + } +} diff --git a/src/main/resources/mapper/ActivityDao.xml b/src/main/resources/mapper/ActivityDao.xml index b059d78..cadc46c 100644 --- a/src/main/resources/mapper/ActivityDao.xml +++ b/src/main/resources/mapper/ActivityDao.xml @@ -4,12 +4,12 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -17,11 +17,6 @@ select user.user_id,username,real_name,user_phone,avatar_src from activity,user,manage where activity.activity_id=#{activityId} and manage.activity_id=activity.activity_id and manage.user_id=user.user_id and manage.is_delete=0 and user.is_delete=0 - diff --git a/src/main/webapp/css/student/applyActivity.css b/src/main/webapp/css/student/applyActivity.css new file mode 100644 index 0000000..8f4f03c --- /dev/null +++ b/src/main/webapp/css/student/applyActivity.css @@ -0,0 +1,3 @@ +.button-group{ + float: right; +} \ No newline at end of file diff --git a/src/main/webapp/jsp/student/activities.jsp b/src/main/webapp/jsp/student/activities.jsp index b9ad462..65a9819 100644 --- a/src/main/webapp/jsp/student/activities.jsp +++ b/src/main/webapp/jsp/student/activities.jsp @@ -26,7 +26,7 @@