Skip to content

gf gen dao: 数据库表设计的字段名字不重复,生成的结构体重复,怎么处理? #4525

@buexplain

Description

@buexplain

What do you want to ask?

表设计:

CREATE TABLE `info` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `updateTime` timestamp NULL DEFAULT NULL COMMENT '记录更新时间',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='智能相关数据';

生成的结构体:

type Info struct {
  Id           uint        `json:"id"           orm:"id"            description:"自增ID"`                                                    // 自增ID
  UpdateTime   *gtime.Time `json:"updateTime"   orm:"updateTime"    description:"记录更新时间"`                                                  // 记录更新时间
  UpdateTime   *gtime.Time `json:"updateTime"   orm:"update_time"   description:"更新时间"`                                                    // 更新时间
}

我的问题是,能不能加个控制参数,字段名字与结构体名字保持一致,但是结构体的字段名字首字母大写,
类似生成于如下结构体:

type Info struct {
  Id           uint        `json:"id"           orm:"id"            description:"自增ID"`                                                    // 自增ID
  UpdateTime *gtime.Time `json:"updateTime"   orm:"updateTime"    description:"记录更新时间"`                                                  // 记录更新时间
  Update_time *gtime.Time `json:"update_time"   orm:"update_time"   description:"更新时间"`                                                    // 更新时间
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions