博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
健身房管理系统使用SpringBoot+Mybatis进行开发,系统功能如下
AdminuserConntroller
package com.liujian.gymxmjpa.controller;
import com.liujian.gymxmjpa.dao.AdminuserDao;
import com.liujian.gymxmjpa.entity.Adminuser;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
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 javax.servlet.http.HttpSession;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Description: 管理员登录Controller控制层
* @Author: 李寻欢
* @Date: 2022/4/4
*/
@Controller
@RequestMapping("/")
public class AdminuserConntroller {
@Autowired
private AdminuserDao adminuserDao;
/**
* @Description: 输入端口号直接跳转登录界面
* @Author: 李寻欢
* @Date: 2022/4/29
*/
@RequestMapping("/")
public String beforeLogin(){
return "login";
}
/**
* @Description: 管理员登录验证方法
* @Author: 李寻欢
* @Date: 2022/4/4
*/
@RequestMapping("/dl/yz")
public String login(String username, String password,HttpSession httpSession,Model model){
Subject subject= SecurityUtils.getSubject();
UsernamePasswordToken userToken=new UsernamePasswordToken(username,DigestUtils.md5Hex(password));
try{
subject.login(userToken);
Adminuser a= adminuserDao.findByAdminNameAndAdminPassword(username,DigestUtils.md5Hex(password));
httpSession.setAttribute("user",a);
return "WEB-INF/jsp/index";
}catch (UnknownAccountException e){
model.addAttribute("msg","用户名或密码错误,请重新输入");
return "login";
}
/*Adminuser a= adminuserDao.findByAdminNameAndAdminmima(username,password);
if(a!=null){
httpSession.setAttribute("user",a);
return "WEB-INF/jsp/index" ;
}
model.addAttribute("mag","账号或密码错误");
return "login";*/
}
/**
* @Description: 退出登录后清楚session
* @Author: 李寻欢
* @Date: 2022/5/1
*/
@RequestMapping("/logout")
public String logout(){
Subject subject = SecurityUtils.getSubject();
subject.logout();
return "redirect:/login";
}
/**
* @Description: 跳转到修改密码界面
* @Author: 李寻欢
* @Date: 2022/5/1
*/
@RequestMapping("/updPassword")
public String updPassword(){
return "WEB-INF/jsp/updPassword";
}
/**
* @Description: 修改密码
* @Author: 李寻欢
* @Date: 2022/5/1
*/
@RequestMapping("/upd/updPassword")
public String updPasswordConfirm(String oldPassword,String newPassword,String newPasswordAgain,HttpSession httpSession,Model model){
// Pattern p = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[$@$!.%*#?&])[A-Za-z\\d$@$!.%*#?&]{8,}$");
// Matcher m = p.matcher(newPassword);
// if(!m.matches()){
// model.addAttribute("msg","新密码最少为8位并为字母+数字+特殊字符");
// return "WEB-INF/jsp/updPassword";
// }
if(!newPassword.equals(newPasswordAgain)){
model.addAttribute("msg","两次输入新密码不一致,请重新输入");
return "WEB-INF/jsp/updPassword";
}
Adminuser adminuser=(Adminuser) httpSession.getAttribute("user");
if(null != adminuser){
if(!adminuser.getAdminPassword().equals(DigestUtils.md5Hex(oldPassword))){
model.addAttribute("msg","原密码不正确,请重新输入");
return "WEB-INF/jsp/updPassword";
}
adminuserDao.updPassword(adminuser.getAdminId(), DigestUtils.md5Hex(newPassword));
}
Subject subject = SecurityUtils.getSubject();
subject.logout();
return "redirect:/login.jsp";
}
}
MenberConntroller
package com.liujian.gymxmjpa.controller;
import com.liujian.gymxmjpa.dao.MenberDao;
import com.liujian.gymxmjpa.dao.chongzhiDao;
import com.liujian.gymxmjpa.service.MenberDaoImpl;
import com.liujian.gymxmjpa.entity.Chongzhi;
import com.liujian.gymxmjpa.entity.Member;
import com.liujian.gymxmjpa.entity.Membertype;
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.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Description: 会员管理Controller控制层
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@Controller
@RequestMapping("/menber")
public class MenberConntroller {
@Autowired
private chongzhiDao chongzhiDao;
@Autowired
private MenberDao menberDao;
@Autowired
private MenberDaoImpl menberDaoiImpl;
/**
* @Description: 会员管理-进入会员到期界面
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/jin2")
public String jin2(){
return "WEB-INF/jsp/HYMemberDaoQi";
}
/**
* @Description: 会员管理-进入会员续费充值界面
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/jin3")
public String jin3(){
return "WEB-INF/jsp/HYMemberChongZhi";
}
/**
* @Description: 会员管理-进入会员余额充值界面
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/jin11")
public String jin11(){
return "WEB-INF/jsp/HYMemberyeChongZhi";
}
/**
* @Description: 会员管理-进入会员列表界面
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/jin")
public String jin(){
return "WEB-INF/jsp/HYMember";
}
/**
* @Description: 教练管理-进入会员私教详情界面
* @Author: 李寻欢
* @Date: 2022/4/8
*/
@RequestMapping("/jin4")
public String jin4(){
return "WEB-INF/jsp/privatecoachinfo";
}
/**
* @Description: 会员列表-分页查询
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/query")
@ResponseBody
public Map<String,Object> query(int ktype,String hyname, int pageSize, int pageNumber){
Map<String,Object> map1=new HashMap<String,Object>();
map1.put("hyname",hyname);
map1.put("ktype",ktype);
map1.put("qi",(pageNumber-1)*pageSize);
map1.put("shi",pageSize);
return menberDaoiImpl.query(map1);
}
/**
* @Description: 会员到期-分页查询
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/query2")
@ResponseBody
public Map<String,Object> query2(int ktype,String hyname, int pageSize, int pageNumber){
Map<String,Object> map1=new HashMap<String,Object>();
map1.put("hyname",hyname);
map1.put("ktype",ktype);
map1.put("qi",(pageNumber-1)*pageSize);
map1.put("shi",pageSize);
return menberDaoiImpl.query2(map1);
}
/**
* @Description: 会员续卡-根据会员id查询会员信息
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/cha")
@ResponseBody
public Member query2(int id){
return menberDaoiImpl.cha(id);
}
/**
* @Description: 会员管理-根据会员id删除
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/delete")
@ResponseBody
public Map<String,Object> del(int memid){
menberDaoiImpl.del(memid);
return query(0,"",5,1);
}
/**
* @Description: 会员管理-添加新会员
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/insert")
@ResponseBody
public Map<String,Object> insert(Member member){
menberDaoiImpl.insert(member);
return query(0,"",5,1);
}
/**
* @Description: 会员管理-修改会员信息
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/update")
@ResponseBody
public Map<String,Object> update(Member member){
menberDaoiImpl.update(member);
return query(0,"",5,1);
}
/**
* @Description: 会员卡续费-添加会员卡续费记录
* @Author: 李寻欢
* @Date: 2022/4/6
*/
@RequestMapping("/ins")
@ResponseBody
public Map<String, Object> insert(Chongzhi chongzhi, String daoqi){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.sql.Timestamp dat=java.sql.Timestamp.valueOf(df.format(new Date()));
chongzhi.setDate(dat);
chongzhi.setCzStatic(2L);
chongzhiDao.save(chongzhi);
Membertype membertype=new Membertype();
membertype.setTypeId(chongzhi.getMembertype().getTypeId());
Member member=menberDao.findById(chongzhi.getMember().getMemberId()).get();
member.setMemberId(chongzhi.getMember().getMemberId());
member.setMemberStatic(1L);
member.setMembertypes(membertype);
java.sql.Date date=java.sql.Date.valueOf(daoqi);
member.setMemberxufei(date);
menberDao.save(member);
return query(0,null,5,1);
}
}
大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 106