package com.bjpowernode.music.ss.controller.base;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.bjpowernode.music.common.WebResponse;
import com.bjpowernode.music.ss.domain.User;
import org.springframework.beans.BeanUtils;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import com.bjpowernode.music.ss.service.IMyMusicService;
import com.bjpowernode.music.ss.service.IUserService;
import com.bjpowernode.music.ss.service.impl.UserService;
/**
*
*
*
*/
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
protected WebResponse webResponse;
@Resource
protected IUserService userService;
@Resource
protected IMyMusicService MyMusicService;
@Autowired
UserService userService2;
String newName = null;
// 登录功能
@RequestMapping(value = "/loginPage", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse loginCon(HttpServletRequest request, HttpSession session) {
// 取参数的方法,对应登录表单中的用户名name="user_name"
String user_name = request.getParameter("user_name");
String user_password = request.getParameter("user_password");
// 调用mapper层的登录的方法,从数据库中匹配用户名和密码,并放回用户名
String tname = userService2.login(user_name, user_password);
String user_Id = userService2.getUserById(user_name, user_password);
// newUserId = user_Id; //修改密码用的
int userId = 0;
try {
// 判断字符串是否是数字,并且抛出异常
// boolean NotisNum
// =(user_Id.equals(null)||user_Id.equals("")||user_Id.equals("null"));
boolean NotisNum = (user_Id.equals("null"));
// System.out.println(NotisNum);
if (!NotisNum) {
userId = Integer.parseInt(user_Id);
}
} catch (Exception e) {
}
//
session.setAttribute("tname", tname);
session.setAttribute("userId", userId);
Object data = null;
String statusMsg = "";
Integer statusCode = 200;
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("user_name", user_name);
paramMap.put("user_password", user_password);
data = paramMap;
User user = new User();
user.setUser_id(userId);
System.out.println("登录的id:" + user.getUser_id());
System.out.println("登录的用户名:" + session.getAttribute(tname));
System.out.println("前端,用户名:" + user_name + " 密码:" + user_password);
System.out.println("根据前端在数据库中查找到的用户名:" + tname + " 用户的id:" + userId);
// 用户名和密码匹配不成功,则返回的用户名为空
if (tname == null) {
System.out.println("用户不存在");
System.out.println();
statusMsg = "用户或密码错误!";
statusCode = 201;
return webResponse.getWebResponse(statusCode, statusMsg, data);
} else {
statusCode = 200;
webResponse.setStatusCode(statusCode);
System.out.println("状态码:" + webResponse.getStatusCode());
System.out.println("登录成功了");
System.out.println();
return webResponse.getWebResponseUserId(statusCode, statusMsg, data, userId);
}
}
// 更改密码 更改密码 更改密码
@RequestMapping(value = "/resetUserPassword", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse resetUserPassword(HttpServletRequest request, HttpSession session) {
Object data = null;
String statusMsg = "";
Integer statusCode = 200;
int uId = 0;
// 取参数的方法,对应登录表单中的用户名
String user_name = request.getParameter("user_name");
String newUser_password = request.getParameter("newUser_password");
try {
uId = (int) this.userService2.resetPassword(user_name, newUser_password);
System.out.println("修改密码返回的id:" + uId);
} catch (Exception e) {
}
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
// 用户注册
@RequestMapping(value = "/addOrEditUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse addOrEditTest(HttpServletRequest request, HttpServletResponse response, HttpSession session,
String user_id, @RequestParam(required = false) String user_name,
@RequestParam(required = false) String user_password) {
Object data = null;
String statusMsg = "用户名已存在,请重新注册!";
Integer statusCode = 201;
String rearchName = null;
try {
rearchName = this.userService.rearchUserName(user_name);
if (!(rearchName.equals("null"))) {
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
} catch (Exception e) {
}
System.out.println("判断用户是否重复:" + rearchName);
if (user_id == null || user_id.length() == 0) {
return this.addUser(request, response, session, user_name, user_password);
} else {
return this.editUser(request, response, session, user_id, user_name, user_password);
}
}
// 添加用户
@RequestMapping(value = "/addUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse addUser(HttpServletRequest request, HttpServletResponse response, HttpSession session,
String user_name, String user_password) {
Object data = null;
String statusMsg = "";
Integer statusCode = 200;
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("user_name", user_name);
paramMap.put("user_password", user_password);
data = paramMap;
if (user_name == null || "".equals(user_name.trim()) || user_password == null
|| "".equals(user_password.trim())) {
statusMsg = " 参数为空错误!!!!";
statusCode = 201;
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
if (user_name.length() > 255 || user_password.length() > 65535) {
statusMsg = " 参数长度过长错误!!!";
statusCode = 201;
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
User user = new User();
boolean isAdd = true;
return this.addOrEditUser(request, response, session, data, user, user_name, user_password, isAdd);
}
@RequestMapping(value = "/editUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse editUser(HttpServletRequest request, HttpServletResponse response, HttpSession session,
String user_id, @RequestParam(required = false) String user_name,
@RequestParam(required = false) String user_password) {
Object data = null;
String statusMsg = "";
Integer statusCode = 200;
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("user_id", user_id);
paramMap.put("user_name", user_name);
paramMap.put("user_password", user_password);
data = paramMap;
if (user_id == null || "".equals(user_id.trim())) {
statusMsg = "未获得主键参数错误!!!";
statusCode = 201;
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
Integer user_idNumeri = user_id.matches("^[0-9]*$") ? Integer.parseInt(user_id) : 0;
if (user_idNumeri == 0) {
statusMsg = "主键不为数字错误!!!";
statusCode =
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过严格测试运行成功才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设_音乐管理系统:Java 毕设项目,含代码.zip (807个子文件)
Upload.asp 5KB
Upload.aspx 109B
Upload.aspx 109B
Upload.asp.cls 15KB
Upload.aspx.cs 4KB
summernote-bs3.css 149KB
bootstrap.min.css 143KB
style.css 141KB
bootstrap.min14ed.css 118KB
style.min.css 97KB
style.min862f.css 97KB
animate.css 67KB
jquery.mCustomScrollbar.css 54KB
animate.min.css 46KB
datepicker3.css 34KB
font-awesome.css 34KB
bootstrap-rtl.css 32KB
font-awesome.min93e3.css 26KB
font-awesome.min.css 26KB
ambiance.css 26KB
style.min.css 25KB
bootstrap-editable.css 21KB
sweetalert.css 18KB
simditor.css 18KB
ui.jqgrid.css 17KB
jasny-bootstrap.min.css 14KB
jquery-ui-1.10.4.custom.min.css 14KB
chosen.css 13KB
index.css 12KB
mainpage1.css 12KB
dropzone.css 12KB
fullcalendar.css 11KB
layim.css 11KB
layer.css 11KB
summernote.css 10KB
plyr.css 10KB
singer.css 9KB
musicRadio.css 8KB
songlist.css 8KB
webuploader-demo.css 8KB
musician.css 8KB
codemirror.css 7KB
bootstrap-table.css 7KB
index1.css 7KB
mymusic.css 7KB
mv.css 7KB
awesome-bootstrap-checkbox.css 7KB
toastr.min.css 7KB
blueimp-gallery.min.css 7KB
playmusic.css 6KB
laydate.css 6KB
jquery.steps.css 6KB
blueimp-gallery.css 6KB
footable.core.css 6KB
jquery.fancybox.css 5KB
dataTables.bootstrap.css 5KB
bootstrap-table.min.css 4KB
bangdan.css 4KB
clockpicker.css 4KB
basic.css 4KB
style.css 4KB
laydate.css 3KB
bootstrap-colorpicker.min.css 3KB
nav.css 3KB
cropper.min.css 3KB
ion.rangeSlider.css 3KB
jquery.nouislider.css 3KB
layer.ext.css 3KB
register.css 3KB
bootstrap-markdown.min.css 3KB
jquery.gritter.css 3KB
blueimp-gallery-video.css 2KB
login.css 2KB
ion.rangeSlider.skinFlat.css 2KB
bootstrap-duallistbox.css 2KB
blueimp-gallery-indicator.css 2KB
login.min.css 1KB
custom.css 1KB
bootstrap-multiselect.css 1KB
bootstrap-treeview.css 1KB
demo.css 920B
login-n.css 882B
fullcalendar.print.css 694B
switchery.css 645B
webuploader.css 545B
webuploader.css 545B
tiki.css 469B
morris-0.4.3.min.css 447B
tiddlywiki.css 236B
Newtonsoft.Json.dll 530KB
Newtonsoft.Json.dll 530KB
.DS_Store 6KB
fontawesome-webfont.eot 121KB
glyphicons-halflings-regular.eot 35KB
footable.eot 6KB
fancybox_loading@2x.gif 23KB
fancybox_loading.gif 10KB
xubox_loading0.gif 9KB
loading-0.gif 9KB
loading.gif 7KB
共 807 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
pk_xz123456
- 粉丝: 2859
- 资源: 4045
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 精选毕设项目-树芽读书.zip
- 精选毕设项目-数独小游戏.zip
- 精选毕设项目-体育圈招聘小程序.zip
- 精选毕设项目-天天快拍.zip
- 精选毕设项目-体育新闻赛事数据.zip
- 精选毕设项目-同城拼车(完整带PHP后台).zip
- 精选毕设项目-图表.zip
- MATLAB/SIMULINK环境下5V/0.5A手机充电器仿真设计及其实现方法
- 精选毕设项目-托福资料(完整带Java后台).zip
- 精选毕设项目-微笑话.zip
- 精选毕设项目-外卖带bmob后端.zip
- 精选毕设项目-王者荣耀故事站小程序带Vue后台.zip
- 精选毕设项目-微赞论坛.zip
- 精选毕设项目-物品回收.zip
- 精选毕设项目-五洲商城.zip
- 精选毕设项目-小丑电影小程序.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功