finished the modules of join and create group.

DEV
PeterAlbus 3 years ago
parent c00885a59b
commit ebaba909f0

@ -56,8 +56,7 @@ public class StudentController
Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId); Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId);
if(participate!=null) if(participate!=null)
{ {
modelAndView.setViewName("redirect: /student/manageActivity?activityId="+activityId); return new ModelAndView("redirect: /student/manageActivity?activityId="+activityId);
return modelAndView;
} }
modelAndView.addObject("activity",activity); modelAndView.addObject("activity",activity);
List<Group> groupList=groupService.getGroupListByActivity(activityId); List<Group> groupList=groupService.getGroupListByActivity(activityId);
@ -71,34 +70,61 @@ public class StudentController
ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView(); ModelAndView modelAndView=PrincipalUtil.getBasicModelAndView();
Subject subject = SecurityUtils.getSubject(); Subject subject = SecurityUtils.getSubject();
User user=(User)subject.getPrincipal(); User user=(User)subject.getPrincipal();
modelAndView.addObject("userId",user.getUserId());
Activity activity= activityService.getActivityById(activityId); Activity activity= activityService.getActivityById(activityId);
Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId); Participate participate=participateService.getByUserAndActivity(user.getUserId(), activityId);
if(participate==null) if(participate==null)
{ {
throw new UnauthorizedException(); throw new UnauthorizedException();
} }
Long memberCount=groupService.getMemberCount(participate.getGroupId()); Group group=groupService.getById(participate.getGroupId());
if(memberCount<=activity.getMinPeople()) Long memberCount=groupService.getMemberCount(group.getGroupId());
List<Participate> memberList=groupService.getGroupMember(group.getGroupId());
modelAndView.addObject("group",group);
modelAndView.addObject("memberList",memberList);
if(participate.getAccept())
{ {
if(participate.getAccept()) if(memberCount<activity.getMinPeople())
{ {
modelAndView.addObject("currentStatus","正在等待小组成员数量达到要求"); modelAndView.addObject("currentStatus","正在等待小组成员数量达到要求");
modelAndView.setViewName("/jsp/student/waitGroup.jsp");
} }
else else
{ {
modelAndView.addObject("currentStatus","正在等待组长通过您的申请"); modelAndView.setViewName("/jsp/student/manageActivity.jsp");
} }
modelAndView.setViewName("/jsp/student/waitGroup.jsp");
} }
else else
{ {
modelAndView.setViewName("/jsp/student/manageActivity.jsp"); modelAndView.addObject("currentStatus","正在等待组长通过您的申请");
modelAndView.setViewName("/jsp/student/waitGroup.jsp");
} }
modelAndView.addObject("activity",activity); modelAndView.addObject("activity",activity);
return modelAndView; return modelAndView;
} }
@ResponseBody @ResponseBody
@RequestMapping("/acceptJoin")
public String acceptJoin(Long participateId)
{
int result=participateService.acceptJoin(participateId);
if(result<=0)
{
return "error";
}
return "success";
}
@ResponseBody
@RequestMapping("/refuseJoin")
public String refuseJoin(Long participateId)
{
int result=participateService.refuseJoin(participateId);
if(result<=0)
{
return "error";
}
return "success";
}
@ResponseBody
@RequestMapping("/participateWithNewGroup") @RequestMapping("/participateWithNewGroup")
public String participateWithNewGroup(Group group) public String participateWithNewGroup(Group group)
{ {

@ -21,6 +21,8 @@ public class Group implements Serializable
private Long leaderId; private Long leaderId;
@TableField(exist = false) @TableField(exist = false)
private String leaderName; private String leaderName;
@TableField(exist = false)
public Long memberCount;
private Long activityId; private Long activityId;
@Version @Version
private Integer version; private Integer version;
@ -130,6 +132,16 @@ public class Group implements Serializable
this.leaderName = leaderName; this.leaderName = leaderName;
} }
public Long getMemberCount()
{
return memberCount;
}
public void setMemberCount(Long memberCount)
{
this.memberCount = memberCount;
}
@Override @Override
public String toString() public String toString()
{ {

@ -17,6 +17,10 @@ public class Participate implements Serializable
@TableId(type= IdType.ASSIGN_ID) @TableId(type= IdType.ASSIGN_ID)
private Long participationId; private Long participationId;
private Long userId; private Long userId;
@TableField(exist = false)
private String username;
@TableField(exist = false)
private String realName;
private Long activityId; private Long activityId;
private Long groupId; private Long groupId;
private Boolean isFinished; private Boolean isFinished;
@ -134,6 +138,26 @@ public class Participate implements Serializable
isAccept = accept; isAccept = accept;
} }
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getRealName()
{
return realName;
}
public void setRealName(String realName)
{
this.realName = realName;
}
@Override @Override
public String toString() public String toString()
{ {

@ -10,6 +10,7 @@ import com.peteralbus.entity.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -39,7 +40,11 @@ public class GroupService
} }
public Group getById(Long groupId) public Group getById(Long groupId)
{ {
return groupDao.selectById(groupId); Group group=groupDao.selectById(groupId);
User user=userDao.selectById(group.getLeaderId());
group.setLeaderName(user.getRealName());
group.setMemberCount(getMemberCount(groupId));
return group;
} }
public Long getMemberCount(Long groupId) public Long getMemberCount(Long groupId)
{ {
@ -48,6 +53,19 @@ public class GroupService
queryWrapper.eq("is_accept",true); queryWrapper.eq("is_accept",true);
return participateDao.selectCount(queryWrapper); return participateDao.selectCount(queryWrapper);
} }
public List<Participate> getGroupMember(Long groupId)
{
QueryWrapper<Participate> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("group_id",groupId);
List<Participate> memberList=participateDao.selectList(queryWrapper);
for(Participate participate:memberList)
{
User user= userDao.selectById(participate.getUserId());
participate.setUsername(user.getUsername());
participate.setRealName(user.getRealName());
}
return memberList;
}
public int insertGroup(Group group) public int insertGroup(Group group)
{ {
return groupDao.insert(group); return groupDao.insert(group);

@ -7,6 +7,7 @@ import com.peteralbus.entity.Group;
import com.peteralbus.entity.Participate; import com.peteralbus.entity.Participate;
import com.peteralbus.entity.User; import com.peteralbus.entity.User;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -59,4 +60,33 @@ public class ParticipateService
participate.setAccept(false); participate.setAccept(false);
return participateDao.insert(participate); return participateDao.insert(participate);
} }
public int acceptJoin(Long participateId)
{
Participate participate=participateDao.selectById(participateId);
Subject subject = SecurityUtils.getSubject();
User user=(User)subject.getPrincipal();
if(groupDao.selectById(participate.getGroupId()).getLeaderId().equals(user.getUserId()))
{
participate.setAccept(true);
return participateDao.updateById(participate);
}
else
{
throw new UnauthorizedException();
}
}
public int refuseJoin(Long participateId)
{
Participate participate=participateDao.selectById(participateId);
Subject subject = SecurityUtils.getSubject();
User user=(User)subject.getPrincipal();
if(groupDao.selectById(participate.getGroupId()).getLeaderId().equals(user.getUserId()))
{
return participateDao.deleteById(participate);
}
else
{
throw new UnauthorizedException();
}
}
} }

