added paging and some student activity method

DEV
PeterAlbus 3 years ago
parent cf8c20f4d6
commit e8448f7103

1
.gitignore vendored

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

@ -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<Group> groupList=groupService.getGroupListByActivity(activityId);
modelAndView.addObject(groupList);
modelAndView.setViewName("/jsp/student/applyActivity.jsp");
return modelAndView;
}
}

@ -39,13 +39,6 @@ public interface ActivityDao extends BaseMapper<Activity>
*/
List<User> getTeacherList(Long activityId);
/**
* Gets activities.
*
* @return the activities
*/
List<Activity> getActivities();
/**
* Gets count.
*

@ -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 +

@ -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 +

@ -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<Activity> getActivities()
{
List<Activity> activityList=activityDao.getActivities();
List<Activity> activityList=activityDao.selectList(null);
for(Activity activity:activityList)
{
List<User> teacherList=activityDao.getTeacherList(activity.getActivityId());

@ -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<Group> getGroupListByActivity(Long activityId)
{
QueryWrapper<Group> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("activity_id",activityId);
return groupDao.selectList(queryWrapper);
}
public int insertGroup(Group group)
{
return groupDao.insert(group);
}
}

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

@ -4,12 +4,12 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peteralbus.dao.ActivityDao">
<select id="getActivityByTeacher" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity">
select activity.activity_id, activity_name, activity_type, activity_introduction, activity.version, activity.gmt_create, activity.gmt_modified
select activity.activity_id, activity_name, activity_type, activity_introduction, min_people, max_people,activity.version, activity.gmt_create, activity.gmt_modified
from social_practice_sys.activity,social_practice_sys.user,social_practice_sys.manage
where activity.is_delete=0 and user.user_id=#{userId} and user.user_id=manage.user_id and manage.activity_id=activity.activity_id
</select>
<select id="getActivityByStudent" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity">
select activity.activity_id, activity_name, activity_type, activity_introduction, activity.version, activity.gmt_create, activity.gmt_modified
select activity.activity_id, activity_name, activity_type, activity_introduction, min_people, max_people, activity.version, activity.gmt_create, activity.gmt_modified
from activity,participate,user
where user.user_id=#{userId} and activity.activity_id=participate.activity_id and user.user_id=participate.user_id and activity.is_delete=0
</select>
@ -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
</select>
<select id="getActivities" resultType="com.peteralbus.entity.Activity">
select activity.activity_id, activity_name, activity_type, activity_introduction, activity.version, activity.gmt_create, activity.gmt_modified
from activity
where activity.is_delete=0
</select>
<select id="getCount" resultType="int">
select count(*) from social_practice_sys.activity
</select>

@ -0,0 +1,3 @@
.button-group{
float: right;
}

@ -26,7 +26,7 @@
<div id="app">
<el-dialog
v-model="dialogVisible"
title="Tips"
title="查看详情"
>
<div style="text-align:center">
<el-descriptions
@ -35,7 +35,7 @@
border
>
<template #extra>
<el-button type="primary" size="small">参与活动</el-button>
<el-button type="primary" size="small" @click="toApply(showedActivity.activityId)">申请参与活动</el-button>
</template>
<el-descriptions-item>
<template #label>
@ -59,7 +59,7 @@
</div>
<br/>
<div>
<el-descriptions :column="1" border>
<el-descriptions :column="1" border direction="vertical">
<el-descriptions-item>
<template #label>
简介
@ -68,13 +68,6 @@
</el-descriptions-item>
</el-descriptions>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">Cancel</el-button>
<el-button type="primary" @click="dialogVisible = false"
>Confirm</el-button>
</span>
</template>
</el-dialog>
<header>
<%@ include file="/jsp/header.html" %>
@ -242,6 +235,9 @@
this.showedActivity=this.allActivitiesResult[index];
this.dialogVisible=true
},
toApply(id){
location.href="/student/applyActivity?activityId="+id
}
}
};
const app = Vue.createApp(App);

@ -0,0 +1,170 @@
<%--
Created by IntelliJ IDEA.
User: peteralbus
Date: 2021/12/18
Time: 16:30
To change this template use File | Settings | File Templates.
--%>
<%@ 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>
<title>申请参加活动</title>
<!-- 导入 Vue 3 -->
<script src="${pageContext.request.contextPath}/vue/vue@next/vue.global.js"></script>
<!-- 导入组件库 -->
<script src="${pageContext.request.contextPath}/vue/element/index.full.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">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/student/applyActivity.css">
<link rel="stylesheet" href="//unpkg.com/element-plus@1.1.0-beta.9/dist/index.css" />
</head>
<body>
<div id="app">
<header>
<%@ include file="/jsp/header.html" %>
</header>
<div class="main">
<div class="container">
<el-container>
<el-aside width="80px">
<%@ include file="/jsp/aside.html" %>
</el-aside>
<el-main>
<el-page-header icon="el-icon-arrow-left" :content="title" @back="goBack"></el-page-header>
<br/>
<div class="container">
<el-steps :active="0" 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>
<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-divider content-position="left">申请参加</el-divider>
<div>
<el-form ref="apply" :model="form">
<el-form-item label="参加方式">
<el-radio-group v-model="form.isNewGroup">
<el-radio :label="true">作为小组长创建小组</el-radio>
<el-radio :label="false">加入已创建的小组</el-radio>
</el-radio-group>
</el-form-item>
<el-row v-if="form.isNewGroup">
<el-col :span="12">
<el-form-item label="小组名称" >
<el-input v-model="form.groupName"></el-input>
</el-form-item>
</el-col>
</el-row>
<div class="button-group">
<el-button type="primary">创建小组并参加活动</el-button>
</div>
</el-form>
</div>
</div>
</el-main>
</el-container>
</div>
</div>
<footer>
<%@ include file="/jsp/foot.html" %>
</footer>
</div>
<script>
const App = {
data() {
return{
title:'申请参加活动',
user:{
username:'',
realName:'',
avatarSrc: ''
},
form:{
isNewGroup:true,
group:{},
groupId:0
},
activity:{
activityId: '${activity.getActivityId()}',
activityName: '${activity.getActivityName()}',
activityType:'${activity.getActivityType()}',
activityIntroduction:'${activity.getActivityIntroduction()}',
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'
}
},
mounted(){
this.user.realName='${realName}'
this.user.username='${username}'
this.user.avatarSrc='${avatarSrc}'
},
methods: {
goBack(){
window.history.go(-1);
}
}
};
const app = Vue.createApp(App);
app.use(ElementPlus);
app.mount("#app");
</script>
</body>
</html>

@ -65,6 +65,9 @@
<el-form-item label="活动介绍" prop="activityIntroduction">
<el-input type="textarea" :rows="10" v-model="form.activityIntroduction"></el-input>
</el-form-item>
<el-form-item label="参加人数">
<el-slider v-model="range" range :max="50" :min="1"> </el-slider>
</el-form-item>
<el-form-item label="" label-width="80px">
<el-button type="primary" @click="submit('form')" :loading="loading">提交</el-button>
<el-button>取消</el-button>
@ -87,7 +90,17 @@
</el-card>
</div>
<el-divider content-position="left">所有活动</el-divider>
<div class="activity-list-card" v-for="item in allActivitiesResult">
<div style="text-align: center">
<el-pagination
background
layout="total, sizes ,prev, pager, next, jumper"
:total="allActivitiesResult.length"
:page-sizes="[5, 10, 20, 40]"
v-model:page-size="pageSize"
v-model:current-page="currentPage">
</el-pagination>
</div>
<div class="activity-list-card" v-for="item in currentPageAllActivities">
<el-card class="box-card" shadow="hover">
<template #header>
<div class="card-header">
@ -124,8 +137,11 @@
form: {
activityName: '',
activityType: '',
activityIntroduction: ''
activityIntroduction: '',
minPeople:1,
maxPeople:12
},
range:[1,12],
rules: {
activityName: [
{ required: true, message: '请填写活动名称', trigger: 'blur' }
@ -141,6 +157,8 @@
keyWord:'',
activityList:[],
allActivities:[],
currentPage:1,
pageSize:5,
loading:false,
showAddActivityForm:false
}
@ -221,6 +239,9 @@
}
}
return result;
},
currentPageAllActivities:function (){
return this.allActivitiesResult.slice((this.currentPage-1)*this.pageSize,this.currentPage*this.pageSize)
}
},
methods: {
@ -231,6 +252,8 @@
this.$refs[name].validate((valid) => {
if (valid) {
this.loading=true
this.form.minPeople=this.range[0]
this.form.maxPeople=this.range[1]
axios({
method: "post",
url: "/teacher/addActivity",

@ -67,7 +67,7 @@
</div>
<br/>
<div>
<el-descriptions :column="1" border>
<el-descriptions :column="1" border direction="vertical">
<el-descriptions-item>
<template #label>
简介

Loading…
Cancel
Save