正在显示
6 个修改的文件
包含
180 行增加
和
29 行删除
| @@ -108,7 +108,7 @@ where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) | @@ -108,7 +108,7 @@ where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) | ||
| 108 | order by create_at desc | 108 | order by create_at desc |
| 109 | limit ? | 109 | limit ? |
| 110 | ) a left JOIN chance_data b on a.id =b.chance_id` | 110 | ) a left JOIN chance_data b on a.id =b.chance_id` |
| 111 | - | 111 | + //update_at |
| 112 | sqlCount := fmt.Sprintf(`select count(0) from ( | 112 | sqlCount := fmt.Sprintf(`select count(0) from ( |
| 113 | select id,user_id,create_at,source_content from chance | 113 | select id,user_id,create_at,source_content from chance |
| 114 | where user_id=? and company_id=? and review_status in (%v) | 114 | where user_id=? and company_id=? and review_status in (%v) |
| @@ -81,13 +81,16 @@ func DeleteChanceFavorite(id int64) (err error) { | @@ -81,13 +81,16 @@ func DeleteChanceFavorite(id int64) (err error) { | ||
| 81 | 81 | ||
| 82 | //按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数 | 82 | //按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数 |
| 83 | //获取用户点赞收藏机会 | 83 | //获取用户点赞收藏机会 |
| 84 | -func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { | 84 | +func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, sourceId int64, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { |
| 85 | sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") | 85 | sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") |
| 86 | sql.Where(fmt.Sprintf("user_id=%d", userId)) | 86 | sql.Where(fmt.Sprintf("user_id=%d", userId)) |
| 87 | sql.Where(fmt.Sprintf("company_id=%d", companyId)) | 87 | sql.Where(fmt.Sprintf("company_id=%d", companyId)) |
| 88 | if sourceType > 0 { | 88 | if sourceType > 0 { |
| 89 | sql.Where(fmt.Sprintf("source_type=%d", sourceType)) | 89 | sql.Where(fmt.Sprintf("source_type=%d", sourceType)) |
| 90 | } | 90 | } |
| 91 | + if sourceId > 0 { | ||
| 92 | + sql.Where(fmt.Sprintf("source_id=%d", sourceId)) | ||
| 93 | + } | ||
| 91 | if markFlag > 0 { | 94 | if markFlag > 0 { |
| 92 | sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag)) | 95 | sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag)) |
| 93 | } | 96 | } |
models/role.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "time" | ||
| 6 | + | ||
| 7 | + "github.com/astaxie/beego/orm" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type Role struct { | ||
| 11 | + Id int `orm:"column(id);auto" description:"编号"` | ||
| 12 | + Pid int `orm:"column(pid)" description:"关联的上级组id"` | ||
| 13 | + Types int8 `orm:"column(types)" description:"类型【1:角色】【2:角色组】"` | ||
| 14 | + Name string `orm:"column(name);size(30)" description:"角色名称"` | ||
| 15 | + CompanyId int `orm:"column(company_id)" description:"表company.id 编号"` | ||
| 16 | + Descript string `orm:"column(descript);size(255)" description:"描述"` | ||
| 17 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now_add" description:"创建时间"` | ||
| 18 | + DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` | ||
| 19 | + UpdateAt time.Time `orm:"column(update_at);type(timestamp)"` | ||
| 20 | + IsDefault int8 `orm:"column(is_default)" description:"是否是默认项【0:不是默认】【1:是默认】"` | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func (t *Role) TableName() string { | ||
| 24 | + return "role" | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func init() { | ||
| 28 | + orm.RegisterModel(new(Role)) | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +// AddRole insert a new Role into database and returns | ||
| 32 | +// last inserted Id on success. | ||
| 33 | +func AddRole(m *Role) (id int64, err error) { | ||
| 34 | + o := orm.NewOrm() | ||
| 35 | + id, err = o.Insert(m) | ||
| 36 | + return | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +// GetRoleById retrieves Role by Id. Returns error if | ||
| 40 | +// Id doesn't exist | ||
| 41 | +func GetRoleById(id int) (v *Role, err error) { | ||
| 42 | + o := orm.NewOrm() | ||
| 43 | + v = &Role{Id: id} | ||
| 44 | + if err = o.Read(v); err == nil { | ||
| 45 | + return v, nil | ||
| 46 | + } | ||
| 47 | + return nil, err | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +// UpdateRole updates Role by Id and returns error if | ||
| 51 | +// the record to be updated doesn't exist | ||
| 52 | +func UpdateRoleById(m *Role) (err error) { | ||
| 53 | + o := orm.NewOrm() | ||
| 54 | + v := Role{Id: m.Id} | ||
| 55 | + // ascertain id exists in the database | ||
| 56 | + if err = o.Read(&v); err == nil { | ||
| 57 | + var num int64 | ||
| 58 | + if num, err = o.Update(m); err == nil { | ||
| 59 | + fmt.Println("Number of records updated in database:", num) | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + return | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +// DeleteRole deletes Role by Id and returns error if | ||
| 66 | +// the record to be deleted doesn't exist | ||
| 67 | +func DeleteRole(id int) (err error) { | ||
| 68 | + o := orm.NewOrm() | ||
| 69 | + v := Role{Id: id} | ||
| 70 | + // ascertain id exists in the database | ||
| 71 | + if err = o.Read(&v); err == nil { | ||
| 72 | + var num int64 | ||
| 73 | + if num, err = o.Delete(&Role{Id: id}); err == nil { | ||
| 74 | + fmt.Println("Number of records deleted in database:", num) | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + return | ||
| 78 | +} |
models/user_role.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "github.com/astaxie/beego/orm" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type UserRole struct { | ||
| 9 | + Id int `orm:"column(id);auto"` | ||
| 10 | + RoleId int `orm:"column(role_id)"` | ||
| 11 | + EnableStatus int8 `orm:"column(enable_status)" description:"是否有效 1:有效 2:无效"` | ||
| 12 | + CompanyId int64 `orm:"column(company_id)"` | ||
| 13 | + UserCompanyId int64 `orm:"column(user_company_id)" description:"表user_company的id"` | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +func (t *UserRole) TableName() string { | ||
| 17 | + return "user_role" | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func init() { | ||
| 21 | + orm.RegisterModel(new(UserRole)) | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +// AddUserRole insert a new UserRole into database and returns | ||
| 25 | +// last inserted Id on success. | ||
| 26 | +func AddUserRole(m *UserRole) (id int64, err error) { | ||
| 27 | + o := orm.NewOrm() | ||
| 28 | + id, err = o.Insert(m) | ||
| 29 | + return | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +// GetUserRoleById retrieves UserRole by Id. Returns error if | ||
| 33 | +// Id doesn't exist | ||
| 34 | +func GetUserRoleById(id int) (v *UserRole, err error) { | ||
| 35 | + o := orm.NewOrm() | ||
| 36 | + v = &UserRole{Id: id} | ||
| 37 | + if err = o.Read(v); err == nil { | ||
| 38 | + return v, nil | ||
| 39 | + } | ||
| 40 | + return nil, err | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +// UpdateUserRole updates UserRole by Id and returns error if | ||
| 44 | +// the record to be updated doesn't exist | ||
| 45 | +func UpdateUserRoleById(m *UserRole) (err error) { | ||
| 46 | + o := orm.NewOrm() | ||
| 47 | + v := UserRole{Id: m.Id} | ||
| 48 | + // ascertain id exists in the database | ||
| 49 | + if err = o.Read(&v); err == nil { | ||
| 50 | + var num int64 | ||
| 51 | + if num, err = o.Update(m); err == nil { | ||
| 52 | + fmt.Println("Number of records updated in database:", num) | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + return | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +// DeleteUserRole deletes UserRole by Id and returns error if | ||
| 59 | +// the record to be deleted doesn't exist | ||
| 60 | +func DeleteUserRole(id int) (err error) { | ||
| 61 | + o := orm.NewOrm() | ||
| 62 | + v := UserRole{Id: id} | ||
| 63 | + // ascertain id exists in the database | ||
| 64 | + if err = o.Read(&v); err == nil { | ||
| 65 | + var num int64 | ||
| 66 | + if num, err = o.Delete(&UserRole{Id: id}); err == nil { | ||
| 67 | + fmt.Println("Number of records deleted in database:", num) | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + return | ||
| 71 | +} |
| @@ -27,6 +27,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) | @@ -27,6 +27,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) | ||
| 27 | header.CompanyId, | 27 | header.CompanyId, |
| 28 | request.ObjectType, | 28 | request.ObjectType, |
| 29 | request.ChanceType, | 29 | request.ChanceType, |
| 30 | + 0, | ||
| 30 | request.LastId, | 31 | request.LastId, |
| 31 | request.PageSize) | 32 | request.PageSize) |
| 32 | if err != nil { | 33 | if err != nil { |
| @@ -290,7 +291,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -290,7 +291,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
| 290 | } | 291 | } |
| 291 | //4.查询审核配置 | 292 | //4.查询审核配置 |
| 292 | //5.生成审核流 | 293 | //5.生成审核流 |
| 293 | - if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { | 294 | + if auditFlows, err = GenAuditFlowProcess(header, chance.Id, chance.DepartmentId, template.Id, auditConfig); err != nil { |
| 294 | log.Error(err) | 295 | log.Error(err) |
| 295 | orm.Rollback() | 296 | orm.Rollback() |
| 296 | return | 297 | return |
| @@ -628,7 +629,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, | @@ -628,7 +629,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, | ||
| 628 | } | 629 | } |
| 629 | 630 | ||
| 630 | //生成审批流 | 631 | //生成审批流 |
| 631 | -func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) { | 632 | +func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, relatedDeparmentId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) { |
| 632 | var ( | 633 | var ( |
| 633 | configs []*models.AuditFlowConfig | 634 | configs []*models.AuditFlowConfig |
| 634 | IsSpecailAuditFlow bool = false | 635 | IsSpecailAuditFlow bool = false |
| @@ -704,7 +705,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -704,7 +705,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
| 704 | var userIds []int64 | 705 | var userIds []int64 |
| 705 | switch config.AuditFlowType { | 706 | switch config.AuditFlowType { |
| 706 | case protocol.AuditByDepartmentor: | 707 | case protocol.AuditByDepartmentor: |
| 707 | - if userIds, err = getDepartmentors(header); err != nil { | 708 | + if userIds, err = getDepartmentors(header, relatedDeparmentId); err != nil { |
| 708 | log.Error(err) | 709 | log.Error(err) |
| 709 | return | 710 | return |
| 710 | } | 711 | } |
| @@ -730,7 +731,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -730,7 +731,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
| 730 | uid = company.AdminId | 731 | uid = company.AdminId |
| 731 | } | 732 | } |
| 732 | if approver, err = models.GetUserByUcid(uid); err != nil { | 733 | if approver, err = models.GetUserByUcid(uid); err != nil { |
| 733 | - log.Error(err) | 734 | + log.Error(uid, err) |
| 734 | return | 735 | return |
| 735 | } | 736 | } |
| 736 | item := &models.AuditFlowProcess{ | 737 | item := &models.AuditFlowProcess{ |
| @@ -769,33 +770,28 @@ func resolveActionType(t uint) string { | @@ -769,33 +770,28 @@ func resolveActionType(t uint) string { | ||
| 769 | } | 770 | } |
| 770 | 771 | ||
| 771 | //获取部门长用户列表 | 772 | //获取部门长用户列表 |
| 772 | -func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) { | 773 | +func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) { |
| 773 | var ( | 774 | var ( |
| 774 | - departments []*protocol.Department | 775 | + departments *models.Department |
| 775 | ) | 776 | ) |
| 776 | - if err = models.GetUserDepartments(header.Uid, header.CompanyId, &departments); err != nil { | ||
| 777 | - log.Error(err) | 777 | + //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil { |
| 778 | + // log.Error(header.UserId,header.CompanyId,err) | ||
| 779 | + // return | ||
| 780 | + //} | ||
| 781 | + if departments, err = models.GetDepartmentById(int(relatedDeparmentId)); err != nil { | ||
| 782 | + log.Error(relatedDeparmentId, err) | ||
| 778 | return | 783 | return |
| 779 | } | 784 | } |
| 780 | - | ||
| 781 | - for i := 0; i < len(departments); i++ { | ||
| 782 | - d := departments[i] | ||
| 783 | - //部门长存在 | ||
| 784 | - if len(d.ManagerString) > 0 { | ||
| 785 | - var tmpIds []int64 | ||
| 786 | - if err = json.Unmarshal([]byte(d.ManagerString), &tmpIds); err == nil && len(ids) > 0 { | ||
| 787 | - ids = append(ids, tmpIds...) | ||
| 788 | - continue | ||
| 789 | - } | ||
| 790 | - } | ||
| 791 | - //部门长不存在 | ||
| 792 | - if d.PId == 0 { | ||
| 793 | - ids = append(ids, 0) | ||
| 794 | - continue | ||
| 795 | - } else { | ||
| 796 | - ids = append(ids, getParentDepartmentors(d.PId)...) | 785 | + if len(departments.Managers) > 0 { |
| 786 | + var tmpIds []int64 | ||
| 787 | + if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil && len(ids) > 0 { | ||
| 788 | + ids = append(ids, tmpIds...) | ||
| 797 | } | 789 | } |
| 798 | } | 790 | } |
| 791 | + //部门长不存在 | ||
| 792 | + if len(ids) == 0 { | ||
| 793 | + ids = append(ids, 0) | ||
| 794 | + } | ||
| 799 | return | 795 | return |
| 800 | } | 796 | } |
| 801 | 797 | ||
| @@ -888,7 +884,10 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -888,7 +884,10 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
| 888 | } | 884 | } |
| 889 | commItem.ReviewStatus = chance.ReviewStatus | 885 | commItem.ReviewStatus = chance.ReviewStatus |
| 890 | if request.ReviewStatus == protocol.ReviewStatusPass { | 886 | if request.ReviewStatus == protocol.ReviewStatusPass { |
| 891 | - jsonUnmarshal(chance.ApproveData, &commItem.ApproveData) | 887 | + var approveData protocol.ApproveData |
| 888 | + jsonUnmarshal(chance.ApproveData, &approveData) | ||
| 889 | + //commItem.ApproveData = approveData //TODO:删除不需要 | ||
| 890 | + commItem.Score = approveData.Score | ||
| 892 | } | 891 | } |
| 893 | rsp.List = append(rsp.List, commItem) | 892 | rsp.List = append(rsp.List, commItem) |
| 894 | } | 893 | } |
| @@ -172,7 +172,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques | @@ -172,7 +172,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques | ||
| 172 | baseUserInfo *protocol.BaseUserInfo | 172 | baseUserInfo *protocol.BaseUserInfo |
| 173 | ) | 173 | ) |
| 174 | rsp = &protocol.ThumbsupsResponse{} | 174 | rsp = &protocol.ThumbsupsResponse{} |
| 175 | - if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.LastId, request.PageSize); err != nil { | 175 | + if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { |
| 176 | if err == orm.ErrNoRows { | 176 | if err == orm.ErrNoRows { |
| 177 | err = nil | 177 | err = nil |
| 178 | return | 178 | return |
-
请 注册 或 登录 后发表评论