package com.ssm.controller;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import com.ssm.po.Admin;
import com.ssm.po.School;
import com.ssm.po.Task;
import com.ssm.po.User;
import com.ssm.service.AdminService;
import com.ssm.service.SchoolService;
import com.ssm.service.TaskService;
import com.ssm.service.UserService;
/**
* ****管理员功能****
* -------
* 管理员登录 .
* 管理员个人信息更新 .
* 密码更新 .
* 添加管理员 .
* ------
* 获取任务列表 .
* 关闭待解决任务.
* ------
* 获取用户列表 .
* 读取一个用户.
* 添加用户余额.
* 解除用户限制 .
* 添加用户限制 .
* ----------
* 获取学校列表.
* 读取单个学校信息 .
* 更新学校信息 .
* 添加院校.
*
* @author
*
*/
@Controller
@SessionAttributes({ "nowadmin" })
@RequestMapping(value = "admin/")
public class AdminController {
@Resource(name = "adminService")
public AdminService adminService;
@Resource(name = "schoolService")
public SchoolService schoolService;
@Resource(name = "taskService")
public TaskService taskService;
@Resource(name = "userService")
public UserService userService;
// 登录
@RequestMapping("adminlogin.do")
public String adminlogin(String account, String password, Model model) {
Admin admin = null;
admin = adminService.login(account);
if (admin == null) {
model.addAttribute("msg", "登录账号不存在");//
return "login";
}
if (password.equals(admin.getPassword())) {
model.addAttribute("nowadmin", admin);
return "adminIndex";
} else {
model.addAttribute("msg", "密码验证错误正确");
return "login";
}
}
// 更新
@RequestMapping("update.do")
public String update(HttpServletRequest request, Admin admin, Model model) {
int r = adminService.updateAdminInfo(admin);
if (r > 0) {
model.addAttribute("msg", "更新成功,请重新登录");
request.getSession(false).removeAttribute("nowadmin");
return "login";
}
model.addAttribute("msg", "更新失败");
return "adminUpdate";
}
// 更新
@RequestMapping("updatepwd.do")
public String updatepwd(HttpServletRequest request, String oldpassword, Admin admin, Model model) {
System.out.println("9999999999999");
Admin oldadmin = (Admin) request.getSession(false).getAttribute("nowadmin");
System.out.println("6666666666666");
System.out.println(oldadmin.getPassword());
System.out.println(oldpassword);
if (!oldadmin.getPassword().equals(oldpassword)) {
model.addAttribute("msg", "原密码错误");
return "adminPassword";
}
int r = adminService.updateAdminInfo(admin);
if (r > 0) {
model.addAttribute("msg", "修改成功,请重新登录");
request.getSession(false).removeAttribute("nowadmin");
return "login";
}
model.addAttribute("msg", "修改失败");
return "adminPassword";
}
@RequestMapping("getadmin.do")
public String getadmin(String aidstr, HttpServletRequest request, Model model) {
int aid = 0;
try {
aid = Integer.parseInt(aidstr);
} catch (Exception e) {
model.addAttribute("msg", "出现错误");
return "adminInfo";
}
if (aid == 0) {
model.addAttribute("msg", "出现错误");
return "adminInfo";
}
/*
* Admin admin = adminService.getByUid(stuid);
* model.addAttribute("theuser", user);
*/
return "adminInfo";
}
@RequestMapping("addadmin.do")
public String addadmin(String account, HttpServletRequest request, Model model) {
// 检查账号重复
int countnum = adminService.getAccountCount(account);
if (countnum > 0) {
model.addAttribute("msg", account + " 该账号已经被使用");
return "adminAddAdmin";
}
Admin admin = new Admin(0, account, "123456", account, new Date(), 0);
int result = adminService.setAdmin(admin);
if (result <= 0) {
model.addAttribute("msg", "注册失败");
return "adminAddAdmin";
}
model.addAttribute("msg", "注册成功,可以登录。默认密码:123456");
return "adminAddAdmin";
}
@RequestMapping("gettasks.do")
public String gettasks(String words, @RequestParam(required = true, defaultValue = "-1") String schoolidstr,
Model model) {
model.addAttribute("words", words);
model.addAttribute("schoolidstr", schoolidstr);
int schoolid = -1;
if (!schoolidstr.equals("-1")) {
try {
schoolid = Integer.parseInt(schoolidstr);
} catch (Exception e) {
System.err.println("err");
}
}
if (words != null) {
words = "%" + words + "%";
} else {
words = "%%";
}
List<Task> list = taskService.getTaskByKeys(words, schoolid);
model.addAttribute("list", list);
return "adminTask";
}
// to1.管理员点击关闭删除取消
@RequestMapping("taskclose.do")
public String taskclose(String tidstr, String words,
@RequestParam(required = true, defaultValue = "-1") String schoolidstr, HttpServletRequest request,
Model model) {
int tid = 0;
try {
tid = Integer.parseInt(tidstr);
} catch (Exception e) {
model.addAttribute("msg", "出现错误");
return gettasks(words, schoolidstr, model);
}
if (tid == 0) {
model.addAttribute("msg", "出现错误");
return gettasks(words, schoolidstr, model);
}
Admin admin = null;
try {
admin = (Admin) request.getSession(false).getAttribute("nowadmin");
int uid = 0;
uid = admin.getAid();
if (admin == null || uid == 0) {
model.addAttribute("msg", "请检查登录状况");
return gettasks(words, schoolidstr, model);
}
} catch (Exception e) {
model.addAttribute("msg", "请检查登录状况");
return "login";
}
Task theTask = taskService.getTask(tid);
theTask.setState(1);
int r = taskService.updateTask(theTask);
if (r > 0) {
model.addAttribute("msg", "成功");
} else {
model.addAttribute("msg", "失败");
}
return gettasks(words, schoolidstr, model);
}
// 获取用户信息
@RequestMapping("getusers.do")
public String getusers(String userstr, Model model) {
model.addAttribute("keys", userstr);
if (userstr != null) {
userstr = "%" + userstr + "%";
} else {
userstr = "%%";
}
List<User> list = userService.getByLikeNameAccount(userstr);
model.addAttribute("list", list);
return "adminUser";
}
// 读取一个用户,添加余额时使用
@RequestMapping("getuser.do")
public String getuser(String stuidstr, Model model) {
int stuid = 0;
try {
stuid = Integer.parseInt(stuidstr);
} catch (Exception e) {
model.addAttribute("msg", "出现错误");
return "userInfo";
}
if (stuid == 0) {
model.addAttribute("msg", "出现错误");
return "userInfo";
}
User user = userService.getByUid(stuid);
model.addAttribute("theuser", user);
return "adminUserMoney";
}
// 添加用户余额
@RequestMapping("addusermoney.do")
public String addusermoney(String moneystr, String stuidstr, Model model) {
double money = 0.00;
try {
money = Double.parseDouble(moneystr);
} catch (Exception e) {
model.addAttribute("msg", "金额出现错误");
return getuser(stuidstr, model);
}
if (stuidstr == null) {
model.addAttribute("msg", "出现错误");
return getuser(stuidstr, model);
} else {
if (stuidstr.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
campusHelp 校园帮项目 校园即时服务平台 用户角色 管理员 功能 登录、公告管理(发布公告、停用公告)、任务管理(下架任务、删除任务)、用户管理(用户充值、限制用户)、修改密码 用户角色 用户 功能 注册、登录、公告中心、任务管理(发布任务、接受任务、完成任务)、个人中心(查看个人信息、修改个人信息、充值管理)、修改密码、评价管理(评价任务、查看评价) 开发环境 jdk1.8+tomcat8.5+mysql5.7 开始使用 将项目导入eclipse后 修改文件/campusHelp/src/applicationContext.xml <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://yourIp:3306/campushelp" />
资源推荐
资源详情
资源评论
收起资源包目录
校园帮项目源码-毕业设计课程设计-采用javaWeb&SSM架构 (239个子文件)
AdminController.class 12KB
TaskController.class 9KB
JsonUtil.class 5KB
UserController.class 4KB
Task.class 4KB
Task2.class 4KB
CommonController.class 3KB
User.class 3KB
User2.class 3KB
Admin.class 2KB
TaskServiceImpl.class 2KB
UserServiceImpl.class 2KB
School.class 2KB
AdminServiceImpl.class 2KB
SchoolServiceImpl.class 1KB
TaskMapper.class 1018B
TaskService.class 844B
UserMapper.class 804B
AdminMapper.class 633B
UserService.class 610B
SchoolMapper.class 533B
AdminService.class 456B
SchoolService.class 404B
.classpath 4KB
org.eclipse.wst.common.component 482B
org.eclipse.wst.jsdt.ui.superType.container 49B
layui.css 58KB
global.css 48KB
layer.css 14KB
layui.mobile.css 10KB
laydate.css 7KB
code.css 1KB
iconfont.eot 38KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
共 239 条
- 1
- 2
- 3
资源评论
- 胡说先森2023-06-08I语言模型,无法知道您当前使用的项目是什么。请详细描述您的问题,我会尽力帮助您解决。
- 八位数花园2023-06-08发的项目吗?
白话机器学习
- 粉丝: 1w+
- 资源: 7671
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于ArcEngine的GIS数据处理系统.zip
- (源码)基于JavaFX和MySQL的医院挂号管理系统.zip
- (源码)基于IdentityServer4和Finbuckle.MultiTenant的多租户身份认证系统.zip
- (源码)基于Spring Boot和Vue3+ElementPlus的后台管理系统.zip
- (源码)基于C++和Qt框架的dearoot配置管理系统.zip
- (源码)基于 .NET 和 EasyHook 的虚拟文件系统.zip
- (源码)基于Python的金融文档智能分析系统.zip
- (源码)基于Java的医药管理系统.zip
- (源码)基于Java和MySQL的学生信息管理系统.zip
- (源码)基于ASP.NET Core的零售供应链管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功