Skip to content

Commit

Permalink
Merge pull request #255 from ArtisanCloud/dev/michaelhu
Browse files Browse the repository at this point in the history
update(debug): comment out debug
  • Loading branch information
Matrix-X authored Sep 10, 2023
2 parents 52edaca + 84a8d5e commit bea9426
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 85 deletions.
93 changes: 46 additions & 47 deletions internal/model/scrm/organization/weworkemployee.go
Original file line number Diff line number Diff line change
@@ -1,77 +1,76 @@
package organization

import (
"PowerX/internal/model"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"PowerX/internal/model"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)

type WeWorkEmployee struct {
model.Model
model.Model

WeWorkUserId string `gorm:"comment:员工ID;column:we_work_user_id;unique" json:"we_work_user_id"`
Name string `gorm:"comment:员工名称;column:name" json:"name"`
Position string `gorm:"comment:员工位置;column:position" json:"position"`
Mobile string `gorm:"comment:员工电话;column:mobile" json:"mobile"`
Gender string `gorm:"comment:员工性别;column:gender" json:"gender"`
Email string `gorm:"comment:邮箱;column:email" json:"email"`
BizMail string `gorm:"comment:商务邮箱;column:biz_mail" json:"biz_mail"`
Avatar string `gorm:"comment:头像;column:avatar" json:"avatar"`
ThumbAvatar string `gorm:"comment:ThumbAvatar;column:thumb_avatar" json:"thumb_avatar"`
Telephone string `gorm:"comment:电话;column:telephone" json:"telephone"`
Alias string `gorm:"comment:别称;column:alias" json:"alias"`
Address string `gorm:"comment:地址;column:address" json:"address"`
OpenUserId string `gorm:"comment:开放ID;column:open_user_id" json:"open_user_id"`
WeWorkMainDepartmentId int `gorm:"comment:部门ID;column:we_work_main_department_id" json:"we_work_main_department_id"`
Status int `gorm:"comment:状态;column:status" json:"status"`
QrCode string `gorm:"comment:二维码;column:qr_code" json:"qr_code"`
Department string `gorm:"comment:部门;column:department" json:"department"`
RefEmployeeId int64 `gorm:"comment:RefEmployeeId;column:ref_employee_id" json:"ref_employee_id"`
WeWorkUserId string `gorm:"comment:员工ID;column:we_work_user_id;unique" json:"we_work_user_id"`
Name string `gorm:"comment:员工名称;column:name" json:"name"`
Position string `gorm:"comment:员工位置;column:position" json:"position"`
Mobile string `gorm:"comment:员工电话;column:mobile" json:"mobile"`
Gender string `gorm:"comment:员工性别;column:gender" json:"gender"`
Email string `gorm:"comment:邮箱;column:email" json:"email"`
BizMail string `gorm:"comment:商务邮箱;column:biz_mail" json:"biz_mail"`
Avatar string `gorm:"comment:头像;column:avatar" json:"avatar"`
ThumbAvatar string `gorm:"comment:ThumbAvatar;column:thumb_avatar" json:"thumb_avatar"`
Telephone string `gorm:"comment:电话;column:telephone" json:"telephone"`
Alias string `gorm:"comment:别称;column:alias" json:"alias"`
Address string `gorm:"comment:地址;column:address" json:"address"`
OpenUserId string `gorm:"comment:开放ID;column:open_user_id" json:"open_user_id"`
WeWorkMainDepartmentId int `gorm:"comment:部门ID;column:we_work_main_department_id" json:"we_work_main_department_id"`
Status int `gorm:"comment:状态;column:status" json:"status"`
QrCode string `gorm:"comment:二维码;column:qr_code" json:"qr_code"`
Department string `gorm:"comment:部门;column:department" json:"department"`
RefEmployeeId int64 `gorm:"comment:RefEmployeeId;column:ref_employee_id" json:"ref_employee_id"`
}

//
// Table
// @Description:
// @receiver e
// @return string
//
// @Description:
// @receiver e
// @return string
func (e WeWorkEmployee) TableName() string {
return `we_work_employees`
return `we_work_employees`
}

type (
AdapterEmployeeSliceUserIDs func(employee []*WeWorkEmployee) (ids []string)
AdapterEmployeeSliceUserIDs func(employee []*WeWorkEmployee) (ids []string)
)

//
// Query
// @Description:
// @receiver this
// @param db
// @return employees
//
// @Description:
// @receiver this
// @param db
// @return employees
func (e WeWorkEmployee) Query(db *gorm.DB) (employees []*WeWorkEmployee) {

err := db.Model(e).Find(&employees).Error
if err != nil {
panic(err)
}
return employees
err := db.Model(e).Find(&employees).Error
if err != nil {
panic(err)
}
return employees

}

