欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Java毕业设计实战之教室预订管理系统的实现

程序员文章站 2022-03-03 09:18:17
一、项目运行环境配置:jdk1.8 + tomcat8.5 + mysql + hbuilderx(webstorm也行)+ eclispe(intellij idea,eclispe,myeclis...

一、项目运行

环境配置:

jdk1.8 + tomcat8.5 + mysql + hbuilderx(webstorm也行)+ eclispe(intellij idea,eclispe,myeclispe,sts都支持)。

项目技术:

spring + springboot+ mybatis + maven + vue 等等组成,b/s模式 + maven管理等等。

Java毕业设计实战之教室预订管理系统的实现

Java毕业设计实战之教室预订管理系统的实现

Java毕业设计实战之教室预订管理系统的实现

Java毕业设计实战之教室预订管理系统的实现

Java毕业设计实战之教室预订管理系统的实现

Java毕业设计实战之教室预订管理系统的实现

用户管理控制器:

/**
 * 用户管理控制器
 */
@requestmapping("/user/")
@controller
public class usercontroller {
    @autowired
    private iuserservice userservice;
    @autowired
    private iroleservice roleservice;
 
    @resource
    private processengineconfiguration configuration;
    @resource
    private processengine engine;
 
    @getmapping("/index")
    @apioperation("跳转用户页接口")
    @preauthorize("hasrole('管理员')")
    public string index(string menuid,model model){
        list<role> roles = queryallrole();
        model.addattribute("roles",roles);
        model.addattribute("menuid",menuid);
        //用户首页
        return "views/user/user_list";
    }
 
    @getmapping("/listpage")
    @apioperation("查询用户分页数据接口")
    @apiimplicitparams({
            @apiimplicitparam(name = "userquery", value = "用户查询对象", defaultvalue = "userquery对象")
    })
    @responsebody
    @preauthorize("hasrole('管理员')")
    public pagelist listpage(userquery userquery){
        return  userservice.listpage(userquery);
    }
 
    //添加用户
    @postmapping("/adduser")
    @apioperation("添加用户接口")
    @responsebody
    public map<string,object> adduser(user user){
        map<string, object> ret = new hashmap<>();
        ret.put("code",-1);
        if(stringutils.isempty(user.getusername())){
            ret.put("msg","请填写用户名");
            return ret;
        }
        if(stringutils.isempty(user.getpassword())){
            ret.put("msg","请填写密码");
            return ret;
        }
        if(stringutils.isempty(user.getemail())){
            ret.put("msg","请填写邮箱");
            return ret;
        }
        if(stringutils.isempty(user.gettel())){
            ret.put("msg","请填写手机号");
            return ret;
        }
        if(stringutils.isempty(user.getheadimg())){
            ret.put("msg","请上传头像");
            return ret;
        }
        if(userservice.adduser(user)<=0) {
            ret.put("msg", "添加用户失败");
            return ret;
        }
        ret.put("code",0);
        ret.put("msg","添加用户成功");
        return ret;
    }
 
    /**
     * 修改用户信息操作
     * @param user
     * @return
     */
    @postmapping("/editsaveuser")
    @apioperation("修改用户接口")
    @preauthorize("hasrole('管理员')")
    @responsebody
    public message editsaveuser(user user){
        if(stringutils.isempty(user.getusername())){
          return message.error("请填写用户名");
        }
        if(stringutils.isempty(user.getemail())){
            return message.error("请填写邮箱");
        }
        if(stringutils.isempty(user.gettel())){
            return message.error("请填写手机号");
        }
        try {
            userservice.editsaveuser(user);
            return message.success();
        } catch (exception e) {
            e.printstacktrace();
            return message.error("修改用户信息失败");
        }
 
    }
 
    //添加用户
    @getmapping("/deleteuser")
    @apioperation("删除用户接口")
    @apiimplicitparams({
            @apiimplicitparam(name = "id", value = "如:88",required = true)
    })
    @preauthorize("hasrole('管理员')")
    @responsebody
    public ajaxresult deleteuser(@requestparam(required = true) long id){
        ajaxresult ajaxresult = new ajaxresult();
        try {
            userservice.deleteuser(id);
        } catch (exception e) {
            e.printstacktrace();
            return new ajaxresult("删除失败");
        }
 
        return ajaxresult;
    }
 
    @postmapping(value="/deletebatchuser")
    @apioperation("批量删除用户接口")
    @preauthorize("hasrole('管理员')")
    @responsebody
    public ajaxresult deletebatchuser(string ids){
        string[] idsarr = ids.split(",");
        list list = new arraylist();
        for(int i=0;i<idsarr.length;i++){
            list.add(idsarr[i]);
        }
        try{
            userservice.batchremove(list);
            return new ajaxresult();
        }catch(exception e){
           return new ajaxresult("批量删除失败");
        }
    }
 
    //查询所有角色
    public list<role> queryallrole(){
        return roleservice.queryall();
    }
 
    //添加用户的角色
    @postmapping("/adduserrole")
    @apioperation("添加用户角色接口")
    @apiimplicitparams({
            @apiimplicitparam(name = "parammap", value = "如:{userid:1,[1,2,3,4]]}")
    })
    @responsebody
    public ajaxresult adduserrole(@requestbody map parammap){
        ajaxresult ajaxresult = new ajaxresult();
        string userid = (string)parammap.get("userid");
        list roleids = (list) parammap.get("roleids");
        try {
            //添加用户对应的角色
            roleservice.adduserrole(userid,roleids);
            return ajaxresult;
        }catch (exception e){
            e.printstacktrace();
            return new ajaxresult("保存角色失败");
        }
 
    }
 
 
 
 
    //添加用户
    @requestmapping("/regsaveuser")
    @responsebody
    public long addteacher(user user){
        system.out.println("保存用户...."+user);
        userservice.adduser(user);
 
        //保存工作流程操作
        identityservice is = engine.getidentityservice();
        // 添加用户组
        org.activiti.engine.identity.user userinfo = userservice.saveuser(is, user.getusername());
        // 添加用户对应的组关系
        group stugroup = new groupentityimpl();
        stugroup.setid("stugroup");
        group tgroup = new groupentityimpl();
        tgroup.setid("tgroup");
        if(user.gettype() == 2) {
            //保存老师组
            userservice.saverel(is, userinfo, tgroup);
        }
        if(user.gettype() == 3) {
            //保存学生组
            userservice.saverel(is, userinfo, stugroup);
        }
 
        long userid = user.getid();
        return userid;
    }
 
    /**
     * 修改密码页面
     * @return
     */
    @requestmapping(value="/update_pwd",method=requestmethod.get)
    public string updatepwd(){
        return "views/user/update_pwd";
    }
 
    /**
     * 修改密码操作
     * @param oldpwd
     * @param newpwd
     * @return
     */
    @responsebody
    @postmapping("/update_pwd")
    public message updatepassword(@requestparam(name="oldpwd",required=true)string oldpwd,
                                  @requestparam(name="newpwd",required=true)string newpwd){
        string username = commonutils.getloginuser().getusername();
        user userbyusername = userservice.finduserbyusername(username);
        if(userbyusername!=null){
            string password = userbyusername.getpassword();
            bcryptpasswordencoder bcryptpasswordencoder = new bcryptpasswordencoder();
            boolean matches = bcryptpasswordencoder.matches(oldpwd, password);
            if(!matches){
                return message.error("旧密码不正确");//true
            }
            userbyusername.setpassword(bcryptpasswordencoder.encode(newpwd));
 
            if(userservice.edituserpassword(userbyusername)<=0){
                return message.error("密码修改失败");
            }
        }
        return message.success();
    }
 
    /**
     * 清除缓存
     * @param request
     * @param response
     * @return
     */
    @responsebody
    @postmapping("/clear_cache")
    public message clearcache(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {
        response.setheader("cache-control","no-store");
        response.setheader("pragrma","no-cache");
        response.setdateheader("expires",0);
      return  message.success();
    }
}

角色管理控制层:

@controller
public class rolecontroller {
 
    @autowired
    private iroleservice roleservice;
 
    @autowired
    private ipermissionservice permissionservice;
 
 
 
 
    @preauthorize("hasrole('管理员')")
    @responsebody
    @requestmapping("/role/doadd")
    public string doadd(role role){
        //角色添加
        return "ok";
    }
    //添加角色
    @requestmapping("/role/addrole")
    @preauthorize("hasrole('管理员')")
    @responsebody
    public ajaxresult addrole(role role){
        system.out.println("保存角色...."+role);
        try {
            roleservice.saverole(role);
            return new ajaxresult();
        } catch (exception e) {
            e.printstacktrace();
            return new ajaxresult("操作失败");
        }
    }
 
    @preauthorize("hasrole('管理员')")
    @requestmapping("/role/index")
    public string index(model model){
        list<permission> permisisons = permissionservice.findallpermisisons();
        model.addattribute("permissions",permisisons);
        //返回角色
        return "views/role/role_list";
    }
 
    @requestmapping("/role/listpage")
    @responsebody
    public pagelist listpage(rolequery rolequery){
        system.out.println("传递参数:"+rolequery);
        return  roleservice.listpage(rolequery);
    }
 
 
    //修改用户editsaveuser
    @requestmapping("/role/editsaverole")
    @responsebody
    public ajaxresult editsaverole(role role){
        system.out.println("修改角色...."+role);
        try {
            roleservice.editsaverole(role);
            return new ajaxresult();
        } catch (exception e) {
            e.printstacktrace();
        }
        return new ajaxresult("修改失败");
    }
 
    //添加角色
    @requestmapping("/role/deleterole")
    @responsebody
    public ajaxresult deleterole(long id){
        system.out.println("删除角色...."+id);
        ajaxresult ajaxresult = new ajaxresult();
        try {
            roleservice.deleterole(id);
        } catch (exception e) {
            e.printstacktrace();
            return new ajaxresult("删除失败");
        }
        return ajaxresult;
    }
 
    //添加角色权限 addrolepermission
    @requestmapping("/role/addrolepermission")
    @responsebody
    public ajaxresult addrolepermission(@requestbody map parammap){
        ajaxresult ajaxresult = new ajaxresult();
        string roleid = (string)parammap.get("roleid");
        list permissionids = (list) parammap.get("permissionids");
        try {
            //添加角色对应的权限
            roleservice.addrolepermission(roleid,permissionids);
            return ajaxresult;
        }catch (exception e){
            e.printstacktrace();
            return new ajaxresult("保存权限失败");
        }
 
    }
 
}

到此这篇关于java毕业设计实战之教室预订管理系统的实现的文章就介绍到这了,更多相关java 教室预订管理内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!