packServer/backend/app/model/sys_config.js
liufumingren bd2363bf00 chore: 初始化仓库(backend / frontend / extension 三块)
- backend/:Egg 3 纯 JSON 接口服务(MySQL 8 + Redis),全部走 header 令牌鉴权;
  已彻底去掉服务端渲染(删除 page 控制器 / app/view / nunjucks / session / CSRF),
  开发时把页面请求反代到前端 dev server,生产托管 frontend/dist(SPA 回退)。
  单测 91 个通过(不需要本机数据库)。
- frontend/:Vite + Vue3 + TypeScript 的 SPA(登录 / 注册 / 找回密码 / 扫码登录与确认 /
  首页统计 / 设备管理 / 扫码记录 / 个人中心 / 测试页),vue-tsc 类型检查与构建通过。
- extension/:MV3 浏览器扩展(零构建),注入第三方 WMS 页面识别运单号并打开溯源页。
- 忽略规则统一放根 .gitignore:node_modules、dist、logs / logs-*、run、typings、
  .env*、config.local.js(含本机数据库与 Redis 密码,绝不入库)。
2026-10-17 08:50:32 +08:00

31 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 系统配置表模型(sys_config)
*
* 通用 key-value 配置:group_name + config_key 唯一定位一条配置,
* value_type 决定 config_value 的解析方式(string / number / boolean / json)。
*
* 注意:唯一性由 service 层保证(先查后写),不建唯一索引 ——
* 因为本表用 deleted_at 软删除,唯一索引会被已删除的记录占用,导致同 key 无法重建。
*/
module.exports = (app) => {
const { BIGINT, STRING, TEXT, TINYINT } = app.Sequelize;
const SysConfig = app.model.define('sysConfig', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
groupName: { type: STRING(64), allowNull: false, defaultValue: 'default', comment: '分组' },
configKey: { type: STRING(128), allowNull: false, comment: '配置键' },
configValue: { type: TEXT, comment: '配置值' },
valueType: { type: STRING(16), allowNull: false, defaultValue: 'string', comment: 'string/number/boolean/json' },
remark: { type: STRING(255), comment: '备注' },
status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
}, {
tableName: 'sys_config',
paranoid: true,
comment: '系统配置表',
});
return SysConfig;
};