Improved functionality for faculty management activities.

DEV
PeterAlbus 3 years ago
parent ad4e5a1f96
commit 4a48b675ac

@ -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<Group> groupList=groupService.getGroupListByActivity(activityId);
List<User> 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";

@ -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<Participate> memberList;
private Long activityId;
@Version
private Integer version;
@ -142,6 +145,16 @@ public class Group implements Serializable
this.memberCount = memberCount;
}
public List<Participate> getMemberList()
{
return memberList;
}
public void setMemberList(List<Participate> memberList)
{
this.memberList = memberList;
}
@Override
public String toString()
{

@ -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.
*

@ -52,6 +52,10 @@ public class GroupService
{
User user=userDao.selectById(group.getLeaderId());
group.setLeaderName(user.getRealName());
List<Participate> memberList=this.getGroupMember(group.getGroupId());
group.setMemberList(memberList);
Long memberCount=this.getMemberCount(group.getGroupId());
group.setMemberCount(memberCount);
}
return groupList;
}

@ -72,4 +72,11 @@ public class UserService
{
return userDao.deleteById(user);
}
public List<User> getTeacherList()
{
QueryWrapper<User> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("user_class",2);
return userDao.selectList(queryWrapper);
}
}

@ -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;
}

@ -100,15 +100,10 @@
<el-divider content-position="left">参加的活动</el-divider>
<div class="activity-list-card" v-for="item in activityListResult">
<el-card class="box-card" shadow="hover">
<template #header>
<div class="card-header">
<span>{{item.activityName}}<el-tag size="mini">{{item.activityType}}</el-tag><el-tag effect="dark" type="success" size="mini" v-if="item.isFinished">已完成</el-tag></span>
<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>
<p>要求人数:{{item.minPeople}}-{{item.maxPeople}}人</p>
<div>{{item.activityIntroduction}}</div>
</el-card>
</div>
<el-divider content-position="left">所有活动</el-divider>

