feat(generator): 添加代码生成模板常量定义

- 新增 consts.go 定义 DO NOT EDIT 标记常量
- 添加控制器生成模板相关常量定义
- 添加 SDK 客户端生成模板常量定义
- 添加数据访问对象(DAO)生成模板常量定义
- 添加枚举、协议缓冲区实体和服务生成模板常量定义
- 添加数据库表字段定义模板常量定义
This commit is contained in:
maguodong
2026-04-08 14:11:46 +08:00
parent d01b2973df
commit fd1a6686b1
34 changed files with 3389 additions and 7 deletions
+4 -6
View File
@@ -717,12 +717,10 @@ func (c *Core) MarshalJSON() ([]byte, error) {
// writeSqlToLogger outputs the Sql object to logger.
// It is enabled only if configuration "debug" is true.
func (c *Core) writeSqlToLogger(ctx context.Context, sql *Sql) {
func (c *Core) writeSqlToLogger(sql *Sql) {
var transactionIdStr string
if sql.IsTransaction {
if v := ctx.Value(transactionIdForLoggerCtx); v != nil {
transactionIdStr = fmt.Sprintf(`[txid:%d] `, v.(uint64))
}
transactionIdStr = fmt.Sprintf(`[tx] `)
}
s := fmt.Sprintf(
"[%3d ms] [%s] [%s] [rows:%-3d] %s%s",
@@ -730,9 +728,9 @@ func (c *Core) writeSqlToLogger(ctx context.Context, sql *Sql) {
)
if sql.Error != nil {
s += "\nError: " + sql.Error.Error()
c.logger.Error(ctx, s)
c.logger.Error(s)
} else {
c.logger.Debug(ctx, s)
c.logger.Debug(s)
}
}
+1 -1
View File
@@ -307,7 +307,7 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp
// Logging.
if c.db.GetDebug() {
c.writeSqlToLogger(ctx, sqlObj)
c.writeSqlToLogger(sqlObj)
}
if err != nil && err != sql.ErrNoRows {
err = gerror.WrapCode(