almost finished waitGroup.jsp

DEV
PeterAlbus 3 years ago
parent 5689ee40df
commit c00885a59b

@ -2,12 +2,14 @@ package com.peteralbus.controller;
import com.peteralbus.entity.Activity;
import com.peteralbus.entity.Group;
import com.peteralbus.entity.Participate;
import com.peteralbus.entity.User;
import com.peteralbus.service.ActivityService;
import com.peteralbus.service.GroupService;
import com.peteralbus.service.ParticipateService;
import com.peteralbus.util.PrincipalUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -48,17 +50,52 @@ public class StudentController
public ModelAndView applyActivity(Long activityId)
{
ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView();
Subject subject = SecurityUtils.getSubject();
User user=(User)subject.getPrincipal();
Activity activity= activityService.getActivityById(activityId);
Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId);
if(participate!=null)
{
modelAndView.setViewName("redirect: /student/manageActivity?activityId="+activityId);
return modelAndView;
}
modelAndView.addObject("activity",activity);
List<Group> groupList=groupService.getGroupListByActivity(activityId);
modelAndView.addObject("groupList",groupList);
modelAndView.setViewName("/jsp/student/applyActivity.jsp");
return modelAndView;
}
@RequestMapping("/manageActivity")
public ModelAndView manageActivity(Long activityId)
{
ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView();
Subject subject = SecurityUtils.getSubject();
User user=(User)subject.getPrincipal();
Activity activity= activityService.getActivityById(activityId);
Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId);
if(participate==null)
{
throw new UnauthorizedException();
}
Long memberCount=groupService.getMemberCount(participate.getGroupId());
if(memberCount<=activity.getMinPeople())
{
if(participate.getAccept())
{
modelAndView.addObject("currentStatus","正在等待小组成员数量达到要求");
}
else
{
modelAndView.addObject("currentStatus","正在等待组长通过您的申请");
}
modelAndView.setViewName("/jsp/student/waitGroup.jsp");
}
else
{
modelAndView.setViewName("/jsp/student/manageActivity.jsp");
}
modelAndView.addObject("activity",activity);
return modelAndView;
}
@ResponseBody

@ -2,8 +2,10 @@ package com.peteralbus.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peteralbus.dao.GroupDao;
import com.peteralbus.dao.ParticipateDao;
import com.peteralbus.dao.UserDao;
import com.peteralbus.entity.Group;
import com.peteralbus.entity.Participate;
import com.peteralbus.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -21,6 +23,8 @@ public class GroupService
GroupDao groupDao;
@Autowired
UserDao userDao;
@Autowired
ParticipateDao participateDao;
public List<Group> getGroupListByActivity(Long activityId)
{
QueryWrapper<Group> queryWrapper=new QueryWrapper<>();
@ -37,6 +41,13 @@ public class GroupService
{
return groupDao.selectById(groupId);
}
public Long getMemberCount(Long groupId)
{
QueryWrapper<Participate> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("group_id",groupId);
queryWrapper.eq("is_accept",true);
return participateDao.selectCount(queryWrapper);
}
public int insertGroup(Group group)
{
return groupDao.insert(group);

@ -1,5 +1,6 @@
package com.peteralbus.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peteralbus.dao.GroupDao;
import com.peteralbus.dao.ParticipateDao;
import com.peteralbus.entity.Group;
@ -17,6 +18,13 @@ public class ParticipateService
ParticipateDao participateDao;
@Autowired
GroupDao groupDao;
public Participate getByUserAndActivity(Long userId,Long activityId)
{
QueryWrapper<Participate> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("user_id",userId);
queryWrapper.eq("activity_id",activityId);
return participateDao.selectOne(queryWrapper);
}
public int insertParticipate(Participate participate)
{
return participateDao.insert(participate);

@ -98,7 +98,7 @@
<template #header>
<div class="card-header">
<span>{{item.activityName}}<el-tag size="mini">{{item.activityType}}</el-tag></span>
<el-button class="button" type="text" @click="toModify(item.activityId)">管理</el-button>
<el-button class="button" type="text" @click="toManage(item.activityId)">管理</el-button>
</div>
</template>
<h5>负责老师:<span v-for="i in item.teachers">{{i.realName}}&emsp;</span></h5>
@ -264,6 +264,9 @@
},
toApply(id){
location.href="/student/applyActivity?activityId="+id
},
toManage(id){
location.href="/student/manageActivity?activityId="+id
}
}
};

@ -227,7 +227,7 @@
}
else
{
location.href="/"
location.href="/student/manageActivity?activityId="+this.activity.activityId
}
})
})
@ -263,7 +263,7 @@
}
else
{
location.href="/"
location.href="/student/manageActivity?activityId="+this.activity.activityId
}
})
})

@ -7,6 +7,7 @@
--%>
<%@ 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" %>
<!DOCTYPE html>
<html>
<head>
@ -35,12 +36,66 @@
<el-page-header icon="el-icon-arrow-left" :content="title" @back="goBack"></el-page-header>
<br/>
<div class="container">
<el-card style="width:320px">
<div style="text-align:center">
<img src="${pageContext.request.contextPath}/img/2.png" alt="">
<h3>A high quality UI Toolkit based on Vue.js</h3>
<el-steps :active="1" finish-status="success" simple>
<el-step title="申请参加" icon="el-icon-edit"></el-step>
<el-step title="小组形成" icon="el-icon-s-custom"></el-step>
<el-step title="上传日志" icon="el-icon-upload"></el-step>
<el-step title="教师评分" icon="el-icon-picture"></el-step>
</el-steps>
<el-divider content-position="left">社会实践活动信息</el-divider>
<div class="activity-info">
<el-descriptions
title="活动情况"
:column="1"
border
>
<el-descriptions-item>
<template #label>
活动名称
</template>
{{activity.activityName}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
活动类别
</template>
{{activity.activityType}}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
活动人数
</template>
{{activity.minPeople}}-{{activity.maxPeople}}人
</el-descriptions-item>
<el-descriptions-item>
<template #label>
负责老师
</template>
<span v-for="i in activity.teachers">{{i.realName}}&emsp;</span>
</el-descriptions-item>
<el-descriptions-item>
<template #label>
创建日期
</template>
{{activity.gmtCreate}}
</el-descriptions-item>
</el-descriptions>
<el-descriptions :column="1" border direction="vertical">
<el-descriptions-item>
<template #label>
简介
</template>
{{activity.activityIntroduction}}
</el-descriptions-item>
</el-descriptions>
</div>
</el-card>
<el-divider content-position="left">当前状态</el-divider>
<el-result
icon="info"
title="您已成功提交申请"
:sub-title="currentStatus"
>
</el-result>
</div>
</el-main>
</el-container>
@ -60,6 +115,27 @@
realName:'',
avatarSrc: ''
},
currentStatus:'${currentStatus}',
activity:{
activityId: '${activity.getActivityId()}',
activityName: '${activity.getActivityName()}',
activityType:'${activity.getActivityType()}',
activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:'${activity.getMinPeople()}',
maxPeople:'${activity.getMaxPeople()}',
gmtCreate:'${activity.getFormattedCreateDate()}',
teachers:[
<c:forEach items="${activity.getTeacherList()}" var="teacher">
{
userId:'${teacher.getUserId()}',
username:'${teacher.getUsername()}',
realName:'${teacher.getRealName()}',
userPhone:'${teacher.getUserPhone()}',
avatarSrc:'${teacher.getAvatarSrc()}'
},
</c:forEach>
]
},
activeIndex:'3'
}
},

Loading…
Cancel
Save