Add admin page,now admin can restore activity.Fix the bug that version didn't work in Class:Activity.

DEV
PeterAlbus 3 years ago
parent 8046e1ec63
commit 7ac57ac0d9

@ -1,9 +1,16 @@
package com.peteralbus.controller;
import com.peteralbus.entity.Activity;
import com.peteralbus.service.ActivityService;
import com.peteralbus.util.PrincipalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* The type Admin controller.
*
@ -13,15 +20,25 @@ import org.springframework.web.servlet.ModelAndView;
@RequestMapping("/admin")
public class AdminController
{
/**
* Admin home page model and view.
*
* @return the model and view
*/
@RequestMapping("/index")
public ModelAndView adminHomePage()
@Autowired
ActivityService activityService;
@RequestMapping("/activities")
public ModelAndView activities()
{
return new ModelAndView("/jsp/admin/home.jsp");
ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView();
List<Activity> activityList=activityService.adminActivityList();
modelAndView.addObject("activityList",activityList);
modelAndView.setViewName("/jsp/admin/activities.jsp");
return modelAndView;
}
@ResponseBody
@RequestMapping("/restoreActivity")
public String restoreActivity(Long activityId)
{
if(activityService.restore(activityId)>0)
{
return "success";
}
return "error";
}
}

@ -39,6 +39,21 @@ public interface ActivityDao extends BaseMapper<Activity>
*/
List<User> getTeacherList(Long activityId);
/**
* Admin activity list list.
*
* @return the list
*/
List<Activity> adminActivityList();
/**
* Restore int.
*
* @param activityId the activity id
* @return the int
*/
int restore(Long activityId);
/**
* Gets count.
*

@ -6,9 +6,17 @@ import org.apache.ibatis.annotations.Mapper;
/**
* The interface Group dao.
*
* @author PeterAlbus
*/
@Mapper
public interface GroupDao extends BaseMapper<Group>
{
/**
* Restore int.
*
* @param activityId the activity id
* @return the int
*/
int restore(Long activityId);
}

@ -11,4 +11,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ManageDao extends BaseMapper<Manage>
{
/**
* Restore int.
*
* @param activityId the activity id
* @return the int
*/
int restore(Long activityId);
}

@ -11,4 +11,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ParticipateDao extends BaseMapper<Participate>
{
/**
* Restore int.
*
* @param activityId the activity id
* @return the int
*/
int restore(Long activityId);
}

@ -11,4 +11,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RecordDao extends BaseMapper<Record>
{
/**
* Restore int.
*
* @param participationId the participation id
* @return the int
*/
int restore(Long participationId);
}

