一、项目简述
本系统主要实现的功能有:
网上商城系统,前台+后台管理,用户注册,登录,商品展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,用户管理,信息修改等等。
二、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
Springboot+ SpringMVC + MyBatis + Jsp + Html+ JavaScript + JQuery + Ajax + maven等等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
/**
* 管理员商品列表
* */
@GetMapping("/admin/product")
public String adminproduct(){
return "/admin/product/productlist";
}
/**
* 分页管理员查看各类商品信息
*前端传入页码、分页数量
*前端传入商品信息状态码(commstatus)-->全部:100,违规:0,已审核:1,待审核:3 已完成:4
* 因为是管理员查询,将userid设置为空
*/
@GetMapping("/admin/commodity/{commstatus}")
@ResponseBody
@PutMapping("/user/updatepwd")
public ResultVo updatepwd(HttpSession session, HttpServletRequest request) throws IOException {
JSONObject json = JsonReader.receivePost(request);
String oldpwd = json.getString("oldpwd");
String newpwd = json.getString("newpwd");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
UserInfo userInfo = new UserInfo();
login.setUserid(userid);
Login login1 = loginService.userLogin(login);
String oldpwds = new Md5Hash(oldpwd, "Game-shops").toString();
//如果旧密码相等
if (oldpwds.equals(login1.getPassword())){
//盐加密
String passwords = new Md5Hash(newpwd, "Game-shops").toString();
* */
@ResponseBody
@PutMapping("/admin/changecommstatus/{commid}/{commstatus}")
public ResultVo ChangeCommstatus(@PathVariable("commid") String commid, @PathVariable("commstatus") Integer commstatus) {
Integer i = commodityService.ChangeCommstatus(commid, commstatus);
if (i == 1){
/**发出商品审核结果的系统通知*/
Commodity commodity = commodityService.LookCommodity(new Commodity().setCommid(commid));
if (commstatus == 0){
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(commodity.getUserid()).setTpname("商品审核")
.setWhys("您的商品 "+commodity.getCommname()+"a> 未通过审核,目前不支持公开发布。");
noticesService.insertNotices(notices);
}else if (commstatus == 1){
@PutMapping("/admin/user/forbid/{userid}/{userstatus}")
@ResponseBody
public ResultVo adminuserlist(@PathVariable("userid") String userid,@PathVariable("userstatus") Integer userstatus) {
if (userstatus == 0){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
Integer j = userInfoService.UpdateUserInfo(new UserInfo().setUserid(userid).setUserstatus(userstatus));
if (i ==1 && j == 1){
/**发出封号的系统通知*/
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(userid).setTpname("系统通知")
.setWhys("因为您的不良行为,您在该网站的账号已被封号。");
noticesService.insertNotices(notices);
return new ResultVo(true, StatusCode.OK, "封号成功");
}
return new ResultVo(true, StatusCode.ERROR, "封号失败");
}else if (userstatus == 1){
Integer i = loginService.updateLogin(new Login().setUserid(userid).setUserstatus(userstatus));
return "redirect:/";
}
}
管理员控制器:
/**
* @Description: 管理员控制器
*/
@Controller
public class AdminController {
@Autowired
private UserRoleService userRoleService;
@Autowired
private LoginService loginService;
@Autowired
private UserInfoService userInfoService;
@Autowired
private CommodityService commodityService;
@Autowired
private NoticesService noticesService;
/**
login.setUsername(username).setMobilephone(null);
Login userNameIsExist = loginService.userLogin(login);
if (!StringUtils.isEmpty(userNameIsExist)){//用户名已经存在
return new ResultVo(false, StatusCode.ERROR,"用户名已存在,请换一个吧");
}
String rel = phonecodemap1.get(mobilephone);
if (StringUtils.isEmpty(rel)) {//验证码到期 或者 没发送短信验证码
return new ResultVo(false,StatusCode.ERROR,"请重新获取验证码");
}
//if (rel.equalsIgnoreCase(vercode)) {
if (vercode.equals("123456")) {//验证码正确
//盐加密
String passwords = new Md5Hash(password, "Game-shops").toString();
.setWhys("您的商品 "+commodity.getCommname()+"a> 未通过审核,目前不支持公开发布。");
noticesService.insertNotices(notices);
}else if (commstatus == 1){
Notices notices = new Notices().setId(KeyUtil.genUniqueKey()).setUserid(commodity.getUserid()).setTpname("商品审核")
.setWhys("您的商品 "+commodity.getCommname()+"a> 已通过审核,快去看看吧。");
noticesService.insertNotices(notices);
}
return new ResultVo(true,StatusCode.OK," *** 作成功");
}
return new ResultVo(false,StatusCode.ERROR," *** 作失败");
}
}
后台管理代码:
@Controller
public class IndexController {
/**
* 网站首页
* */
@GetMapping("/")
public String index(){
return "/index";
}
/**
* 联系我们
* */
@GetMapping("/contacts")
Integer dataNumber = commodityService.queryCommodityCount(null, commstatus);
return new LayuiPageVo("",0,dataNumber,commodityList);
}
}
/**
* 管理员对商品的 *** 作
* 前端传入商品id(commid)
* 前端传入 *** 作的商品状态(commstatus)-->违规:0 通过审核:1
* */
@ResponseBody
@PutMapping("/admin/changecommstatus/{commid}/{commstatus}")
public ResultVo ChangeCommstatus(@PathVariable("commid") String commid, @PathVariable("commstatus") Integer commstatus) {
Integer i = commodityService.ChangeCommstatus(commid, commstatus);
if (i == 1){
/**发出商品审核结果的系统通知*/
Commodity commodity = commodityService.LookCommodity(new Commodity().setCommid(commid));
if (commstatus == 0){
Integer integer = loginService.updateLogin(login);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
if (integer == 1 && integer1 == 1) {
return new ResultVo(true, StatusCode.OK, "更换手机号成功");
}
return new ResultVo(false, StatusCode.SERVERERROR, "系统错误,更换失败");
}
return new ResultVo(false,StatusCode.ERROR,"验证码错误");
}
}
登录注册控制器:
/**
* <p>
* 登录注册控制器
* p>
*
*/
@Controller
public class LoginController {
@Autowired
private LoginService loginService;
public ResultVo updateInfo(@RequestBody UserInfo userInfo, HttpSession session) {
String username = userInfo.getUsername();
String sessionname = (String) session.getAttribute("username");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
//如果传入用户名不为空
if (!StringUtils.isEmpty(username)){
login.setUsername(username);
Login login1 = loginService.userLogin(login);
//如果用户名未修改
if (sessionname.equals(username)){
UserInfo userInfo2 = userInfoService.LookUserinfo(login1.getUserid());
if (userInfo.getUsername().equals(userInfo2.getUsername())
&& userInfo.getEmail().equals(userInfo2.getEmail())
&& userInfo.getSex().equals(userInfo2.getSex())
&& userInfo.getServer().equals(userInfo2.getServer())
后台管理代码:
@Controller
public class IndexController {
/**
* 网站首页
* */
@GetMapping("/")
public String index(){
return "/index";
}
/**
* 联系我们
* */
*/
@ResponseBody
@PutMapping("/user/updatepwd")
public ResultVo updatepwd(HttpSession session, HttpServletRequest request) throws IOException {
JSONObject json = JsonReader.receivePost(request);
String oldpwd = json.getString("oldpwd");
String newpwd = json.getString("newpwd");
String userid = (String) session.getAttribute("userid");
Login login = new Login();
UserInfo userInfo = new UserInfo();
login.setUserid(userid);
Login login1 = loginService.userLogin(login);
String oldpwds = new Md5Hash(oldpwd, "Game-shops").toString();
//如果旧密码相等
if (oldpwds.equals(login1.getPassword())){
//盐加密
String passwords = new Md5Hash(newpwd, "Game-shops").toString();
login.setPassword(passwords);
userInfo.setPassword(passwords).setUserid(login1.getUserid());
Integer integer = loginService.updateLogin(login);
Integer integer1 = userInfoService.UpdateUserInfo(userInfo);
if (integer == 1 && integer1 == 1) {
return new ResultVo(true, StatusCode.OK, "修改密码成功");
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)