ssm+vue基于java的健身房管理系统源码和论文PPT015
开发工具:idea
数据库mysql5.7+(mysql5.7最佳)
数据库链接工具:navcat,小海豚等
开发技术:java ssm tomcat8.5
摘 要
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本健身房管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此健身房管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了健身房基础数据的管理,员工的管理,公告信息的发布等功能。健身房管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
关键词:健身房管理系统;SSM框架;Mysql;自动化
package com.controller;import java.text.SimpleDateFormat;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;import com.annotation.IgnoreAuth;
import com.entity.HuiyuankaleixingEntity;
import com.entity.HuiyuanxinxiEntity;
import com.entity.UserEntity;
import com.service.HuiyuankaleixingService;
import com.service.TokenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;import com.entity.HuiyuanxinxiEntity;import com.service.HuiyuanxinxiService;
import com.utils.PageUtils;
import com.utils.R;/*** * 后端接口* @author* @email* @date 2021-01-26
*/
@RestController
@RequestMapping("/huiyuanxinxi")
public class HuiyuanxinxiController {private static final Logger logger = LoggerFactory.getLogger(HuiyuanxinxiController.class);@Autowiredprivate HuiyuanxinxiService huiyuanxinxiService;@Autowiredprivate HuiyuankaleixingService huiyuankaleixingService;@Autowiredprivate TokenService tokenService;/*** 登录*/@IgnoreAuth@PostMapping(value = "/login")public R login(String username, String password, String role, HttpServletRequest request) {HuiyuanxinxiEntity user = huiyuanxinxiService.selectOne(new EntityWrapper<HuiyuanxinxiEntity>().eq("account", username));if(user == null){return R.error("您没有此权限或账号或密码不正确");}if(!user.getRole().equals(role)){return R.error("您没有此权限");}if(user==null || !user.getPassword().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(),username, "huiyuanxinxi", user.getRole());return R.ok().put("token", token);}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody HuiyuanxinxiEntity user){
// ValidatorUtils.validateEntity(user);if(huiyuanxinxiService.selectOne(new EntityWrapper<HuiyuanxinxiEntity>().eq("username", user.getHyname()).eq("role",user.getRole())) != null) {return R.error("用户已存在");}huiyuanxinxiService.insert(user);return R.ok();}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}/*** 密码重置*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request){HuiyuanxinxiEntity user = huiyuanxinxiService.selectOne(new EntityWrapper<HuiyuanxinxiEntity>().eq("username", username));if(user==null) {return R.error("账号不存在");}user.setPassword("123456");huiyuanxinxiService.update(user,null);return R.ok("密码已重置为:123456");}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrUser(HttpServletRequest request){Integer id = (Integer) request.getSession().getAttribute("userId");HuiyuanxinxiEntity user = huiyuanxinxiService.selectById(id);return R.ok().put("data", user);}/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params,HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",page方法");params.put("userId",request.getSession().getAttribute("userId"));params.put("role",request.getSession().getAttribute("role"));PageUtils page = huiyuanxinxiService.queryPage(params);return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Integer id){logger.debug("Controller:"+this.getClass().getName()+",info方法");HuiyuanxinxiEntity huiyuanxinxi = huiyuanxinxiService.selectById(id);if(huiyuanxinxi!=null){return R.ok().put("data", huiyuanxinxi);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody HuiyuanxinxiEntity huiyuanxinxi, HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",save");Wrapper<HuiyuanxinxiEntity> queryWrapper = new EntityWrapper<HuiyuanxinxiEntity>().eq("hyname", huiyuanxinxi.getHyname()).eq("account", huiyuanxinxi.getAccount());logger.info("sql语句:"+queryWrapper.getSqlSegment());huiyuanxinxi.setRole("会员");HuiyuanxinxiEntity huiyuanxinxiEntity = huiyuanxinxiService.selectOne(queryWrapper);if(huiyuanxinxiEntity==null){huiyuanxinxi.setId((int) (new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()));huiyuanxinxiService.insert(huiyuanxinxi);return R.ok();}else {return R.error(511,"输入信息重复请重新输入");}}/*** 修改*/@RequestMapping("/update")public R update(@RequestBody HuiyuanxinxiEntity huiyuanxinxi, HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",update");//根据字段查询是否有相同数据Wrapper<HuiyuanxinxiEntity> queryWrapper = new EntityWrapper<HuiyuanxinxiEntity>().notIn("id",huiyuanxinxi.getId()).eq("hyname", huiyuanxinxi.getHyname()).eq("account", huiyuanxinxi.getAccount());logger.info("sql语句:"+queryWrapper.getSqlSegment());HuiyuanxinxiEntity huiyuanxinxiEntity = huiyuanxinxiService.selectOne(queryWrapper);//根据id获取数据库信息HuiyuanxinxiEntity huiyuanxinxiEntity1 = huiyuanxinxiService.selectById(huiyuanxinxi.getId());//判断用户选的值是否和原来的一样if(huiyuanxinxiEntity1.getHykTypes() != huiyuanxinxi.getHykTypes()){//根据用户选的值去查询HuiyuankaleixingEntity huiyuankaleixingEntity = huiyuankaleixingService.selectById(huiyuanxinxi.getHykTypes());if(huiyuanxinxi.getBalance() <= 0){return R.error(511,"金额不足,请充值");}//将查询出来的会员卡的金额减去用户的余额Double balance = huiyuanxinxi.getBalance()-huiyuankaleixingEntity.getCost();//判断减完后数字是否大于0if(balance >= 0){//将减完的数字进行覆盖huiyuanxinxi.setBalance(balance);}else{//如果余额不足返回前端return R.error(511,"金额不足不能修改会员卡类型,请充值");}}if(huiyuanxinxiEntity==null){//进行修改huiyuanxinxiService.updateById(huiyuanxinxi);//根据id更新return R.ok();}else {return R.error(511,"输入信息重复请重新输入");}}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){logger.debug("Controller:"+this.getClass().getName()+",delete");huiyuanxinxiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}
}
package com.controller;import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;import com.annotation.IgnoreAuth;
import com.entity.YonghuxinxiEntity;
import com.service.TokenService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;import com.entity.YonghuxinxiEntity;import com.service.YonghuxinxiService;
import com.utils.PageUtils;
import com.utils.R;/*** 员工信息* 后端接口* @author* @email* @date 2024-02-02
*/
@RestController
@Controller
@RequestMapping("/yonghuxinxi")
public class YonghuxinxiController {private static final Logger logger = LoggerFactory.getLogger(YonghuxinxiController.class);@Autowiredprivate YonghuxinxiService yonghuxinxiService;@Autowiredprivate TokenService tokenService;/*** 登录*/@IgnoreAuth@PostMapping(value = "/login")public R login(String username, String password, String role, HttpServletRequest request) {YonghuxinxiEntity user = yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("account", username));if(user != null){if(!user.getRole().equals(role)){return R.error("权限不正常");}if(user==null || !user.getPassword().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(),user.getName(), "users", user.getRole());return R.ok().put("token", token);}else{return R.error("账号或密码或权限不对");}}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody YonghuxinxiEntity user){
// ValidatorUtils.validateEntity(user);if(yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("username", user.getAccount())) !=null) {return R.error("用户已存在");}yonghuxinxiService.insert(user);return R.ok();}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrUser(HttpServletRequest request){Integer id = (Integer)request.getSession().getAttribute("userId");YonghuxinxiEntity user = yonghuxinxiService.selectById(id);return R.ok().put("data", user);}/*** 密码重置*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request){YonghuxinxiEntity user = yonghuxinxiService.selectOne(new EntityWrapper<YonghuxinxiEntity>().eq("username", username));if(user==null) {return R.error("账号不存在");}user.setPassword("123456");yonghuxinxiService.update(user,null);return R.ok("密码已重置为:123456");}/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",page方法");Object role = request.getSession().getAttribute("role");PageUtils page = null;if(role.equals("员工")){params.put("yh",request.getSession().getAttribute("userId"));page = yonghuxinxiService.queryPage(params);}else{page = yonghuxinxiService.queryPage(params);}return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id){logger.debug("Controller:"+this.getClass().getName()+",info方法");YonghuxinxiEntity yonghuxinxi = yonghuxinxiService.selectById(id);if(yonghuxinxi!=null){return R.ok().put("data", yonghuxinxi);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody YonghuxinxiEntity yonghuxinxi, HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",save");Wrapper<YonghuxinxiEntity> queryWrapper = new EntityWrapper<YonghuxinxiEntity>().eq("name", yonghuxinxi.getName()).in("account",yonghuxinxi.getAccount());logger.info("sql语句:"+queryWrapper.getSqlSegment());YonghuxinxiEntity yonghuxinxiEntity = yonghuxinxiService.selectOne(queryWrapper);if("".equals(yonghuxinxi.getImgPhoto()) || "null".equals(yonghuxinxi.getImgPhoto())){yonghuxinxi.setImgPhoto(null);}yonghuxinxi.setRole("员工");if(yonghuxinxiEntity==null){yonghuxinxiService.insert(yonghuxinxi);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 修改*/@RequestMapping("/update")public R update(@RequestBody YonghuxinxiEntity yonghuxinxi, HttpServletRequest request){logger.debug("Controller:"+this.getClass().getName()+",update");//根据字段查询是否有相同数据Wrapper<YonghuxinxiEntity> queryWrapper = new EntityWrapper<YonghuxinxiEntity>().notIn("id",yonghuxinxi.getId()).in("name",yonghuxinxi.getName()).in("account",yonghuxinxi.getAccount());logger.info("sql语句:"+queryWrapper.getSqlSegment());YonghuxinxiEntity yonghuxinxiEntity = yonghuxinxiService.selectOne(queryWrapper);if("".equals(yonghuxinxi.getImgPhoto()) || "null".equals(yonghuxinxi.getImgPhoto())){yonghuxinxi.setImgPhoto(null);}if(yonghuxinxiEntity==null){yonghuxinxiService.updateById(yonghuxinxi);//根据id更新return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){logger.debug("Controller:"+this.getClass().getName()+",delete");yonghuxinxiService.deleteBatchIds(Arrays.asList(ids));return R.ok();}
}