@ -57,7 +57,13 @@ public class ActivityService
*/
public int updateActivity(Activity activity)
{
return activityDao.updateById(activity);
Activity old=activityDao.selectById(activity.getActivityId());
old.setActivityName(activity.getActivityName());
old.setActivityType(activity.getActivityType());
old.setActivityIntroduction(activity.getActivityIntroduction());
old.setMaxPeople(activity.getMaxPeople());
old.setMinPeople(activity.getMinPeople());
return activityDao.updateById(old);
}
/**
@ -186,4 +192,26 @@ public class ActivityService
result=activityDao.deleteById(activityId);
return result;
}
public List<Activity> adminActivityList()
{
return activityDao.adminActivityList();
}
public int restore(Long activityId)
{
int result=0;
result=activityDao.restore(activityId);
manageDao.restore(activityId);
groupDao.restore(activityId);
participateDao.restore(activityId);
QueryWrapper<Participate> participateQueryWrapper=new QueryWrapper<>();
participateQueryWrapper.eq("activity_id",activityId);
List<Participate> participateList=participateDao.selectList(participateQueryWrapper);
for(Participate participate:participateList)
{
recordDao.restore(participate.getParticipationId());
}
return result;
}
}

@ -17,6 +17,12 @@
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="adminActivityList" resultType="activity">
select * from activity
</select>
<update id="restore" parameterType="long">
update activity set is_delete=0 where activity_id=#{activityId}
</update>
<select id="getCount" resultType="int">
select count(*) from social_practice_sys.activity
</select>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peteralbus.dao.GroupDao">
<update id="restore" parameterType="long">
update `group` set is_delete=0 where activity_id=#{activityId}
</update>
</mapper>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peteralbus.dao.ManageDao">
<update id="restore" parameterType="long">
update manage set is_delete=0 where activity_id=#{activityId}
</update>
</mapper>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peteralbus.dao.ParticipateDao">
<update id="restore" parameterType="long">
update participate set is_delete=0 where activity_id=#{activityId}
</update>
</mapper>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.peteralbus.dao.RecordDao">
<update id="restore" parameterType="long">
update record set is_delete=0 where participation_id=#{participationId}
</update>
</mapper>

@ -31,3 +31,7 @@ body{
align-items: center;
justify-content:center;
}
.el-table .warning-row {
--el-table-tr-bg-color: var(--el-color-warning-lighter);
}

@ -0,0 +1,222 @@
<%--
Created by IntelliJ IDEA.
User: peteralbus
Date: 2021/12/21
Time: 18:13
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>
<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">
<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 style="text-align: center">
<el-pagination
background
layout="total, sizes ,prev, pager, next, jumper"
:total="activityListResult.length"
:page-sizes="[5, 10, 20, 40]"
v-model:page-size="pageSize"
v-model:current-page="currentPage">
</el-pagination>
</div>
<div>
<el-table
:data="currentPageActivities"
style="width: 100%"
>
<el-table-column label="活动ID" fixed width="250">
<template #default="scope">
{{scope.row.activityId}}
<el-tag v-if="scope.row.isDelete=='1'" type="danger" size="mini">已删除</el-tag>
</template>
</el-table-column>
<el-table-column prop="activityName" label="活动名" width="250"></el-table-column>
<el-table-column prop="activityType" label="活动类型"></el-table-column>
<el-table-column label="活动介绍">
<template #default="scope">
<el-popover effect="light" trigger="hover" placement="top">
<template #default>
<p>{{ scope.row.activityIntroduction }}</p>
</template>
<template #reference>
<el-tag size="medium">悬浮查看</el-tag>
</template>
</el-popover>
</template>
</el-table-column>
<el-table-column prop="minPeople" label="最小人数"></el-table-column>
<el-table-column prop="maxPeople" label="最大人数"></el-table-column>
<el-table-column prop="version" label="版本"></el-table-column>
<el-table-column prop="gmtCreate" label="创建时间" width="250"></el-table-column>
<el-table-column prop="gmtModified" label="上次更改" width="250"></el-table-column>
<el-table-column prop="isDelete" label="是否删除"></el-table-column>
<el-table-column align="right" fixed="right" width="100">
<template #header>
<el-input v-model="keyWord" size="mini" placeholder="搜索活动名"></el-input>
</template>
<template #default="scope">
<el-button size="mini" @click="restore(scope.row.activityId)" v-if="scope.row.isDelete=='1'" type="success">恢复</el-button>
<el-button size="mini" @click="deleteAct(scope.row.activityId)" v-if="scope.row.isDelete!='1'" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</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: ''
},
keyWord:'',
currentPage:1,
pageSize:10,
activityList:[
<c:forEach items="${activityList}" var="activity">
{
activityId: '${activity.getActivityId()}',
activityName: '${activity.getActivityName()}',
activityType:'${activity.getActivityType()}',
activityIntroduction:'${activity.getActivityIntroduction()}',
minPeople:'${activity.getMinPeople()}',
maxPeople:'${activity.getMaxPeople()}',
version:'${activity.getVersion()}',
gmtCreate:'${activity.getFormattedCreateDate()}',
gmtModified:'${activity.getGmtModified()}',
isDelete:'${activity.getIsDelete()}'
},
</c:forEach>
],
activeIndex:'4'
}
},
mounted(){
this.user.realName='${realName}'
this.user.username='${username}'
this.user.avatarSrc='${avatarSrc}'
},
methods: {
goBack(){
window.history.go(-1);
},
restore(id){
this.$messageBox.confirm(
'确认要恢复这个被删除的社会实践活动吗?',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
axios({
method: "get",
url: "/admin/restoreActivity?activityId="+id,
}).then(res=>{
if(res.data==="error")
{
this.$message.error('恢复失败!')
}
else
{
location.reload()
}
})
})
},
deleteAct(id){
this.$messageBox.confirm(
'确认要删除社会实践活动吗,请与老师联系确认!',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
axios({
method: "get",
url: "/teacher/deleteActivity?activityId="+id,
}).then(res=>{
if(res.data==="error")
{
this.$message.error('删除失败!')
}
else
{
location.reload()
}
})
})
}
},
computed:{
activityListResult:function (){
let result=[];
if(this.keyWord==='')
{
return this.activityList;
}
for(let i=0;i<this.activityList.length;i++)
{
let str=this.activityList[i].activityName;
let str_leader=this.activityList[i].activityIntroduction;
if(str.search(this.keyWord)!==-1||str_leader.search(this.keyWord)!==-1)
{
result.push(this.activityList[i]);
}
}
return result;
},
currentPageActivities:function (){
return this.activityListResult.slice((this.currentPage-1)*this.pageSize,this.currentPage*this.pageSize)
}
}
};
const app = Vue.createApp(App);
app.use(ElementPlus);
app.mount("#app");
</script>
</body>
</html>

@ -21,6 +21,12 @@
<template #title>活动列表</template>
</el-menu-item>
</shiro:hasRole>
<shiro:hasRole name="admin">
<el-menu-item index="4" onclick="location.href='/admin/activities'">
<i class="el-icon-s-data"></i>
<template #title>活动列表</template>
</el-menu-item>
</shiro:hasRole>
<el-menu-item index="9">
<i class="el-icon-document"></i>
<template #title>Navigator Three</template>

@ -202,7 +202,7 @@
},
newGroup(){
this.$messageBox.confirm(
'参与社会实践活动后不可更改小组,不可退出,确认申请?',
'担任组长意味着责任,若还有组员,不可退出活动,确认申请?',
'警告',
{
confirmButtonText: '确认',
@ -236,7 +236,7 @@
},
joinGroup(id){
this.$messageBox.confirm(
'参与社会实践活动后不可更改小组,不可退出,确认申请',
'确认申请该小组参与社会实践活动?',
'警告',
{
confirmButtonText: '确认',

@ -58,9 +58,9 @@
border
>
<template #extra>
<el-button type="success" size="mini" @click="dialogVisible=true" v-if="!isScored">评分</el-button>
<el-button type="success" size="mini" @click="dialogVisible=true" v-if="!isScored&&(activity.minPeople<=group.memberCount)">评分</el-button>&emsp;
<el-tag type="success" v-if="isFinished">该小组已完成社会实践</el-tag>
<el-tag type="danger" v-if="activity.minPeople>group.memberCount">该小组人数尚未达标</el-tag>
<el-tag type="danger" v-if="activity.minPeople>group.memberCount" size="small">该小组人数尚未达标</el-tag>
<el-link href="#record" type="primary">日志管理<i class="el-icon-arrow-down"></i></el-link>&emsp;
<el-link href="#groupMember" type="primary">小组成员<i class="el-icon-arrow-down"></i></el-link>
</template>

Loading…
Cancel
Save