Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangke committed Dec 5, 2018
1 parent e5885b8 commit be0b492
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Binary file modified gorepomaker-intellij-plugin.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

<change-notes><![CDATA[
<html>
<b>v1.0.2</b> (11/13/2018)
<b>v1.0.3</b> (12/05/2018)
<ul>
<li>Add function : Update${entityName}ByID ; Adjust Update func, it can't update '_id'.</li>
</ul>
<b>v1.0.2</b> (12/2/2018)
<ul>
<li>Add function : Delete${entityName}ByID , Get${entityName}ByID.</li>
</ul>
Expand Down
14 changes: 12 additions & 2 deletions resources/repotemplates/impl_mgo_repo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (this *${entityMongoRepoName})Query${entityName}One(query map[string]interf
//通过主键查询一条${entityName}记录
func (this *${entityMongoRepoName})Get${entityName}ByID(id interface{}) (*SELFENTITY.${entityName},error) {
entity := SELFENTITY.${entityName}{}
err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).Find(map[string]interface{}{"_id":id}).One(&entity)
err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).FindId(id).One(&entity)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -83,14 +83,24 @@ func (this *${entityMongoRepoName})Query${entityName}Count(query map[string]inte

//更新${entityName}记录
func (this *${entityMongoRepoName}) Update${entityName}(selector , values map[string]interface{}) error {
delete(values,"_id")
_, err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).UpdateAll(selector, bson.M{"$set": values})
if err != nil {
return err
}
return nil

}
//根据主键更新$${entityName}记录
func (this *${entityMongoRepoName}) Update${entityName}ByID(id interface{} , values map[string]interface{}) error {
delete(values,"_id")
err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).UpdateId(id, bson.M{"$set": values})
if err != nil {
return err
}
return nil

}
//删除${entityName}记录
func (this *${entityMongoRepoName}) Delete${entityName}(selector map[string]interface{}) error {
_, err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).RemoveAll(selector)
Expand All @@ -103,7 +113,7 @@ func (this *${entityMongoRepoName}) Delete${entityName}(selector map[string]inte

//根据主键删除${entityName}记录
func (this *${entityMongoRepoName}) Delete${entityName}ByID(id interface{}) error {
_, err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).RemoveAll(map[string]interface{}{"_id":id})
err := this.session.DB(CONFIG.MgoDBName).C(SELFENTITY.${entityCollectionName}).RemoveId(id)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions resources/repotemplates/inf_repo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type ${entityRepoInterfaceName} interface {
//更新${entityName}记录
Update${entityName}(selector , values map[string]interface{}) error

//根据主键更新${entityName}记录
Update${entityName}ByID(id interface{} , values map[string]interface{}) error

//删除${entityName}记录
Delete${entityName}(selector map[string]interface{}) error

Expand Down

0 comments on commit be0b492

Please sign in to comment.