@ -6,12 +6,12 @@
<select id="getActivityByTeacher" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity"> <select id="getActivityByTeacher" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity">
select activity.activity_id, activity_name, activity_type, activity_introduction, min_people, max_people,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 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 where activity.is_delete=0 and user.user_id=#{userId} and user.user_id=manage.user_id and manage.activity_id=activity.activity_id and manage.is_delete=0
</select> </select>
<select id="getActivityByStudent" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity"> <select id="getActivityByStudent" parameterType="java.lang.Long" resultType="com.peteralbus.entity.Activity">
select activity.activity_id, activity_name, activity_type, activity_introduction, min_people, max_people, 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 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 where user.user_id=#{userId} and activity.activity_id=participate.activity_id and user.user_id=participate.user_id and activity.is_delete=0 and participate.is_delete=0
</select> </select>
<select id="getTeacherList" parameterType="java.lang.Long" resultType="com.peteralbus.entity.User"> <select id="getTeacherList" parameterType="java.lang.Long" resultType="com.peteralbus.entity.User">
select user.user_id,username,real_name,user_phone,avatar_src from activity,user,manage select user.user_id,username,real_name,user_phone,avatar_src from activity,user,manage

@ -16,6 +16,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">
@ -96,6 +98,26 @@
:sub-title="currentStatus" :sub-title="currentStatus"
> >
</el-result> </el-result>
<div>
<el-descriptions title="小组信息" border>
<el-descriptions-item label="小组名">{{group.groupName}}</el-descriptions-item>
<el-descriptions-item label="组长姓名">{{group.leaderName}}</el-descriptions-item>
<el-descriptions-item label="已加入组员数">{{group.memberCount}}</el-descriptions-item>
</el-descriptions>
<h4>成员信息</h4>
<el-table :data="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-button size="mini" @click="accept(scope.row.participateId)" v-if="(!scope.row.isAccept)&&user.userId==group.leaderId">通过</el-button>
<el-button size="mini" @click="refuse(scope.row.participateId)" v-if="(!scope.row.isAccept)&&user.userId==group.leaderId" type="danger">拒绝</el-button>
<el-tag type="success" v-if="scope.row.isAccept">已通过</el-tag>
<el-tag type="info" v-if="(!scope.row.isAccept)&&user.userId!=group.leaderId">审核中</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</div> </div>
</el-main> </el-main>
</el-container> </el-container>
@ -113,7 +135,8 @@
user:{ user:{
username:'', username:'',
realName:'', realName:'',
avatarSrc: '' avatarSrc: '',
userId:''
}, },
currentStatus:'${currentStatus}', currentStatus:'${currentStatus}',
activity:{ activity:{
@ -136,6 +159,24 @@
</c:forEach> </c:forEach>
] ]
}, },
group:{
groupId:'${group.getGroupId()}',
groupName:'${group.getGroupName()}',
leaderId:'${group.getLeaderId()}',
leaderName: '${group.getLeaderName()}',
memberCount: '${group.getMemberCount()}'
},
memberList:[
<c:forEach items="${memberList}" var="member">
{
participateId:'${member.getParticipationId()}',
userId:'${member.getUserId()}',
username:'${member.getUsername()}',
realName:'${member.getRealName()}',
isAccept:${member.getAccept()}
},
</c:forEach>
],
activeIndex:'3' activeIndex:'3'
} }
}, },
@ -143,10 +184,71 @@
this.user.realName='${realName}' this.user.realName='${realName}'
this.user.username='${username}' this.user.username='${username}'
this.user.avatarSrc='${avatarSrc}' this.user.avatarSrc='${avatarSrc}'
this.user.userId='${userId}'
}, },
methods: { methods: {
goBack(){ goBack(){
window.history.go(-1); window.history.go(-1);
},
accept(id){
this.$messageBox.confirm(
'小组成员加入后,不可再抛弃了哦,确认通过申请?',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
axios({
method: "get",
url: "/student/acceptJoin?participateId="+id,
})
.then(res => {
if(res.data==="success")
{
location.reload();
}
else
{
this.$message.error("出现异常,通过失败")
}
})
.catch(res=>{
this.$message.error("出现异常,通过失败")
})
})
},
refuse(id){
this.$messageBox.confirm(
'确认要拒绝该同学的申请吗?',
'警告',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
axios({
method: "get",
url: "/student/refuseJoin?participateId="+id,
})
.then(res => {
if(res.data==="success")
{
location.reload();
}
else
{
this.$message.error("出现异常,拒绝失败")
}
})
.catch(res=>{
this.$message.error("出现异常,拒绝失败")
})
})
} }
} }
}; };

Loading…
Cancel
Save