pipeline_dist/wwwroot/distributor_pipeline/get_distributor_pipeline.dspy
yumoqing d483238ac5 feat: 修复工作区状态并提交CRUD生成文件
- 修复文件权限 (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)
2026-08-03 16:20:26 +08:00

143 lines
3.5 KiB
Plaintext

ns = params_kw.copy()
debug(f'get_distributor_pipeline.dspy:{ns=}')
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'created_at'
sql = '''select a.*, b.distributor_id_text, c.pipeline_id_text, d.markup_type_text, e.status_text
from (select * from distributor_pipeline where 1=1 [[filterstr]]) a left join (select id as distributor_id,
name as distributor_id_text from distributors where 1 = 1) b on a.distributor_id = b.distributor_id left join (select id as pipeline_id,
name as pipeline_id_text from pipelines where 1 = 1) c on a.pipeline_id = c.pipeline_id left join (select k as markup_type,
v as markup_type_text from appcodes_kv where parentid='markup_type') d on a.markup_type = d.markup_type left join (select k as status,
v as status_text from appcodes_kv where parentid='dp_status') e on a.status = e.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": "主键",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "distributor_id",
"title": "分销商ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "pipeline_id",
"title": "产线ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "custom_price",
"title": "自定义单价",
"type": "double",
"length": 15,
"dec": 4
},
{
"name": "markup_type",
"title": "加价方式",
"type": "str",
"length": 20
},
{
"name": "markup_value",
"title": "加价值",
"type": "double",
"length": 10,
"dec": 2
},
{
"name": "daily_limit",
"title": "日限额",
"type": "int",
"default": "0"
},
{
"name": "monthly_limit",
"title": "月限额",
"type": "int",
"default": "0"
},
{
"name": "today_usage",
"title": "今日已用",
"type": "int",
"default": "0"
},
{
"name": "month_usage",
"title": "本月已用",
"type": "int",
"default": "0"
},
{
"name": "status",
"title": "状态",
"type": "str",
"length": 20,
"default": "active"
},
{
"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)
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_dist')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}