正在显示
5 个修改的文件
包含
7 行增加
和
12 行删除
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type Company struct { | 10 | type Company struct { |
| 11 | - Id int64 `orm:"column(id);auto"` | 11 | + Id int64 `orm:"column(id);pk"` |
| 12 | Name string `orm:"column(name);size(40)"` | 12 | Name string `orm:"column(name);size(40)"` |
| 13 | AdminId int64 `orm:"column(admin_id)"` | 13 | AdminId int64 `orm:"column(admin_id)"` |
| 14 | CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"` | 14 | CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"` |
| @@ -2,7 +2,6 @@ package models | @@ -2,7 +2,6 @@ package models | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | - "errors" | ||
| 6 | "fmt" | 5 | "fmt" |
| 7 | "oppmg/common/log" | 6 | "oppmg/common/log" |
| 8 | "oppmg/protocol" | 7 | "oppmg/protocol" |
| @@ -12,7 +11,7 @@ import ( | @@ -12,7 +11,7 @@ import ( | ||
| 12 | ) | 11 | ) |
| 13 | 12 | ||
| 14 | type Department struct { | 13 | type Department struct { |
| 15 | - Id int64 `orm:"column(id);auto"` | 14 | + Id int64 `orm:"column(id);pk"` |
| 16 | CompanyId int64 `orm:"column(company_id)" description:"公司id"` | 15 | CompanyId int64 `orm:"column(company_id)" description:"公司id"` |
| 17 | Name string `orm:"column(name);size(30)" description:"部门名称"` | 16 | Name string `orm:"column(name);size(30)" description:"部门名称"` |
| 18 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` | 17 | CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` |
| @@ -53,9 +52,6 @@ func (t *Department) SetManages(v []int64) { | @@ -53,9 +52,6 @@ func (t *Department) SetManages(v []int64) { | ||
| 53 | } | 52 | } |
| 54 | 53 | ||
| 55 | func (t *Department) SetRelation(parent *Department) error { | 54 | func (t *Department) SetRelation(parent *Department) error { |
| 56 | - if t.Id == 0 { | ||
| 57 | - return errors.New("Id==0") | ||
| 58 | - } | ||
| 59 | if parent == nil { | 55 | if parent == nil { |
| 60 | t.Relation = fmt.Sprintf(",%d,", t.Id) | 56 | t.Relation = fmt.Sprintf(",%d,", t.Id) |
| 61 | } else if parent.Id == 0 { | 57 | } else if parent.Id == 0 { |
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type Position struct { | 10 | type Position struct { |
| 11 | - Id int64 `orm:"column(id);auto" description:"职位表id"` | 11 | + Id int64 `orm:"column(id);pk" description:"职位表id"` |
| 12 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` | 12 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` |
| 13 | Name string `orm:"column(name);size(100)" description:"职位名称"` | 13 | Name string `orm:"column(name);size(100)" description:"职位名称"` |
| 14 | ParentId int64 `orm:"column(parent_id)" description:"父级id"` | 14 | ParentId int64 `orm:"column(parent_id)" description:"父级id"` |
| @@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | type UserCompany struct { | 11 | type UserCompany struct { |
| 12 | - Id int64 `orm:"column(id);auto" description:"唯一标识"` | 12 | + Id int64 `orm:"column(id);pk" description:"唯一标识"` |
| 13 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` | 13 | CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` |
| 14 | UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"` | 14 | UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"` |
| 15 | NickName string `orm:"column(nick_name)"` | 15 | NickName string `orm:"column(nick_name)"` |
| @@ -241,7 +241,7 @@ func AddCompanyData(data ModuleCompanytData) error { | @@ -241,7 +241,7 @@ func AddCompanyData(data ModuleCompanytData) error { | ||
| 241 | if err != nil { | 241 | if err != nil { |
| 242 | o.Rollback() | 242 | o.Rollback() |
| 243 | log.Error("处理user_department数据失败:%s", err) | 243 | log.Error("处理user_department数据失败:%s", err) |
| 244 | - return protocol.NewErrWithMessage("1") | 244 | + return errors.New("处理user_department数据失败") |
| 245 | } | 245 | } |
| 246 | //添加部门主管 | 246 | //添加部门主管 |
| 247 | log.Info("添加department_charge表数据") | 247 | log.Info("添加department_charge表数据") |
| @@ -622,9 +622,8 @@ func initUserDedaprtmet(newDepartment *models.Department, newUserCompany *models | @@ -622,9 +622,8 @@ func initUserDedaprtmet(newDepartment *models.Department, newUserCompany *models | ||
| 622 | //添加部门 | 622 | //添加部门 |
| 623 | newUserDepartment = &models.UserDepartment{ | 623 | newUserDepartment = &models.UserDepartment{ |
| 624 | UserCompanyId: newUserCompany.Id, | 624 | UserCompanyId: newUserCompany.Id, |
| 625 | - //UserId: newUserCompany.UserId, | ||
| 626 | - CompanyId: newUserCompany.CompanyId, | ||
| 627 | - DepartmentId: newDepartment.Id, | 625 | + CompanyId: newUserCompany.CompanyId, |
| 626 | + DepartmentId: newDepartment.Id, | ||
| 628 | } | 627 | } |
| 629 | _, err = models.AddUserDepartment(newUserDepartment, o) | 628 | _, err = models.AddUserDepartment(newUserDepartment, o) |
| 630 | if err != nil { | 629 | if err != nil { |
-
请 注册 或 登录 后发表评论