123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package wx_crm
- import (
- "eta/eta_bridge/global"
- "gorm.io/gorm/clause"
- "time"
- )
- type SysUser struct {
- SysUserId int `orm:"pk" description:"系统用户id"`
- SysUserName string `description:"账号"`
- SysRealName string `description:"姓名"`
- Password string `description:"密码"`
- Email string `description:"邮箱"`
- Phone string `description:"手机号"`
- AreaCode string `description:"手机区号"`
- SysRoleId int `description:"角色id"`
- SysRoleName string `description:"角色名称"`
- SysDepartmentId int `description:"所属部门id"`
- SysDepartmentId1 int `description:"所属部门一级id"`
- SysDepartmentId2 int `description:"所属部门二级id"`
- SysDepartmentId3 int `description:"所属部门三级id"`
- SysDepartmentId4 int `description:"所属部门四级id"`
- Province string `description:"省"`
- City string `description:"市"`
- PositionName string `description:"职位名称"`
- PositionCode int `description:"职位编码"`
- IsEnabled bool `description:"是否启用"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (s *SysUser) TableName() string {
- return "sys_user"
- }
- func BatchInsertOrUpdateUser(users []SysUser) (err error) {
- db := global.MYSQL["ht_crm"]
- OnConflictFunc := clause.OnConflict{
- Columns: []clause.Column{{Name: "sys_user_name"}},
- DoUpdates: clause.AssignmentColumns([]string{"sys_real_name", "email", "phone", "position_name", "position_code", "sys_department_id", "sys_department_id1", "sys_department_id2", "sys_department_id3", "sys_department_id4"}),
- }
- // 执行批量插入或更新操作
- err = db.Clauses(OnConflictFunc).Create(&users).Error
- return
- }
|