基于springboot驾校预约学习系统源码和论文

伴随着信息技术与互联网技术的不断发展,人们进到了一个新的信息化时代,传统管理技术性没法高效率、容易地管理信息内容。为了实现时代的发展必须,提升管理高效率,各种各样管理管理体系应时而生,各个领域陆续进到信息内容管理时期。驾校预约学习系统管理系统的实现是信息内容时代浪潮时代的产物之一。

一切系统都要遵循系统设计的最基本全过程,系统也是如此。它还要通过市场调查、需求分析报告、汇总设计、详尽设计、编号和测试,根据Java语言表达设计,完成驾校预约学习系统管理系统。该系统根据B/S,即所谓的电脑浏览器/网络服务器方式,运用Java技术性,挑选MySQL作为后台系统。系统主要包含用户中心、系统公告、学习资料、考试预约管理等功能模块。

文中重点介绍了驾校预约学习系统管理的专业技术发展背景和发展状况,随后遵照软件传统式研发流程,最先挑选适用思维和语言软件开发平台,依据需求分析报告模块和设计数据库结构,再根据系统功能模块的设计制作系统功能模块图、流程表和E-R图。随后,设计架构,并依据设计架构编写代码,并实现系统的每个功能模块。最终,基本完成系统检测通常是系统测试、单元测试卷和功能测试。检测结果显示,该系统能够实现所需要的作用,工作状态没有明显缺陷。

关键词:驾校预约学习系统管理系统;学习资料,MySQL数据库;Java语言

基于springboot驾校预约学习系统源码和论文508

演示视频:

基于springboot驾校预约学习系统源码和论文


Abstract

With the continuous progress of information technology and internet technology, we have entered a new information age, where traditional management professionalism cannot efficiently and conveniently manage information. To achieve social development, it is necessary to improve management efficiency. Various management systems should change with the times, and various industries have entered the stage of information management one after another. The completion of the driving school appointment learning system management system is one of the products of the information age wave era.

All systems must follow the most basic entire process of system design, and the same applies to systems. It also needs to complete a driving school appointment learning system management system through market research, demand analysis reports, summary design, detailed design, numbering, and testing, expressed in Java language. The system uses Java technology and selects MySQL as the backend system based on B/S, the so-called computer browser/network server method. The system mainly includes functional modules such as user center, system announcements, learning materials, and exam appointment management.

The original text focuses on the development background and situation of professional skills in the management of driving school appointment learning systems. Following the traditional development process of mobile software, the first choice was to use thinking and language software development tools. Based on the data analysis report module and database structure design, the system functional module diagram and flow chart electronic wireless communication diagram were created according to the design of the system functional module. Next, design the architecture and write code based on it to implement each functional module of the system. Finally, the basic implementation of system verification generally involves system inspection, unit test papers, and system testing. The inspection data shows that the system can achieve the required efficacy and has no obvious shortcomings in its operating state.

Keywords: Driving school appointment learning system management system; Learning materials, MySQL database system database; Java Language Expression Language.


package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
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.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 专家
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/zhuanjia")
public class ZhuanjiaController {
    private static final Logger logger = LoggerFactory.getLogger(ZhuanjiaController.class);

    private static final String TABLE_NAME = "zhuanjia";

    @Autowired
    private ZhuanjiaService zhuanjiaService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛
    @Autowired
    private GonggaoService gonggaoService;//竞赛公告
    @Autowired
    private HuojiangService huojiangService;//获奖
    @Autowired
    private LaoshiService laoshiService;//老师
    @Autowired
    private PingshenService pingshenService;//评审
    @Autowired
    private PingshenFenpeiService pingshenFenpeiService;//评审分配
    @Autowired
    private PingshenPingfenService pingshenPingfenService;//评审打分
    @Autowired
    private SaishiService saishiService;//赛事
    @Autowired
    private SaishiTijiaoService saishiTijiaoService;//赛事提交
    @Autowired
    private SaishiYuyueService saishiYuyueService;//赛事报名
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private UsersService usersService;//管理员


    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        else if("老师".equals(role))
            params.put("laoshiId",request.getSession().getAttribute("userId"));
        else if("专家".equals(role))
            params.put("zhuanjiaId",request.getSession().getAttribute("userId"));
        CommonUtil.checkMap(params);
        PageUtils page = zhuanjiaService.queryPage(params);

