开发工具:IDEA,jdk1.8
数据库:mysql5.7
技术:springboot+freemark+jpa
前台:
1、社团信息浏览搜索、社团活动风采、新闻信息浏览搜索。
2、学生注册登录。
3、登录后可自己申请创建社团,也可申请加入其他社团活动。
4、管理自己社团的申请人员。
5个人信息修改及留言等。
后台:社团审核管理、活动新闻管理、学生管理、留言管理、活动申请审核、活动经费管理等等。
前台截图:
后台截图:
package com.jinku.jsj.springboot.controller.admin;
import com.aliyuncs.utils.StringUtils;
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.Message;
import com.jinku.jsj.springboot.service.admin.OperaterLogService;
import com.jinku.jsj.springboot.service.common.MessageService;
import com.jinku.jsj.springboot.service.common.NewsService;
import com.jinku.jsj.springboot.util.ValidateEntityUtil;
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/message")
@Controller
public class MessageController {
@Autowired
private MessageService messageService;
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private NewsService newsService;
@RequestMapping(value = "/list")
public String list(Model model, PageBean<Message> pageBean, Message message) {
model.addAttribute("pageBean", messageService.findList(message, pageBean));
model.addAttribute("sender",message.getSender()==null?null:message.getSender());
model.addAttribute("title", "留言列表");
model.addAttribute("auditStatus",message.getAuditStatus()==null?0:message.getAuditStatus());
return "admin/message/list";
}
/**
* 留言添加页面
*
* @param model
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(Model model) {
model.addAttribute("MessageTitle","留言列表");
return "admin/message/add";
}
/**
* 后台留言添加
*
* @param model
* @param message
* @return at wjk
*/
@ResponseBody
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<Boolean> add(Model model, Message message, HttpServletRequest request) {
HttpSession session = request.getSession();
User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(message);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
message.setSender(user.getUsername());
if (messageService.save(message) == null) {
return Result.error(CodeMsg.ADMIN_MESSAGE_ADD_ERROR);
}
operaterLogService.add("添加留言,留言人:" + message.getSender());
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("MessageTitle","留言列表");
model.addAttribute("message", messageService.find(id));
return "admin/message/edit";
}
/**
* 留言编辑
*
* @param message
* @return
*/
@ResponseBody
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public Result<Boolean> edit(Message message,HttpServletRequest request) {
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(message);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
HttpSession session = request.getSession();
User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
message.setReplyUser(user.getUsername());
//将提交的留言信息指定字段复制到已存在的message对象中
Message findbyId = messageService.find(message.getId());
//把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
BeanUtils.copyProperties(message, findbyId, "id", "createTime", "updateTime", "sender");
//到这说明一切通过 开始进行数据库编辑
if (messageService.save(findbyId) == null) {
return Result.error(CodeMsg.ADMIN_MESSAGE_EDIT_ERROR);
}
operaterLogService.add("编辑留言,留言人:" + findbyId.getSender());
return Result.success(true);
}
/**
* 留言删除
* @param ids
* @return
*/
@ResponseBody
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public Result<Boolean> delete(@RequestParam(name = "ids", required = true) String ids) {
if (!StringUtils.isEmpty(ids)) {
String[] splitIds = ids.split(",");
for (String id : splitIds) {
Message message = messageService.find(Long.valueOf(id));
if (message != null) {
try {
messageService.delete(Long.valueOf(id));
operaterLogService.add("删除留言,id为:" + id);
}catch (Exception e){
return Result.error(CodeMsg.ADMIN_MESSAGE_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.entity.home.Student;
import com.jinku.jsj.springboot.service.admin.OperaterLogService;
import com.jinku.jsj.springboot.service.home.StudentService;
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;
/**
@RequestMapping(“/admin/student/”)
@Controller
public class StudentController {
@Autowired
private StudentService studentService ;
@Autowired
private OperaterLogService operaterLogService;
/**
* 学生管理列表
* @param model
* @return
*/
@RequestMapping("/list")
public String list(Model model, Student student, PageBean pageBean){
model.addAttribute("pageBean",studentService.findList(student, pageBean));
model.addAttribute("studentLoginName",student.getLoginName());
model.addAttribute("title","学生列表");
return "/admin/student/list";
}
/**
* 后台学生添加页面
*/
@RequestMapping(value = "/add",method = RequestMethod.GET)
public String add(){
return "/admin/student/add";
}
/**
* 后台学生添加信息操作
*/
@ResponseBody
@RequestMapping(value = "/add",method = RequestMethod.POST)
public Result add(Model model,Student student){
CodeMsg validate = ValidateEntityUtil.validate(student);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
if(studentService.findByLoginName(student.getLoginName())!=null){
return Result.error(CodeMsg.ADMIN_STUDENT_ISEXIST_ERROR);
}
if(studentService.save(student)==null){
return Result.error(CodeMsg.ADMIN_STUDENT_ADD_ERROR);
}
return Result.success(true);
}
/**
* 编辑学生页面
* @param model
* @param id
* @return
*/
@RequestMapping(value = "/edit",method = RequestMethod.GET)
public String edit(Model model, @RequestParam("id")Long id){
if(studentService.findById(id)!=null){
model.addAttribute("student",studentService.findById(id));
}
return "/admin/student/edit";
}
/**
* 编辑后台学生信息
* @param student
* @return
*/
@ResponseBody
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public Result edit(Student student, HttpServletRequest request) {
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(student);
if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
return Result.error(validate);
}
//将提交的学生信息指定字段复制到已存在的student对象中
Student findbyId = studentService.findById(student.getId());
//把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
BeanUtils.copyProperties(student, findbyId, "id", "createTime", "updateTime");
//到这说明一切通过 开始进行数据库编辑
if (studentService.save(findbyId) == null) {
return Result.error(CodeMsg.ADMIN_STUDENT_EDIT_ERROR);
}
operaterLogService.add("编辑学生,学生姓名:" + student.getStuName());
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) {
Student student = studentService.findById(Long.valueOf(id));
if (student != null) {
try {
studentService.delete(Long.valueOf(id));
operaterLogService.add("删除学生,id为:" + id);
}catch (Exception e){
return Result.error(CodeMsg.ADMIN_STUDENT_DELETE_ERROR);
}
}
}
}
return Result.success(true);
}
}