def add():
    myRes = MyResponse()
    DPT_PKEY = MyRequest.get_verify_empty("DPT_PKEY", errmsg="请选择一个父节点")
    DPT_NAME = MyRequest.get_verify_empty("DPT_NAME", errmsg="部门名称不能为空")
    DPT_SOFT = MyRequest.get("DPT_SOFT", type=int)
    try:
        mybrother = db_session.query(DptInfo.DPT_KEY).filter(DptInfo.DPT_PKEY == DPT_PKEY).all()
        if mybrother:
            array_id = [int(x.DPT_KEY) for x in mybrother]
            ###取最大的ID
            DPT_KEY = str(max(array_id) + 1)
        elif DPT_PKEY=="0":
            DPT_KEY = "101"
        else:
            DPT_KEY=DPT_PKEY+"001"
        dpt = DptInfo()
        dpt.DPT_KEY=DPT_KEY
        dpt.DPT_PKEY = DPT_PKEY
        dpt.DPT_NAME = DPT_NAME
        dpt.DPT_SOFT = DPT_SOFT
        MySqlalchemy.comAdd(dpt)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg=ResState.ERROR_DB
    return myRes.to_json()
def add():
    myRes = MyResponse()
    OPER_NAME = MyRequest.get_verify_empty("OPER_NAME", errmsg="操作名称不能为空")
    OPER_PKEY = MyRequest.get_verify_empty("OPER_PKEY", errmsg="OPER_PKEY不能为空")
    OPER_URL = MyRequest.get("OPER_URL", type=str)
    OPER_TYPE = MyRequest.get("OPER_TYPE", type=int)
    OPER_SOFT = MyRequest.get("OPER_SOFT", type=int)
    try:
        mybrother = db_session.query(
            OperInfo.OPER_KEY).filter(OperInfo.OPER_PKEY == OPER_PKEY).all()
        if mybrother:
            array_id = [int(x.OPER_KEY) for x in mybrother]
            ###取最大的ID
            OPER_KEY = str(max(array_id) + 1)
        elif OPER_PKEY == "0":
            OPER_KEY = "101"
        else:
            OPER_KEY = OPER_PKEY + "001"
        operInfo = OperInfo()
        operInfo.OPER_KEY = OPER_KEY
        operInfo.OPER_NAME = OPER_NAME
        operInfo.OPER_URL = OPER_URL
        operInfo.OPER_TYPE = OPER_TYPE
        operInfo.OPER_PKEY = OPER_PKEY
        operInfo.OPER_SOFT = OPER_SOFT
        MySqlalchemy.comAdd(operInfo)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
def add():
    myRes = MyResponse()
    MENU_NAME = MyRequest.get_verify_empty("MENU_NAME", errmsg="菜单名称不能为空")
    MENU_PKEY = MyRequest.get_verify_empty("MENU_PKEY", errmsg="MENU_PKEY")
    MENU_URL = MyRequest.get("MENU_URL", type=str)
    MENU_ICON = MyRequest.get("MENU_ICON", type=str)
    MENU_SOFT = MyRequest.get("MENU_SOFT", type=str)
    try:
        mybrother = db_session.query(
            MenuInfo.MENU_KEY).filter(MenuInfo.MENU_PKEY == MENU_PKEY).all()
        if mybrother:
            array_id = [int(x.MENU_KEY) for x in mybrother]
            ###取最大的ID
            MENU_KEY = str(max(array_id) + 1)
        elif MENU_PKEY == "0":
            MENU_KEY = "101"
        else:
            MENU_KEY = MENU_PKEY + "001"
        menu = MenuInfo()
        menu.MENU_KEY = MENU_KEY
        menu.MENU_NAME = MENU_NAME
        menu.MENU_PKEY = MENU_PKEY
        menu.MENU_URL = MENU_URL
        menu.MENU_ICON = MENU_ICON
        menu.MENU_SOFT = MENU_SOFT
        MySqlalchemy.comAdd(menu)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = str(ex)
    return myRes.to_json()
Example #4
0
def login_logger(oper_descript=""):
    logLogin = LogLogin()
    logLogin.USER_KEY = g.FuserId
    logLogin.IP_ADDRESS = request.remote_addr
    logLogin.TIME_CREATE = getSysDateTime()
    logLogin.DESCRIPT = oper_descript
    try:
        MySqlalchemy.comAdd(logLogin)
    except SQLAlchemyError as ex:
        mylog.error(ex)
def add():
    myRes = MyResponse()
    ROLE_NAME = MyRequest.get_verify_empty("ROLE_NAME")
    DESCRIPT = MyRequest.get("DESCRIPT")
    try:
        role = RoleInfo()
        role.ROLE_NAME = ROLE_NAME
        role.DESCRIPT = DESCRIPT
        role.TIME_CREATE = getSysDateTime()
        role.TIME_MODIFY = getSysDateTime()
        MySqlalchemy.comAdd(role)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except MyError as ex:
        myRes.msg = ex
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = ResState.ERROR_DB
    return myRes.to_json()
Example #6
0
def add():
    myRes = MyResponse()
    user = UserInfo()
    user.LOGIN_NAME = MyRequest.get_verify_empty("LOGIN_NAME",
                                                 errmsg="用户名不能为空")
    user.USER_NAME = MyRequest.get_verify_empty("USER_NAME", errmsg="姓名不能为空")
    user.USER_SEX = MyRequest.get("USER_SEX", type=int)
    user.DPT_KEY = MyRequest.get_verify_empty("DPT_KEY", errmsg="DPT_KEY不能为空")
    user.set_password("123456")
    user.USER_POSITION = MyRequest.get("USER_POSITION", type=str)
    user.PHONE = MyRequest.get("PHONE", type=str)
    user.TIME_CREATE = getSysDateTime()
    user.TIME_MODIFY = getSysDateTime()
    try:
        MySqlalchemy.comAdd(user)
        myRes.code = ResState.HTTP_SUCCESS
        myRes.msg = "操作成功"
    except SQLAlchemyError as ex:
        mylog.error(ex)
        myRes.msg = ResState.ERROR_DB
    return myRes.to_json()
Example #7
0
 def wrapper(*args, **kargs):
     responseInfo = func()
     ###操作成功后,记录操作日志
     if json.loads(responseInfo.data)["code"] == ResState.HTTP_SUCCESS:
         try:
             logOper = LogOper()
             logOper.USER_KEY = g.USER_KEY
             logOper.IP_ADDRESS = request.remote_addr
             logOper.LOGO_FUNC = "function(name=%s,args=%s,kargs=%s)" % (
                 func.__name__, args, kargs)
             logOper.LOGO_REQ_PARAMS = json.dumps(MyRequest.getAll())
             logOper.TIME_CREATE = getSysDateTime()
             logOper.DESCRIPT = oper_descript
             try:
                 MySqlalchemy.comAdd(logOper)
             except SQLAlchemyError as ex:
                 mylog.error(ex)
         except:
             print(sys.exc_info())
             pass
     return responseInfo