开发工具:IDEA,jdk1.8
数据库:mysql5.7
技术:springboot+freemark+jpa
前台:
1、社团信息浏览搜索、社团活动风采、新闻信息浏览搜索。
2、学生注册登录。
3、登录后可自己申请创建社团,也可申请加入其他社团活动。
4、管理自己社团的申请人员。
5个人信息修改及留言等。
后台:社团审核管理、活动新闻管理、学生管理、留言管理、活动申请审核、活动经费管理等等。
前台截图:
后台截图:
package com.jinku.jsj.springboot.controller.admin;
import com.jinku.jsj.springboot.bean.CodeMsg;
import com.jinku.jsj.springboot.bean.PageBean;
import com.jinku.jsj.springboot.bean.Result;
import com.jinku.jsj.springboot.constant.SessionConstant;
import com.jinku.jsj.springboot.entity.admin.User;
import com.jinku.jsj.springboot.entity.common.Activities;
import com.jinku.jsj.springboot.service.admin.OperaterLogService;
import com.jinku.jsj.springboot.service.common.ActivitiesService;
import com.jinku.jsj.springboot.service.common.AssociationService;
import com.jinku.jsj.springboot.service.common.NewsService;
import com.jinku.jsj.springboot.util.ValidateEntityUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;
/**
* 社团活动管理
*/
@RequestMapping("/admin/activities")
@Controller
public class ActivitiesController {
@Autowired
private NewsService newsService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private AssociationService associationService;
@Autowired
private ActivitiesService activitiesService;
@RequestMapping(value = "/list")
public String list(Model model, PageBean pageBean, Activities activities
) {
model.addAttribute("pageBean", activitiesService.findList(activities, pageBean));
model.addAttribute("title", "社团活动列表");
model.addAttribute("activitiesTitle",activities.getTitle()==null?null:activities.getTitle());
//这里要把社团查询出来并返回给页面
model.addAttribute("associations", associationService.findAll());
model.addAttribute("auditStatus",activities.getIsAudit());
model.addAttribute("teamId",activities.getBelonTeam());
return "admin/activities/list";
}
/**
* 社团活动添加页面
*
* @param model
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model) {
//这里要把社团查询出来并返回给页面
model.addAttribute("associations",associationService.findAll());
model.addAttribute("title","社团活动列表");
return "admin/activities/add";
}
/**
* 社团活动添加
*
* @param model
* @param activities
* @return at wjk
*/
@ResponseBody
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result add(Model model, Activities activities, HttpServletRequest request) {
//检查活动标题是否已存在
Activities byTitle = activitiesService.findByTitle(activities.getTitle());
if(byTitle!=null){
return Result.error(CodeMsg.ADMIN_ACTIVITIES_EXIST_ERROR);
}
//比较两日期大小
Date actStartTime = activities.getActStartTime();
Date actEndTime = activities.getActEndTime();
boolean before = actStartTime.before(actEndTime);
if(!before){
return Result.error(CodeMsg.ADMIN_ACTIVITIES_DATE_ERROR);
}
HttpSession session = request.getSession();
User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(activities);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
activities.setCreateUser(user.getUsername());
if (activitiesService.save(activities) == null) {
return Result.error(CodeMsg.ADMIN_ACTIVITIES_ADD_ERROR);
}
operaterLogService.add("添加活动,活动标题:" + activities.getTitle());
return Result.success(true);
}
/**
* 社团活动编辑页面
*
* @param model
* @param id
* @return
*/
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String edit(Model model, @RequestParam(name = "id", required = true) Long id) {
//这里要把社团查询出来并返回给页面
model.addAttribute("associations", associationService.findAll());
model.addAttribute("activities", activitiesService.find(id));
return "admin/activities/edit";
}
/**
* 编辑社团活动
* @param activities
* @return
*/
@ResponseBody
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public Result edit(Activities activities,HttpServletRequest request) {
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(activities);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
//将提交的用户信息指定字段复制到已存在的user对象中
Activities findbyId = activitiesService.find(activities.getId());
HttpSession session = request.getSession();
User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
activities.setCreateUser(user.getUsername());
//把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
BeanUtils.copyProperties(activities, findbyId, "id", "createTime", "updateTime");
//到这说明一切通过 开始进行数据库编辑
if (activitiesService.save(findbyId) == null) {
return Result.error(CodeMsg.ADMIN_ACTIVITIES_EDIT_ERROR);
}
operaterLogService.add("编辑活动,活动标题:" + activities.getTitle());
return Result.success(true);
}
/**
* 社团活动删除
* @param ids
* @return
*/
@ResponseBody
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public Result delete(@RequestParam(name = "ids", required = true) String ids) {
if (!StringUtils.isEmpty(ids)) {
String[] splitIds = ids.split(",");
for (String id : splitIds) {
Activities activities = activitiesService.find(Long.valueOf(id));
if (activities != null) {
try {
activitiesService.delete(Long.valueOf(id));
operaterLogService.add("删除社团活动,id为:" + id);
}catch (Exception e){
return Result.error(CodeMsg.ADMIN_ACTIVITIES_DELETE_ERROR);
}
}
}
}
return Result.success(true);
}
}
package com.jinku.jsj.springboot.controller.admin; import com.jinku.jsj.springboot.bean.CodeMsg; import com.jinku.jsj.springboot.bean.PageBean; import com.jinku.jsj.springboot.bean.Result; import com.jinku.jsj.springboot.constant.SessionConstant; import com.jinku.jsj.springboot.entity.admin.User; import com.jinku.jsj.springboot.entity.common.SiteNews; import com.jinku.jsj.springboot.service.admin.OperaterLogService; import com.jinku.jsj.springboot.service.common.AssociationService; import com.jinku.jsj.springboot.service.common.NewsService; import com.jinku.jsj.springboot.util.ValidateEntityUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * 新闻管理 */ @RequestMapping("/admin/news") @Controller public class NewsController { @Autowired private NewsService newsService; @Autowired private OperaterLogService operaterLogService; @Autowired private AssociationService associationService; @RequestMapping(value = "/list") public String list(Model model, PageBeanpageBean, SiteNews siteNews) { model.addAttribute("pageBean", newsService.findList(siteNews, pageBean)); model.addAttribute("isAudit",siteNews.getIsAudit()); model.addAttribute("title", "新闻列表"); model.addAttribute("newsTitle",siteNews.getTitle()==null?null:siteNews.getTitle()); model.addAttribute("teamId",siteNews.getBelonTeam()); //这里要把社团查询出来并返回给页面 model.addAttribute("associations", associationService.findAll()); return "admin/news/list"; } /** * 新闻添加页面 * * @param model * @return */ @RequestMapping(value = "/add", method = RequestMethod.GET) public String add(Model model) { //这里要把社团查询出来并返回给页面 model.addAttribute("associations",associationService.findAll()); return "admin/news/add"; } /** * 新闻添加 * * @param model * @param siteNews * @return at wjk */ @ResponseBody @RequestMapping(value = "/add", method = RequestMethod.POST) public Result add(Model model, SiteNews siteNews, HttpServletRequest request) { HttpSession session = request.getSession(); User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY); //用统一验证实体方法验证是否合法 CodeMsg validate = ValidateEntityUtil.validate(siteNews); if (validate.getCode() != CodeMsg.SUCCESS.getCode()) { return Result.error(validate); } siteNews.setCreateUser(user.getUsername()); if (newsService.save(siteNews) == null) { return Result.error(CodeMsg.ADMIN_NEWS_ADD_ERROR); } operaterLogService.add("添加新闻,新闻标题:" + siteNews.getTitle()); return Result.success(true); } /** * 新闻编辑页面 * * @param model * @param id * @return */ @RequestMapping(value = "/edit", method = RequestMethod.GET) public String edit(Model model, @RequestParam(name = "id", required = true) Long id) { //这里要把社团查询出来并返回给页面 model.addAttribute("associations", associationService.findAll()); model.addAttribute("news", newsService.find(id)); return "admin/news/edit"; } /** * 新闻编辑 * * @param siteNews * @return */ @ResponseBody @RequestMapping(value = "/edit", method = RequestMethod.POST) public Result edit(SiteNews siteNews) { //用统一验证实体方法验证是否合法 CodeMsg validate = ValidateEntityUtil.validate(siteNews); if (validate.getCode() != CodeMsg.SUCCESS.getCode()) { return Result.error(validate); } //将提交的用户信息指定字段复制到已存在的user对象中 SiteNews findbyId = newsService.find(siteNews.getId()); //把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容 BeanUtils.copyProperties(siteNews, findbyId, "id", "createTime", "updateTime", "createUser"); //到这说明一切通过 开始进行数据库编辑 if (newsService.save(findbyId) == null) { return Result.error(CodeMsg.ADMIN_NEWS_EDIT_ERROR); } operaterLogService.add("编辑新闻,新闻标题:" + siteNews.getTitle()); return Result.success(true); } /** * 新闻删除 * @param ids * @return */ @ResponseBody @RequestMapping(value = "/delete", method = RequestMethod.POST) public Result delete(@RequestParam(name = "ids", required = true) String ids) { if (!StringUtils.isEmpty(ids)) { String[] splitIds = ids.split(","); for (String id : splitIds) { SiteNews siteNews = newsService.find(Long.valueOf(id)); if (siteNews != null) { try { newsService.delete(Long.valueOf(id)); operaterLogService.add("删除新闻,id为:" + id); }catch (Exception e){ return Result.error(CodeMsg.ADMIN_NEWS_DELETE_ERROR); } } } } return Result.success(true); } }