//
// Action
// @Description:
// @receiver e
// @param db
// @param employees
//
// @Description:
// @receiver e
// @param db
// @param employees
func (e WeWorkEmployee) Action(db *gorm.DB, employees []*WeWorkEmployee) {

err := db.Table(e.TableName()).Debug().Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "we_work_user_id"}}, UpdateAll: true}).CreateInBatches(&employees, 100).Error
if err != nil {
panic(err)
}
err := db.Table(e.TableName()).
//Debug().
Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "we_work_user_id"}}, UpdateAll: true}).CreateInBatches(&employees, 100).Error
if err != nil {
panic(err)
}

}
68 changes: 32 additions & 36 deletions internal/model/scrm/tag/weworktag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@ type WeWorkTag struct {
IsDelete bool `gorm:"comment:是否删除;column:is_delete" json:"is_delete"`
}

//
// Table
// @Description:
// @receiver e
// @return string
//
// @Description:
// @receiver e
// @return string
func (e WeWorkTag) TableName() string {
return `we_work_tags`
}

//
// Query
// @Description:
// @receiver this
// @param db
// @return groups
// @return err
//
// @Description:
// @receiver this
// @param db
// @return groups
// @return err
func (e *WeWorkTag) Query(db *gorm.DB) (tags []*WeWorkTag) {

err := db.Model(e).Where(`is_delete = ?`, false).Preload(`WeWorkGroup`).Order(`sort ASC`).Find(&tags).Error
Expand All @@ -48,14 +46,13 @@ func (e *WeWorkTag) Query(db *gorm.DB) (tags []*WeWorkTag) {

}

//
// Action
// @Description:
// @receiver this
// @param db
// @param group
// @return []*WeWorkAppGroup
//
// @Description:
// @receiver this
// @param db
// @param group
// @return []*WeWorkAppGroup
func (e *WeWorkTag) Action(db *gorm.DB, tags []*WeWorkTag) {

err := db.Table(e.TableName()).Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "tag_id"}},
Expand All @@ -67,14 +64,13 @@ func (e *WeWorkTag) Action(db *gorm.DB, tags []*WeWorkTag) {

}

//
// FindOneByTagGroupId
// @Description:
// @receiver e
// @param db
// @param groupId
// @return tags
//
// @Description:
// @receiver e
// @param db
// @param groupId
// @return tags
func (e *WeWorkTag) FindOneByTagGroupId(db *gorm.DB, groupId string) (tags []*WeWorkTag) {

err := db.Model(e).Where(`is_delete = ? AND group_id = ?`, false, groupId).Find(&tags).Error
Expand All @@ -85,14 +81,13 @@ func (e *WeWorkTag) FindOneByTagGroupId(db *gorm.DB, groupId string) (tags []*We

}

//
// FindOneByTagId
// @Description:
// @receiver e
// @param db
// @param tagId
// @return tag
//
// @Description:
// @receiver e
// @param db
// @param tagId
// @return tag
func (e *WeWorkTag) FindOneByTagId(db *gorm.DB, tagId string) (tag *WeWorkTag) {

err := db.Model(e).Where(`is_delete = ? AND tag_id = ?`, false, tagId).Find(&tag).Error
Expand All @@ -103,15 +98,14 @@ func (e *WeWorkTag) FindOneByTagId(db *gorm.DB, tagId string) (tag *WeWorkTag) {

}

//
// Delete
// @Description:
// @receiver e
// @param db
// @param groupIds
// @param tagIds
// @return error
//
// @Description:
// @receiver e
// @param db
// @param groupIds
// @param tagIds
// @return error
func (e *WeWorkTag) Delete(db *gorm.DB, groupIds, tagIds []string) error {

query := db.Model(e)
Expand All @@ -124,7 +118,9 @@ func (e *WeWorkTag) Delete(db *gorm.DB, groupIds, tagIds []string) error {
column := make(map[string]interface{})
column[`is_delete`] = true
column[`deleted_at`] = time.Now()
err := query.Debug().UpdateColumns(&column).Error
err := query.
//Debug().
UpdateColumns(&column).Error
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/uc/powerx/infoorganization/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (uc *CategoryUseCase) ListCategoryTree(ctx context.Context, opt *FindCatego
query = uc.PreloadItems(query)
err := query.
Where("p_id", pId).
Debug().
//Debug().
Find(&categories).
Error
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/uc/powerx/trade/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (uc *TokenUseCase) FindAllTokenBalances(ctx context.Context, opt *FindManyT
query = uc.buildFindQueryNoPage(query, opt)
query = uc.PreloadItems(query)
if err := query.
Debug().
//Debug().
Find(&tokenBalances).Error; err != nil {
panic(errors.Wrap(err, "find all tokenBalances failed"))
}
Expand Down

0 comments on commit bea9426

Please sign in to comment.