- 修复文件权限 (600→644) - 删除调试日志 (global_func.py) - 添加 CRUD 生成的 wwwroot 文件 (pipeline_core/dist/ops) - 添加 mysql.ddl.sql 文件 - 更新 pyproject.toml 配置 - 添加 showcase 模块安装 (build.sh) - 更新 index.ui (sidebar toggle + 管理按钮) - 设置 start.sh/stop.sh 可执行权限 - 添加 wwwroot 符号链接 (appbase/rbac/pipeline_sdlc) - 更新 .gitignore (排除 pkgs/bricks/pipeline.pid)
165 lines
3.7 KiB
Plaintext
165 lines
3.7 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
|
|
userorgid = await get_userorgid()
|
|
if not userorgid:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Authorization Error",
|
|
"timeout":3,
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"message":"Please login"
|
|
}
|
|
}
|
|
ns['org_id'] = userorgid
|
|
ns['userorgid'] = userorgid
|
|
|
|
debug(f'get_pipelines.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
|
|
ns['sort'] = 'created_at'
|
|
|
|
|
|
|
|
sql = '''select a.*, b.pipeline_type_text, c.status_text
|
|
from (select * from pipelines where 1=1 [[filterstr]]) a left join (select k as pipeline_type,
|
|
v as pipeline_type_text from appcodes_kv where parentid='pipeline_type') b on a.pipeline_type = b.pipeline_type left join (select k as status,
|
|
v as status_text from appcodes_kv where parentid='pipeline_status') c on a.status = c.status'''
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if filterjson and isinstance(filterjson, str):
|
|
try:
|
|
filterjson = json.loads(filterjson)
|
|
except (json.JSONDecodeError, TypeError):
|
|
filterjson = None
|
|
fields_str=r'''[
|
|
{
|
|
"name": "id",
|
|
"title": "id",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "name",
|
|
"title": "产线名称",
|
|
"type": "str",
|
|
"length": 200,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "description",
|
|
"title": "产线描述",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "pipeline_type",
|
|
"title": "产线类型",
|
|
"type": "str",
|
|
"length": 50,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "version",
|
|
"title": "当前版本",
|
|
"type": "str",
|
|
"length": 20,
|
|
"default": "1.0.0"
|
|
},
|
|
{
|
|
"name": "status",
|
|
"title": "状态",
|
|
"type": "str",
|
|
"length": 20,
|
|
"nullable": "no",
|
|
"default": "draft"
|
|
},
|
|
{
|
|
"name": "pipeline_config",
|
|
"title": "产线配置JSON",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "model_api_url",
|
|
"title": "模型API地址",
|
|
"type": "str",
|
|
"length": 500
|
|
},
|
|
{
|
|
"name": "model_api_key",
|
|
"title": "模型API密钥",
|
|
"type": "str",
|
|
"length": 500
|
|
},
|
|
{
|
|
"name": "org_id",
|
|
"title": "所属机构ID",
|
|
"type": "str",
|
|
"length": 32,
|
|
"default": "0"
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"title": "创建人",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"title": "创建时间",
|
|
"type": "timestamp"
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"title": "更新时间",
|
|
"type": "timestamp"
|
|
}
|
|
]'''
|
|
ori_fields = json.loads(fields_str)
|
|
if not filterjson:
|
|
fields = [ f['name'] for f in ori_fields ]
|
|
filterjson = default_filterjson(fields, ns)
|
|
|
|
# 确保 logined 过滤条件始终生效
|
|
if filterjson:
|
|
if not isinstance(filterjson, dict) or 'AND' not in filterjson:
|
|
filterjson = {'AND': [filterjson] if filterjson else []}
|
|
|
|
filterjson['AND'].append({'field': 'org_id', 'op': '=', 'var': '__logined_orgid__'})
|
|
ns['__logined_orgid__'] = userorgid
|
|
|
|
|
|
|
|
filterdic = ns.copy()
|
|
filterdic['filterstr'] = ''
|
|
filterdic['userorgid'] = '${userorgid}$'
|
|
filterdic['userid'] = '${userid}$'
|
|
if filterjson:
|
|
dbf = DBFilter(filterjson)
|
|
conds = dbf.gen(ns)
|
|
if conds:
|
|
ns.update(dbf.consts)
|
|
conds = f' and {conds}'
|
|
filterdic['filterstr'] = conds
|
|
ac = ArgsConvert('[[', ']]')
|
|
vars = ac.findAllVariables(sql)
|
|
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
|
|
filterdic.update(NameSpace)
|
|
sql = ac.convert(sql, filterdic)
|
|
|
|
debug(f'{sql=}')
|
|
db = DBPools()
|
|
dbname = get_module_dbname('pipeline_core')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |