diff --git a/README.md b/README.md index 02bf6b1..d7deec6 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,10 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 * 生成代码示例 ```go + package nocache + import ( "encoding/json" - "time" "github.com/wenj91/gobatis" ) @@ -51,12 +52,12 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 WithConn(conn gobatis.GoBatis) TestUserInfoModel Insert(data *TestUserInfo) (id int64, affected int64, err error) InsertSelective(data *TestUserInfo) (id int64, affected int64, err error) - FindOne(id int64) (*TestUserInfo, error) - FindOneByNanosecond(nanosecond int64) (*TestUserInfo, error) + FindOne(id gobatis.NullInt64) (*TestUserInfo, error) + FindOneByNanosecond(nanosecond gobatis.NullInt64) (*TestUserInfo, error) FindSelective(data *TestUserInfo) (*TestUserInfoFindResult, error) Update(data *TestUserInfo) (affected int64, err error) UpdateSelective(data *TestUserInfo) (affected int64, err error) - Delete(id int64) (affected int64, err error) + Delete(id gobatis.NullInt64) (affected int64, err error) } defaultTestUserInfoModel struct { @@ -65,12 +66,16 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 } TestUserInfo struct { - Id int64 `field:"id" json:"id"` - Nanosecond int64 `field:"nanosecond" json:"nanosecond"` - Data string `field:"data" json:"data"` - Content gobatis.NullString `field:"content" json:"content"` - CreateTime time.Time `field:"create_time" json:"createTime"` - UpdateTime time.Time `field:"update_time" json:"updateTime"` + Id gobatis.NullInt64 `field:"id" json:"id"` + Nanosecond gobatis.NullInt64 `field:"nanosecond" json:"nanosecond"` + Data gobatis.NullString `field:"data" json:"data"` + Content gobatis.NullString `field:"content" json:"content"` + StartCreateTime gobatis.NullTime `json:"startCreateTime"` + EndCreateTime gobatis.NullTime `json:"endCreateTime"` + CreateTime gobatis.NullTime `field:"create_time" json:"createTime"` + StartUpdateTime gobatis.NullTime `json:"startUpdateTime"` + EndUpdateTime gobatis.NullTime `json:"endUpdateTime"` + UpdateTime gobatis.NullTime `field:"update_time" json:"updateTime"` } ) @@ -131,7 +136,7 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 return } - func (m *defaultTestUserInfoModel) FindOne(id int64) (*TestUserInfo, error) { + func (m *defaultTestUserInfoModel) FindOne(id gobatis.NullInt64) (*TestUserInfo, error) { var resp *TestUserInfo err := m.conn.Select(m.method("findOne"), map[string]interface{}{ "Id": id, @@ -139,7 +144,7 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 return resp, err } - func (m *defaultTestUserInfoModel) FindOneByNanosecond(nanosecond int64) (*TestUserInfo, error) { + func (m *defaultTestUserInfoModel) FindOneByNanosecond(nanosecond gobatis.NullInt64) (*TestUserInfo, error) { var resp *TestUserInfo err := m.conn.Select(m.method("findOneByNanosecond"), map[string]interface{}{ "Nanosecond": nanosecond, @@ -165,13 +170,14 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 return } - func (m *defaultTestUserInfoModel) Delete(id int64) (affected int64, err error) { + func (m *defaultTestUserInfoModel) Delete(id gobatis.NullInt64) (affected int64, err error) { affected, err = m.conn.Delete(m.method("delete"), map[string]interface{}{ "Id": id, }) return } + ``` * 生成mapper代码示例 @@ -191,44 +197,44 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 insert into test_user_info - - id, - - - nanosecond, - - - data, - - - content, - - - create_time, - - - update_time, - + + id, + + + nanosecond, + + + data, + + + content, + + + create_time, + + + update_time, + - - #{Id}, - - - #{Nanosecond}, - - - #{Data}, - - - #{Content}, - - - #{CreateTime}, - - - #{UpdateTime}, - + + #{Id}, + + + #{Nanosecond}, + + + #{Data}, + + + #{Content}, + + + #{CreateTime}, + + + #{UpdateTime}, + @@ -241,15 +247,15 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 update test_user_info - - nanosecond = #{Nanosecond}, - - - data = #{Data}, - - - content = #{Content}, - + + nanosecond = #{Nanosecond}, + + + data = #{Data}, + + + content = #{Content}, + where id = #{Id} @@ -276,21 +282,33 @@ mctl model 为go-zero生成github.com/wenj91/gobatis模板代码工具,主要 from test_user_info - - and nanosecond = #{Nanosecond} - - - and data = #{Data} - - - and content = #{Content} - - - and create_time = #{CreateTime} - - - and update_time = #{UpdateTime} - + + and nanosecond = #{Nanosecond} + + + and data = #{Data} + + + and content = #{Content} + + + and create_time >= #{StartCreateTime} + + + and create_time #{EndCreateTime} + + + and create_time = #{CreateTime} + + + and update_time >= #{StartUpdateTime} + + + and update_time #{EndUpdateTime} + + + and update_time = #{UpdateTime} +