Example #1
0
def get_tree_by_userid(p_username):
    try:
        result = {}
        v_html = ""
        d_user = get_user_by_loginame(p_username)
        db = get_connection()
        cr = db.cursor()
        sql1 = """select id,name,icon
                from t_xtqx 
                 where parent_id ='0' and status='1'
                  and  id in(select distinct parent_id from t_xtqx 
                             where id in(select b.priv_id 
                                        from t_user_role a ,t_role_privs b,t_role c
                                         where a.role_id=b.role_id                                          
                                           and a.role_id=c.id and c.status='1'
                                           and a.user_id='{0}' 
                                         ))
                order by id""".format(d_user['userid'])

        sql2 = """select id,name,url 
                    from t_xtqx 
                       where parent_id ='{0}' and status='1'
                         and id IN(select b.priv_id 
                                   from t_user_role a ,t_role_privs b,t_role c
                                   where a.role_id=b.role_id
                                     and a.role_id=c.id and c.status='1'
                                     and a.user_id='{1}')
                        order by id"""

        cr.execute(sql1)
        rs1 = cr.fetchall()
        v_menu_header = """
                      <li class="has_sub">
                         <a href="javascript:void(0);" class="waves-effect"><i class="{0}"></i><span>{1}</span> <span class="menu-arrow"></span></a>
                         <ul class="list-unstyled">
                      """
        v_menu_footer = """</ul>
                      </li>
                      """
        for i in range(len(rs1)):
            cr.execute(sql2.format(rs1[i][0], d_user['userid']))
            rs2 = cr.fetchall()
            v_node = v_menu_header.format(rs1[i][2], rs1[i][1])
            v_html = v_html + v_node
            for j in range(len(rs2)):
                v_node = """<li><a id="{0}" class="file" href="#">{1}</a></li>""".format(
                    rs2[j][2], rs2[j][1])
                v_html = v_html + "\n" + v_node
            v_html = v_html + "\n" + v_menu_footer + "\n"
        #print('get_tree_by_userid=',v_html)
        #sys.exit(0)
        cr.close()
        result['code'] = '0'
        result['message'] = v_html
    except:
        result['code'] = '-1'
        result['message'] = '加载失败!'
    return result
Example #2
0
 def post(self):
     self.set_header("Content-Type", "application/json; charset=UTF-8")
     logon_name = str(self.get_secure_cookie("username"), encoding="utf-8")
     user = get_user_by_loginame(logon_name)
     dbid = self.get_argument("dbid")
     cdb = self.get_argument("cur_db")
     sql = self.get_argument("sql")
     desc = self.get_argument("desc")
     type = self.get_argument("type")
     result = check_sql(dbid, cdb, sql, desc, user, type)
     self.write({"code": result['code'], "message": result['message']})
Example #3
0
 def post(self):
     self.set_header("Content-Type", "application/json; charset=UTF-8")
     logon_name = str(self.get_secure_cookie("username"), encoding="utf-8")
     user = get_user_by_loginame(logon_name)
     dbid = self.get_argument("dbid")
     sql = self.get_argument("sql")
     curdb = self.get_argument("cur_db")
     v_list = query_check_result(user)
     v_dict = {"data": v_list}
     v_json = json.dumps(v_dict)
     self.write(v_json)
Example #4
0
 def post(self):
     unlock_password = self.get_argument("unlock_password")
     username = str(self.get_secure_cookie("username"), encoding="utf-8")
     d_user = get_user_by_loginame(username)
     if d_user['password'] == unlock_password:
         self.set_secure_cookie("screen_lock_status", 'unlock')
         self.set_secure_cookie("heartbeat",
                                'health',
                                expires=time.time() + 300)
         self.write({"code": 0})
     else:
         self.write({"code": -1})
Example #5
0
def get_dss_sql_release(logon_name):
    db = get_connection()
    cr = db.cursor()
    d_user = get_user_by_loginame(logon_name)
    sql = """select cast(id as char) as id,a.db_desc as name 
                  -- concat(b.dmmc,':/',ip,':',port,'/',service) as name 
           from t_db_source a,t_dmmx b
           where a.db_type=b.dmm and b.dm='02' and a.status='1'
               and (select proj_id from t_user_proj_privs where proj_id=a.id and user_id='{0}' and priv_id='2')
        """.format(d_user['userid'])
    print(sql)
    cr.execute(sql)
    v_list = []
    for r in cr.fetchall():
        v_list.append(list(r))
    cr.close()
    db.commit()
    return v_list
Example #6
0
 def get(self):
     username = str(self.get_secure_cookie("username"), encoding="utf-8")
     userid = str(self.get_secure_cookie("userid"), encoding="utf-8")
     d_user = get_user_by_loginame(username)
     genders = get_dmm_from_dm('04')
     depts = get_dmm_from_dm('01')
     proj_groups = get_dmm_from_dm('18')
     print('index->userid=', userid)
     if username:
         self.render("index.html",
                     china_rq=china_rq(),
                     china_week=china_week(),
                     china_time=china_time(),
                     welcome=welcome(d_user['username']),
                     userid=d_user['userid'],
                     loginname=d_user['loginname'],
                     wkno=d_user['wkno'],
                     username=d_user['username'],
                     password=d_user['password'],
                     gender=d_user['gender'],
                     email=d_user['email'],
                     phone=d_user['phone'],
                     proj_group=d_user['project_group'],
                     dept=d_user['dept'],
                     expire_date=d_user['expire_date'],
                     status=d_user['status'],
                     file_path=d_user['file_path'],
                     file_name=d_user['file_name'],
                     user_image=d_user['file_path'] + '/' +
                     d_user['file_name'],
                     user_roles=get_user_roles(userid),
                     genders=genders,
                     depts=depts,
                     d_user=d_user,
                     proj_groups=proj_groups,
                     view_url=self.get_secure_cookie("view_url"))
     else:
         self.render("page-404.html")
Example #7
0
 def post(self):
     username = self.get_argument("username")
     password = self.get_argument("password")
     verify_code = self.get_argument("verify_code")
     verify_img = str(self.get_secure_cookie("verify_img"),
                      encoding="utf-8")
     result = logon_user_check(username, password, verify_code, verify_img)
     if result['code'] == '0':
         d_user = get_user_by_loginame(username)
         self.set_secure_cookie("username",
                                username,
                                expires=time.time() + 1800)
         self.set_secure_cookie("userid",
                                d_user['userid'],
                                expires=time.time() + 1800)
         self.set_secure_cookie("screen_lock_status", 'unlock')
         self.set_secure_cookie("heartbeat",
                                'health',
                                expires=time.time() + 300)
     self.write({
         "code": result['code'],
         "message": result['message'],
         "url": result['url']
     })