@ -49,7 +49,7 @@
direction="rtl"
>
<div class="drawer-box">
<el-form ref="form" :rules="rules" :model="form" style="width: 80%">
<el-form ref="form" :rules="rules" :model="form" style="width: 80%" label-width="80px">
<el-form-item label="活动名称" prop="activityName">
<el-input v-model="form.activityName" autocomplete="off"></el-input>
</el-form-item>
@ -80,17 +80,17 @@
<el-divider content-position="left">负责的活动</el-divider>
<div class="activity-list-card" v-for="item in activityListResult">
<el-card class="box-card" shadow="hover">
<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>
</div>
</template>
</el-card>
</div>
<div class="activity-list-top">
<el-input v-model="keyWord1" prefix-icon="el-icon-search" placeholder="请输入活动名搜索" style="width: 50%"></el-input>
<div>
<p>要求人数:{{item.minPeople}}-{{item.maxPeople}}人</p>
<p>{{item.activityIntroduction}}</p>
<el-button type="primary" @click="showAddActivityForm=true">添加活动<i class="el-icon-document-add el-icon--right"></i></el-button>
</div>
</el-card>
</div>
<el-divider content-position="left">所有活动</el-divider>
<div style="text-align: center">
@ -159,6 +159,7 @@
},
activeIndex:'2',
keyWord:'',
keyWord1:'',
activityList:[],
allActivities:[],
currentPage:1,
@ -236,14 +237,14 @@
},
allActivitiesResult:function (){
let result=[];
if(this.keyWord==='')
if(this.keyWord1==='')
{
return this.allActivities;
}
for(let i=0;i<this.allActivities.length;i++)
{
let str=this.allActivities[i].activityName;
if(str.search(this.keyWord)!==-1)
if(str.search(this.keyWord1)!==-1)
{
result.push(this.allActivities[i]);
}

@ -6,6 +6,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>
@ -63,6 +64,12 @@
</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>
创建日期
@ -109,7 +116,18 @@
activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:'${activity.getMinPeople()}',
maxPeople:'${activity.getMaxPeople()}',
gmtCreate:'${activity.getFormattedCreateDate()}'
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:'2'
}

@ -6,6 +6,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>
@ -14,6 +15,8 @@
<script src="${pageContext.request.contextPath}/vue/vue@next/vue.global.js"></script>
<!-- 导入组件库 -->
<script src="${pageContext.request.contextPath}/vue/element/index.full.js"></script>
<script src="${pageContext.request.contextPath}/vue/axios/axios.js"></script>
<script src="${pageContext.request.contextPath}/vue/qs.min.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/vue/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
@ -32,10 +35,37 @@
<%@ include file="/jsp/aside.html" %>
</el-aside>
<el-main>
<el-dialog
v-model="dialogVisible"
title="选择老师"
width="50%"
>
<el-table :data="teacherListResultPagination" style="width: 100%">
<el-table-column prop="username" label="用户名"></el-table-column>
<el-table-column prop="realName" label="姓名"></el-table-column>
<el-table-column align="right">
<template #header>
<el-input v-model="keyWord" size="mini" placeholder="搜索姓名/用户名"></el-input>
</template>
<template #default="scope">
<el-button size="mini" @click="addTeacher(scope.row.userId)" type="primary">添加</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
layout="total, prev, pager, next"
:total="teacherListResult.length"
:page-size="5"
v-model:current-page="currentPage">
</el-pagination>
</el-dialog>
<el-page-header icon="el-icon-arrow-left" :content="title" @back="goBack"></el-page-header>
<br/>
<div class="container modifyForm">
<el-form ref="activity" :rules="rules" :model="form" style="width: 100%">
<div class="container">
<el-divider content-position="left">编辑活动信息</el-divider>
<div class="modifyForm">
<el-form ref="form" :rules="rules" :model="activity" style="width: 100%" label-width="80px">
<el-form-item label="活动名称" prop="activityName">
<el-input v-model="activity.activityName" autocomplete="off"></el-input>
</el-form-item>
@ -48,6 +78,10 @@
<el-option label="暖心公益" value="暖心公益"></el-option>
</el-select>
</el-form-item>
<el-form-item label="负责老师">
<span v-for="i in activity.teachers">{{i.realName}}&emsp;</span>
<el-button @click="dialogVisible=true" size="small" type="primary">添加</el-button>
</el-form-item>
<el-form-item label="参加人数">
<el-slider v-model="range" range :max="50" :min="1"> </el-slider>
</el-form-item>
@ -60,6 +94,34 @@
</div>
</el-form>
</div>
<el-divider content-position="left">参加活动的小组</el-divider>
<div>
<el-collapse>
<el-collapse-item :name="item.groupId" v-for="item in groupList" style="width:100%">
<template #title>
<div class="group-list-top">
<div>
{{item.groupName}}-组长:{{item.leaderName}}, 组员数量:{{item.memberCount}}
</div>
<div>
<el-button type="primary" size="mini">管理该小组</el-button>
</div>
</div>
</template>
<el-table :data="item.memberList" style="width: 100%" stripe>
<el-table-column prop="username" label="用户名"></el-table-column>
<el-table-column prop="realName" label="姓名"></el-table-column>
<el-table-column align="right" label="加入状态">
<template #default="scope">
<el-tag type="success" v-if="scope.row.isAccept">已通过</el-tag>
<el-tag type="info" v-if="!scope.row.isAccept">审核中</el-tag>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
</div>
</div>
</el-main>
</el-container>
</div>
@ -79,6 +141,10 @@
avatarSrc: ''
},
range:[${activity.getMinPeople()},${activity.getMaxPeople()}],
loading:false,
dialogVisible:false,
currentPage:1,
keyWord:'',
activity:{
activityId: '${activity.getActivityId()}',
activityName: '${activity.getActivityName()}',
@ -86,8 +152,49 @@
activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:${activity.getMinPeople()},
maxPeople:${activity.getMaxPeople()},
gmtCreate:'${activity.getFormattedCreateDate()}'
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>
]
},
groupList: [
<c:forEach items="${groupList}" var="group">
{
groupId:'${group.getGroupId()}',
groupName:'${group.getGroupName()}',
leaderName:'${group.getLeaderName()}',
memberCount:'${group.getMemberCount()}',
memberList:[
<c:forEach items="${group.getMemberList()}" var="member">
{
participateId:'${member.getParticipationId()}',
userId:'${member.getUserId()}',
username:'${member.getUsername()}',
realName:'${member.getRealName()}',
isAccept:${member.getAccept()}
},
</c:forEach>
]
},
</c:forEach>
],
teacherList:[
<c:forEach items="${teacherList}" var="teacher">
{
userId:'${teacher.getUserId()}',
username:'${teacher.getUsername()}',
realName:'${teacher.getRealName()}',
},
</c:forEach>
],
rules: {
activityName: [
{ required: true, message: '请填写活动名称', trigger: 'blur' }
@ -107,6 +214,24 @@
this.user.username='${username}'
this.user.avatarSrc='${avatarSrc}'
},
computed:{
teacherListResult:function (){
let result=[];
for(let i=0;i<this.teacherList.length;i++)
{
let str=this.teacherList[i].realName
let str1=this.teacherList[i].username
if(str.search(this.keyWord)!==-1||str1.search(this.keyWord)!==-1)
{
result.push(this.teacherList[i]);
}
}
return result;
},
teacherListResultPagination:function (){
return this.teacherListResult.slice((this.currentPage-1)*5,this.currentPage*5)
}
},
methods: {
goBack(){
window.history.go(-1);
@ -115,11 +240,11 @@
this.$refs[name].validate((valid) => {
if (valid) {
this.loading=true
this.form.minPeople=this.range[0]
this.form.maxPeople=this.range[1]
this.activity.minPeople=this.range[0]
this.activity.maxPeople=this.range[1]
axios({
method: "post",
url: "/teacher/modifyActivity",
url: "/teacher/updateActivity",
data: this.activity,
transformRequest: [ function(data){
return Qs.stringify(data) //使用Qs将请求参数序列化
@ -142,6 +267,37 @@
}
})
},
addTeacher(id){
this.$messageBox.confirm(
'确认要添加改老师为负责老师吗,该老师将拥有与你相同的权限?',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
axios({
method: "get",
url: "/teacher/addTeacherToActivity?userId="+id+"&activityId="+this.activity.activityId,
}).then(res=>{
this.loading=false
if(res.data==="error")
{
this.$message.error('添加失败!')
}
else if(res.data==="exist")
{
this.$message.error('该老师已经是负责老师!')
}
else
{
location.reload()
}
})
})
}
}
};
const app = Vue.createApp(App);

Loading…
Cancel
Save