        //字典表数据转换
        List<ZhuanjiaView> list =(List<ZhuanjiaView>)page.getList();
        for(ZhuanjiaView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectById(id);
        if(zhuanjia !=null){
            //entity转view
            ZhuanjiaView view = new ZhuanjiaView();
            BeanUtils.copyProperties( zhuanjia , view );//把实体数据重构到view中
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody ZhuanjiaEntity zhuanjia, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,zhuanjia:{}",this.getClass().getName(),zhuanjia.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<ZhuanjiaEntity> queryWrapper = new EntityWrapper<ZhuanjiaEntity>()
            .eq("username", zhuanjia.getUsername())
            .or()
            .eq("zhuanjia_phone", zhuanjia.getZhuanjiaPhone())
            .or()
            .eq("zhuanjia_id_number", zhuanjia.getZhuanjiaIdNumber())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ZhuanjiaEntity zhuanjiaEntity = zhuanjiaService.selectOne(queryWrapper);
        if(zhuanjiaEntity==null){
            zhuanjia.setCreateTime(new Date());
            zhuanjia.setPassword("123456");
            zhuanjiaService.insert(zhuanjia);
            return R.ok();
        }else {
            return R.error(511,"账户或者专家手机号或者专家身份证号已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody ZhuanjiaEntity zhuanjia, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,zhuanjia:{}",this.getClass().getName(),zhuanjia.toString());
        ZhuanjiaEntity oldZhuanjiaEntity = zhuanjiaService.selectById(zhuanjia.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        if("".equals(zhuanjia.getZhuanjiaPhoto()) || "null".equals(zhuanjia.getZhuanjiaPhoto())){
                zhuanjia.setZhuanjiaPhoto(null);
        }

            zhuanjiaService.updateById(zhuanjia);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<ZhuanjiaEntity> oldZhuanjiaList =zhuanjiaService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        zhuanjiaService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
        try {
            List<ZhuanjiaEntity> zhuanjiaList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            ZhuanjiaEntity zhuanjiaEntity = new ZhuanjiaEntity();
//                            zhuanjiaEntity.setUsername(data.get(0));                    //账户 要改的
//                            zhuanjiaEntity.setPassword("123456");//密码
//                            zhuanjiaEntity.setZhuanjiaName(data.get(0));                    //专家姓名 要改的
//                            zhuanjiaEntity.setZhuanjiaPhone(data.get(0));                    //专家手机号 要改的
//                            zhuanjiaEntity.setZhuanjiaIdNumber(data.get(0));                    //专家身份证号 要改的
//                            zhuanjiaEntity.setZhuanjiaPhoto("");//详情和图片
//                            zhuanjiaEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            zhuanjiaEntity.setZhuanjiaEmail(data.get(0));                    //专家邮箱 要改的
//                            zhuanjiaEntity.setCreateTime(date);//时间
                            zhuanjiaList.add(zhuanjiaEntity);


                            //把要查询是否重复的字段放入map中
                                //账户
                                if(seachFields.containsKey("username")){
                                    List<String> username = seachFields.get("username");
                                    username.add(data.get(0));//要改的
                                }else{
                                    List<String> username = new ArrayList<>();
                                    username.add(data.get(0));//要改的
                                    seachFields.put("username",username);
                                }
                                //专家手机号
                                if(seachFields.containsKey("zhuanjiaPhone")){
                                    List<String> zhuanjiaPhone = seachFields.get("zhuanjiaPhone");
                                    zhuanjiaPhone.add(data.get(0));//要改的
                                }else{
                                    List<String> zhuanjiaPhone = new ArrayList<>();
                                    zhuanjiaPhone.add(data.get(0));//要改的
                                    seachFields.put("zhuanjiaPhone",zhuanjiaPhone);
                                }
                                //专家身份证号
                                if(seachFields.containsKey("zhuanjiaIdNumber")){
                                    List<String> zhuanjiaIdNumber = seachFields.get("zhuanjiaIdNumber");
                                    zhuanjiaIdNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> zhuanjiaIdNumber = new ArrayList<>();
                                    zhuanjiaIdNumber.add(data.get(0));//要改的
                                    seachFields.put("zhuanjiaIdNumber",zhuanjiaIdNumber);
                                }
                        }

                        //查询是否重复
                         //账户
                        List<ZhuanjiaEntity> zhuanjiaEntities_username = zhuanjiaService.selectList(new EntityWrapper<ZhuanjiaEntity>().in("username", seachFields.get("username")));
                        if(zhuanjiaEntities_username.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(ZhuanjiaEntity s:zhuanjiaEntities_username){
                                repeatFields.add(s.getUsername());
                            }
                            return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //专家手机号
                        List<ZhuanjiaEntity> zhuanjiaEntities_zhuanjiaPhone = zhuanjiaService.selectList(new EntityWrapper<ZhuanjiaEntity>().in("zhuanjia_phone", seachFields.get("zhuanjiaPhone")));
                        if(zhuanjiaEntities_zhuanjiaPhone.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(ZhuanjiaEntity s:zhuanjiaEntities_zhuanjiaPhone){
                                repeatFields.add(s.getZhuanjiaPhone());
                            }
                            return R.error(511,"数据库的该表中的 [专家手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //专家身份证号
                        List<ZhuanjiaEntity> zhuanjiaEntities_zhuanjiaIdNumber = zhuanjiaService.selectList(new EntityWrapper<ZhuanjiaEntity>().in("zhuanjia_id_number", seachFields.get("zhuanjiaIdNumber")));
                        if(zhuanjiaEntities_zhuanjiaIdNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(ZhuanjiaEntity s:zhuanjiaEntities_zhuanjiaIdNumber){
                                repeatFields.add(s.getZhuanjiaIdNumber());
                            }
                            return R.error(511,"数据库的该表中的 [专家身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        zhuanjiaService.insertBatch(zhuanjiaList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }

    /**
    * 登录
    */
    @IgnoreAuth
    @RequestMapping(value = "/login")
    public R login(String username, String password, String captcha, HttpServletRequest request) {
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectOne(new EntityWrapper<ZhuanjiaEntity>().eq("username", username));
        if(zhuanjia==null || !zhuanjia.getPassword().equals(password))
            return R.error("账号或密码不正确");
        String token = tokenService.generateToken(zhuanjia.getId(),username, "zhuanjia", "专家");
        R r = R.ok();
        r.put("token", token);
        r.put("role","专家");
        r.put("username",zhuanjia.getZhuanjiaName());
        r.put("tableName","zhuanjia");
        r.put("userId",zhuanjia.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody ZhuanjiaEntity zhuanjia, HttpServletRequest request) {
//    	ValidatorUtils.validateEntity(user);
        Wrapper<ZhuanjiaEntity> queryWrapper = new EntityWrapper<ZhuanjiaEntity>()
            .eq("username", zhuanjia.getUsername())
            .or()
            .eq("zhuanjia_phone", zhuanjia.getZhuanjiaPhone())
            .or()
            .eq("zhuanjia_id_number", zhuanjia.getZhuanjiaIdNumber())
            ;
        ZhuanjiaEntity zhuanjiaEntity = zhuanjiaService.selectOne(queryWrapper);
        if(zhuanjiaEntity != null)
            return R.error("账户或者专家手机号或者专家身份证号已经被使用");
        zhuanjia.setCreateTime(new Date());
        zhuanjiaService.insert(zhuanjia);

        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id, HttpServletRequest request) {
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectById(id);
        zhuanjia.setPassword("123456");
        zhuanjiaService.updateById(zhuanjia);
        return R.ok();
    }

	/**
	 * 修改密码
	 */
	@GetMapping(value = "/updatePassword")
	public R updatePassword(String  oldPassword, String  newPassword, HttpServletRequest request) {
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectById((Integer)request.getSession().getAttribute("userId"));
		if(newPassword == null){
			return R.error("新密码不能为空") ;
		}
		if(!oldPassword.equals(zhuanjia.getPassword())){
			return R.error("原密码输入错误");
		}
		if(newPassword.equals(zhuanjia.getPassword())){
			return R.error("新密码不能和原密码一致") ;
		}
        zhuanjia.setPassword(newPassword);
		zhuanjiaService.updateById(zhuanjia);
		return R.ok();
	}



    /**
     * 忘记密码
     */
    @IgnoreAuth
    @RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request) {
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectOne(new EntityWrapper<ZhuanjiaEntity>().eq("username", username));
        if(zhuanjia!=null){
            zhuanjia.setPassword("123456");
            zhuanjiaService.updateById(zhuanjia);
            return R.ok();
        }else{
           return R.error("账号不存在");
        }
    }


    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrZhuanjia(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectById(id);
        if(zhuanjia !=null){
            //entity转view
            ZhuanjiaView view = new ZhuanjiaView();
            BeanUtils.copyProperties( zhuanjia , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }
    }


    /**
    * 退出
    */
    @GetMapping(value = "logout")
    public R logout(HttpServletRequest request) {
        request.getSession().invalidate();
        return R.ok("退出成功");
    }



    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        CommonUtil.checkMap(params);
        PageUtils page = zhuanjiaService.queryPage(params);

        //字典表数据转换
        List<ZhuanjiaView> list =(List<ZhuanjiaView>)page.getList();
        for(ZhuanjiaView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段

        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        ZhuanjiaEntity zhuanjia = zhuanjiaService.selectById(id);
            if(zhuanjia !=null){


                //entity转view
                ZhuanjiaView view = new ZhuanjiaView();
                BeanUtils.copyProperties( zhuanjia , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody ZhuanjiaEntity zhuanjia, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,zhuanjia:{}",this.getClass().getName(),zhuanjia.toString());
        Wrapper<ZhuanjiaEntity> queryWrapper = new EntityWrapper<ZhuanjiaEntity>()
            .eq("username", zhuanjia.getUsername())
            .or()
            .eq("zhuanjia_phone", zhuanjia.getZhuanjiaPhone())
            .or()
            .eq("zhuanjia_id_number", zhuanjia.getZhuanjiaIdNumber())
//            .notIn("zhuanjia_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ZhuanjiaEntity zhuanjiaEntity = zhuanjiaService.selectOne(queryWrapper);
        if(zhuanjiaEntity==null){
            zhuanjia.setCreateTime(new Date());
            zhuanjia.setPassword("123456");
        zhuanjiaService.insert(zhuanjia);

            return R.ok();
        }else {
            return R.error(511,"账户或者专家手机号或者专家身份证号已经被使用");
        }
    }

}


package com.controller;

import java.util.List;
import java.util.Arrays;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.UsersEntity;
import com.service.TokenService;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UsersController {
	
	@Autowired
	private UsersService usersService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		R r = R.ok();
		r.put("token", token);
		r.put("role",user.getRole());
		r.put("userId",user.getId());
		return r;
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UsersEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        usersService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}

	/**
	 * 修改密码
	 */
	@GetMapping(value = "/updatePassword")
	public R updatePassword(String  oldPassword, String  newPassword, HttpServletRequest request) {
		UsersEntity users = usersService.selectById((Integer)request.getSession().getAttribute("userId"));
		if(newPassword == null){
			return R.error("新密码不能为空") ;
		}
		if(!oldPassword.equals(users.getPassword())){
			return R.error("原密码输入错误");
		}
		if(newPassword.equals(users.getPassword())){
			return R.error("新密码不能和原密码一致") ;
		}
		users.setPassword(newPassword);
		usersService.updateById(users);
		return R.ok();
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        usersService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UsersEntity user){
        EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
    	PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UsersEntity user){
       	EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", usersService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UsersEntity user = usersService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Integer id = (Integer)request.getSession().getAttribute("userId");
        UsersEntity user = usersService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UsersEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        usersService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UsersEntity user){
//        ValidatorUtils.validateEntity(user);
        usersService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		List<UsersEntity> user = usersService.selectList(null);
		if(user.size() > 1){
			usersService.deleteBatchIds(Arrays.asList(ids));
		}else{
			return R.error("管理员最少保留一个");
		}
        return R.ok();
    }
}

  • 13
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值