Improved functionality for faculty management activities.

DEV
PeterAlbus 3 years ago
parent ad4e5a1f96
commit 4a48b675ac

@ -1,8 +1,10 @@
package com.peteralbus.controller; package com.peteralbus.controller;
import com.peteralbus.entity.Activity; import com.peteralbus.entity.Activity;
import com.peteralbus.entity.Group;
import com.peteralbus.entity.User; import com.peteralbus.entity.User;
import com.peteralbus.service.ActivityService; import com.peteralbus.service.ActivityService;
import com.peteralbus.service.GroupService;
import com.peteralbus.service.UserService; import com.peteralbus.service.UserService;
import com.peteralbus.util.PrincipalUtil; import com.peteralbus.util.PrincipalUtil;
import net.bytebuddy.implementation.bytecode.Throw; import net.bytebuddy.implementation.bytecode.Throw;
@ -31,6 +33,8 @@ public class TeacherController
ActivityService activityService; ActivityService activityService;
@Autowired @Autowired
UserService userService; UserService userService;
@Autowired
GroupService groupService;
@RequiresRoles(value={"teacher"}, logical= Logical.OR) @RequiresRoles(value={"teacher"}, logical= Logical.OR)
@RequestMapping("/activities") @RequestMapping("/activities")
public ModelAndView activities() public ModelAndView activities()
@ -66,7 +70,11 @@ public class TeacherController
throw new UnauthorizedException(); throw new UnauthorizedException();
} }
Activity activity=activityService.getActivityById(activityId); 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("activity",activity);
modelAndView.addObject("teacherList",teacherList);
modelAndView.setViewName("/jsp/teacher/modifyActivity.jsp"); modelAndView.setViewName("/jsp/teacher/modifyActivity.jsp");
return modelAndView; return modelAndView;
} }
@ -76,7 +84,28 @@ public class TeacherController
{ {
try 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) if(result>0)
{ {
return activity.getActivityId().toString(); return activity.getActivityId().toString();
@ -93,10 +122,13 @@ public class TeacherController
} }
@ResponseBody @ResponseBody
@RequestMapping("/addTeacherToActivity") @RequestMapping("/addTeacherToActivity")
public String addTeacherToActivity(String teacherName,Long activityId) public String addTeacherToActivity(Long userId,Long activityId)
{ {
User user=userService.queryByUsername(teacherName); if(activityService.checkIsManage(userId,activityId))
int result=activityService.addTeacherToActivity(user.getUserId(),activityId); {
return "exist";
}
int result=activityService.addTeacherToActivity(userId,activityId);
if(result>0) if(result>0)
{ {
return "success"; return "success";

@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List;
/** /**
* The type Group. * The type Group.
@ -22,7 +23,9 @@ public class Group implements Serializable
@TableField(exist = false) @TableField(exist = false)
private String leaderName; private String leaderName;
@TableField(exist = false) @TableField(exist = false)
public Long memberCount; private Long memberCount;
@TableField(exist = false)
private List<Participate> memberList;
private Long activityId; private Long activityId;
@Version @Version
private Integer version; private Integer version;
@ -142,6 +145,16 @@ public class Group implements Serializable
this.memberCount = memberCount; this.memberCount = memberCount;
} }
public List<Participate> getMemberList()
{
return memberList;
}
public void setMemberList(List<Participate> memberList)
{
this.memberList = memberList;
}
@Override @Override
public String toString() public String toString()
{ {

@ -50,6 +50,17 @@ public class ActivityService
return manageDao.insert(manage); 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. * Add teacher to activity int.
* *

@ -52,6 +52,10 @@ public class GroupService
{ {
User user=userDao.selectById(group.getLeaderId()); User user=userDao.selectById(group.getLeaderId());
group.setLeaderName(user.getRealName()); 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; return groupList;
} }

@ -72,4 +72,11 @@ public class UserService
{ {
return userDao.deleteById(user); 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; align-items: center;
} }
.group-list-top{
width:95%;
display: flex;
justify-content: space-between;
align-items: center;
}
.button-group{ .button-group{
float: right; float: right;
} }

@ -100,15 +100,10 @@
<el-divider content-position="left">参加的活动</el-divider> <el-divider content-position="left">参加的活动</el-divider>
<div class="activity-list-card" v-for="item in activityListResult"> <div class="activity-list-card" v-for="item in activityListResult">
<el-card class="box-card" shadow="hover"> <el-card class="box-card" shadow="hover">
<template #header> <div class="card-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>
<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>
<el-button class="button" type="text" @click="toManage(item.activityId)">管理</el-button> </div>
</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> </el-card>
</div> </div>
<el-divider content-position="left">所有活动</el-divider> <el-divider content-position="left">所有活动</el-divider>

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

@ -6,6 +6,7 @@
--%> --%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -63,6 +64,12 @@
</template> </template>
{{activity.minPeople}}-{{activity.maxPeople}}人 {{activity.minPeople}}-{{activity.maxPeople}}人
</el-descriptions-item> </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> <el-descriptions-item>
<template #label> <template #label>
创建日期 创建日期
@ -109,7 +116,18 @@
activityIntroduction:'${activity.getActivityIntroduction()}', activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:'${activity.getMinPeople()}', minPeople:'${activity.getMinPeople()}',
maxPeople:'${activity.getMaxPeople()}', 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' activeIndex:'2'
} }

@ -6,6 +6,7 @@
--%> --%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -14,6 +15,8 @@
<script src="${pageContext.request.contextPath}/vue/vue@next/vue.global.js"></script> <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/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}/vue/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css"> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
@ -32,33 +35,92 @@
<%@ include file="/jsp/aside.html" %> <%@ include file="/jsp/aside.html" %>
</el-aside> </el-aside>
<el-main> <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> <el-page-header icon="el-icon-arrow-left" :content="title" @back="goBack"></el-page-header>
<br/> <br/>
<div class="container modifyForm"> <div class="container">
<el-form ref="activity" :rules="rules" :model="form" style="width: 100%"> <el-divider content-position="left">编辑活动信息</el-divider>
<el-form-item label="活动名称" prop="activityName"> <div class="modifyForm">
<el-input v-model="activity.activityName" autocomplete="off"></el-input> <el-form ref="form" :rules="rules" :model="activity" style="width: 100%" label-width="80px">
</el-form-item> <el-form-item label="活动名称" prop="activityName">
<el-form-item label="活动类型" prop="activityType"> <el-input v-model="activity.activityName" autocomplete="off"></el-input>
<el-select </el-form-item>
v-model="activity.activityType" <el-form-item label="活动类型" prop="activityType">
placeholder="选择活动类型" <el-select
> v-model="activity.activityType"
<el-option label="阳光社区" value="阳光社区"></el-option> placeholder="选择活动类型"
<el-option label="暖心公益" value="暖心公益"></el-option> >
</el-select> <el-option label="阳光社区" value="阳光社区"></el-option>
</el-form-item> <el-option label="暖心公益" value="暖心公益"></el-option>
<el-form-item label="参加人数"> </el-select>
<el-slider v-model="range" range :max="50" :min="1"> </el-slider> </el-form-item>
</el-form-item> <el-form-item label="负责老师">
<el-form-item label="活动介绍" prop="activityIntroduction"> <span v-for="i in activity.teachers">{{i.realName}}&emsp;</span>
<el-input type="textarea" :rows="10" v-model="activity.activityIntroduction"></el-input> <el-button @click="dialogVisible=true" size="small" type="primary">添加</el-button>
</el-form-item> </el-form-item>
<div class="button-group"> <el-form-item label="参加人数">
<el-button type="primary" @click="submit('form')" :loading="loading">更改</el-button> <el-slider v-model="range" range :max="50" :min="1"> </el-slider>
<el-button type="danger">删除</el-button> </el-form-item>
</div> <el-form-item label="活动介绍" prop="activityIntroduction">
</el-form> <el-input type="textarea" :rows="10" v-model="activity.activityIntroduction"></el-input>
</el-form-item>
<div class="button-group">
<el-button type="primary" @click="submit('form')" :loading="loading">更改</el-button>
<el-button type="danger">删除</el-button>
</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> </div>
</el-main> </el-main>
</el-container> </el-container>
@ -79,6 +141,10 @@
avatarSrc: '' avatarSrc: ''
}, },
range:[${activity.getMinPeople()},${activity.getMaxPeople()}], range:[${activity.getMinPeople()},${activity.getMaxPeople()}],
loading:false,
dialogVisible:false,
currentPage:1,
keyWord:'',
activity:{ activity:{
activityId: '${activity.getActivityId()}', activityId: '${activity.getActivityId()}',
activityName: '${activity.getActivityName()}', activityName: '${activity.getActivityName()}',
@ -86,8 +152,49 @@
activityIntroduction:'${activity.getActivityIntroduction()}', activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:${activity.getMinPeople()}, minPeople:${activity.getMinPeople()},
maxPeople:${activity.getMaxPeople()}, 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: { rules: {
activityName: [ activityName: [
{ required: true, message: '请填写活动名称', trigger: 'blur' } { required: true, message: '请填写活动名称', trigger: 'blur' }
@ -107,6 +214,24 @@
this.user.username='${username}' this.user.username='${username}'
this.user.avatarSrc='${avatarSrc}' 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: { methods: {
goBack(){ goBack(){
window.history.go(-1); window.history.go(-1);
@ -115,11 +240,11 @@
this.$refs[name].validate((valid) => { this.$refs[name].validate((valid) => {
if (valid) { if (valid) {
this.loading=true this.loading=true
this.form.minPeople=this.range[0] this.activity.minPeople=this.range[0]
this.form.maxPeople=this.range[1] this.activity.maxPeople=this.range[1]
axios({ axios({
method: "post", method: "post",
url: "/teacher/modifyActivity", url: "/teacher/updateActivity",
data: this.activity, data: this.activity,
transformRequest: [ function(data){ transformRequest: [ function(data){
return Qs.stringify(data) //使用Qs将请求参数序列化 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); const app = Vue.createApp(App);

Loading…
Cancel
Save