go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Questions on generating models with goctl.

Open weiailuxueqi opened this issue 1 year ago • 4 comments

image

请问,支持外部变量不,或者有什么方式可以在模板里头定义变量,如果当前table含有该变量的字段名时,才生成相应的代码。例如:当有version字段时,就生成版本号更新操作的代码。

weiailuxueqi avatar Aug 11 '22 06:08 weiailuxueqi

I agree with you

fyyang avatar Aug 11 '22 10:08 fyyang

image

请问,支持外部变量不,或者有什么方式可以在模板里头定义变量,如果当前table含有该变量的字段名时,才生成相应的代码。例如:当有version字段时,就生成版本号更新操作的代码。

你这个功能需要你自己修改定制goctl功能

jsonMark avatar Aug 18 '22 02:08 jsonMark

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


image

Excuse me, does it support external variables, or is there any way to define variables in the template, if the current table contains the field name of the variable, the corresponding code will be generated. For example, when there is a version field, the code for the version number update operation is generated.

Your function requires you to modify the custom goctl function yourself

Issues-translate-bot avatar Aug 18 '22 02:08 Issues-translate-bot

外部变量获取比较复杂,实用性低,以目前看来暂不会支持

It is difficult to get external variables, and there has no more improvements for this change, so it would't be supported so far.

kesonan avatar Aug 21 '22 14:08 kesonan