Exemplo n.º 1
0
    def post(self):
        func = self.get_args(['appCode', 'name', 'code', 'customJson', 'remark'], '')
        func['id'] = int(self.get_arg('id', '0'))
        func['parentID'] = int(self.get_arg('parentID', '0'))
        func['sort'] = int(self.get_arg('sort', '0'))
        
        msg = self.check_str_empty_input(func, ['code', 'name', 'appCode'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return
        btype = str_helper.check_num_abc__(func['code'])
        if btype == False:
            self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线')
            return
        func['user'] = self.get_oper_user()
        if func['id'] <= 0:
            self.check_oper_right(right = state.operAdd)
            if func['parentID'] <= 0:
                func['path'] = '%s.%s' % (func['appCode'], func['code'])
            else:
                func['path'] = '%s.%s' % ((func_logic.query_one_by_id(func['parentID'])).get('path'), func['code'])
            func['status'] = state.Boole['true']

            f = func_logic.query_one_by_path(path = func['path'])
            if None != f:
                self.out_fail(code = 102003)
                return
            try:
                result = func_logic.add(appCode = func['appCode'], name = func['name'], code = func['code'], 
                            parentID = func['parentID'], path = func['path'], customJson = func['customJson'], sort = func['sort'], 
                            status = func['status'], remark = func['remark'], user = func['user'])
                nf = func_logic.query_one_by_path(func['path'])
                self.write_oper_log(action = 'funcCreate', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = '', endStatus= str_helper.json_encode(nf))
            except error.RightError as e:
                self.out_fail(code=e.code)
                return
        else:
            self.check_oper_right(right = state.operEdit)
            try:
                of = func_logic.query_one_by_id(func['id'])
                func_logic.update(id = func['id'], name = func['name'],sort = func['sort'], 
                                customJson = func['customJson'],remark = func['remark'],user = func['user'])
                nf = func_logic.query_one_by_id(func['id'])
                self.write_oper_log(action = 'funcEdit', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = str_helper.json_encode(of), endStatus= str_helper.json_encode(nf))
            except error.RightError as e:
                self.out_fail(code=e.code)
                return
        self.out_ok()
Exemplo n.º 2
0
    def post(self):
        func = self.get_args(['appCode', 'name', 'code', 'customJson', 'rights', 'remark'], '')
        func['id'] = int(self.get_arg('id', '0'))
        func['parentID'] = int(self.get_arg('parentID', '0'))
        func['sort'] = int(self.get_arg('sort', '0'))
        
        msg = self.check_str_empty_input(func, ['code', 'name', 'rights', 'appCode'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return
        btype = str_helper.check_num_abc__(func['code'])
        if btype == False:
            self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线')
            return
        func['user'] = self.get_oper_user()
        if func['id'] <= 0:
            self.check_oper_right(right = state.operAdd)
            if func['parentID'] <= 0:
                func['path'] = '%s.%s' % (func['appCode'], func['code'])
            else:
                func['path'] = '%s.%s' % ((func_logic.query_one_by_id(func['parentID'])).get('path'), func['code'])
            func['status'] = state.Boole['true']

            f = func_logic.query_one_by_path(path = func['path'])
            if None != f:
                self.out_fail(code = 102003)
                return
            try:
                result = func_logic.add(appCode = func['appCode'], name = func['name'], code = func['code'], 
                            parentID = func['parentID'], path = func['path'], rights = func['rights'], customJson = func['customJson'], sort = func['sort'], 
                            status = func['status'], remark = func['remark'], user = func['user'])
                nf = func_logic.query_one_by_path(func['path'])
                self.write_oper_log(action = 'funcCreate', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = '', endStatus= str_helper.json_encode(nf))
            except error.RightError as e:
                self.out_fail(code=e.code)
                return
        else:
            self.check_oper_right(right = state.operEdit)
            try:
                of = func_logic.query_one_by_id(func['id'])
                func_logic.update(id = func['id'], name = func['name'], sort = func['sort'], rights = func['rights'], 
                                customJson = func['customJson'], remark = func['remark'], user = func['user'])
                nf = func_logic.query_one_by_id(func['id'])
                self.write_oper_log(action = 'funcEdit', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = str_helper.json_encode(of), endStatus= str_helper.json_encode(nf))
            except error.RightError as e:
                self.out_fail(code=e.code)
                return
        self.out_ok()
Exemplo n.º 3
0
    def post(self):
        params = self.get_args(['name', 'path', 'customJson', 'rights', 'remark', 'user'], '')
        params['sort'] = int(self.get_arg('sort', '0'))
        params['status'] = int(self.get_arg('status', '0'))

        msg = self.check_str_empty_input(params, ['name', 'path', 'user'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return

        func = func_logic.query_one_by_path(path = params['path'])
        if None == func:
            self.out_fail(code = 102004)
            return

        user = user_logic.query_one_by_name(params['user'])
        if None == user:
            self.out_fail(code = 103002)

        print self.get_argument('rights')
        try:
            result = func_logic.update(id = func['id'], name = params['name'], sort = params['sort'], rights = params['rights'], 
                customJson = params['customJson'], remark = params['remark'], user = params['user'])

            if True == result:
                self.write_oper_log(action = 'funcEditInterface', targetType = 3, targetID = str(func['id']), 
                    targetName = params['name'], startStatus = '', endStatus= str_helper.json_encode(params), user = user)
                self.out_ok()
            else:
                self.out_fail(code = 101)            
        except error.RightError as e:
            self.out_fail(code=e.code)
            return
        return
        
Exemplo n.º 4
0
    def post(self):
        params = self.get_args(['appCode', 'name', 'code', 'parentPath', 'customJson', 'rights', 'remark', 'user'], '')
        params['sort'] = int(self.get_arg('sort', '0'))
        params['status'] = int(self.get_arg('status', '0'))

        msg = self.check_str_empty_input(params, ['appCode', 'name', 'code', 'parentPath', 'user'])
        if str_helper.is_null_or_empty(msg) == False:
            self.out_fail(code = 1001, msg = msg)
            return

        btype = str_helper.check_num_abc__(params['code'])
        if btype == False:
            self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线')
            return

        parent = func_logic.query_one_by_path(path = params['parentPath'])
        if None == parent:
            self.out_fail(code = 102004)
            return

        path = parent['path']+'.'+params['code']
        func = func_logic.query_one_by_path(path = path)
        if None != func:
            self.out_fail(code = 102003)
            return

        user = user_logic.query_one_by_name(params['user'])
        if None == user:
            self.out_fail(code = 103002)

        try:
            result = func_logic.add(appCode = params['appCode'], name = params['name'], 
                code = params['code'], parentID = parent['id'], path = path, rights = params['rights'],
                customJson = params['customJson'], sort = params['sort'], 
                status = params['status'], remark = params['remark'], user = params['user'])

            self.out_ok()
            
            self.write_oper_log(action = 'funcCreateInterface', targetType = 3, targetID = str(result), targetName = params['name'], startStatus = '', endStatus= str_helper.json_encode(params), user = user)
        except error.RightError as e:
            self.out_fail(code=e.code)
            return
        return