Merge remote-tracking branch 'origin/dev' into test
正在显示
11 个修改的文件
包含
279 行增加
和
54 行删除
@@ -104,11 +104,11 @@ func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSi | @@ -104,11 +104,11 @@ func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSi | ||
104 | sql := `select a.*,b.images,speechs,videos | 104 | sql := `select a.*,b.images,speechs,videos |
105 | from ( | 105 | from ( |
106 | select id,user_id,create_at,source_content,approve_data,review_status from chance | 106 | select id,user_id,create_at,source_content,approve_data,review_status from chance |
107 | -where user_id=? and company_id=? and review_status in (?) and (?=0 or id>?) | 107 | +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) |
@@ -129,7 +129,7 @@ func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, | @@ -129,7 +129,7 @@ func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, | ||
129 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 129 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
130 | select a.*,b.user_id,b.source_content,b.enable_status,b.review_status from ( | 130 | select a.*,b.user_id,b.source_content,b.enable_status,b.review_status from ( |
131 | select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time | 131 | select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time |
132 | -from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id>?) | 132 | +from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id<?) |
133 | )a left outer join chance b on a.chance_id = b.id | 133 | )a left outer join chance b on a.chance_id = b.id |
134 | )a left outer join chance_data b on a.chance_id =b.chance_id | 134 | )a left outer join chance_data b on a.chance_id =b.chance_id |
135 | order by process_create_time desc | 135 | order by process_create_time desc |
@@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, | @@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, | ||
152 | sql := `select a.*,b.images,speechs,videos | 152 | sql := `select a.*,b.images,speechs,videos |
153 | from ( | 153 | from ( |
154 | select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance | 154 | select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance |
155 | -where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1 | 155 | +where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1 |
156 | order by create_at desc | 156 | order by create_at desc |
157 | limit ? | 157 | limit ? |
158 | ) a left JOIN chance_data b on a.id =b.chance_id` | 158 | ) a left JOIN chance_data b on a.id =b.chance_id` |
@@ -177,7 +177,7 @@ order by create_at desc | @@ -177,7 +177,7 @@ order by create_at desc | ||
177 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 177 | func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
178 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 178 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
179 | select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( | 179 | select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( |
180 | -select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1 | 180 | +select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 |
181 | and source_type=1 | 181 | and source_type=1 |
182 | and (mark_flag&2)>0 | 182 | and (mark_flag&2)>0 |
183 | )a left outer join chance b on a.source_id = b.id | 183 | )a left outer join chance b on a.source_id = b.id |
@@ -200,7 +200,7 @@ limit ?`) | @@ -200,7 +200,7 @@ limit ?`) | ||
200 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | 200 | func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { |
201 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | 201 | sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
202 | select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( | 202 | select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( |
203 | -select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1 | 203 | +select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 |
204 | and source_type=1 | 204 | and source_type=1 |
205 | and (mark_flag&1)>0 | 205 | and (mark_flag&1)>0 |
206 | )a left outer join chance b on a.source_id = b.id | 206 | )a left outer join chance b on a.source_id = b.id |
@@ -227,7 +227,7 @@ from ( | @@ -227,7 +227,7 @@ from ( | ||
227 | select a.*,b.images,b.speechs,b.videos from ( | 227 | select a.*,b.images,b.speechs,b.videos from ( |
228 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( | 228 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( |
229 | select id,content,view_total,zan_total,comment_total,source_type,source_id,create_at comment_time from comment | 229 | select id,content,view_total,zan_total,comment_total,source_type,source_id,create_at comment_time from comment |
230 | -where user_id =? and (?=0 or id>?) | 230 | +where user_id =? and (?=0 or id<?) |
231 | )a left outer join chance b on a.source_id = b.id and source_type=1 | 231 | )a left outer join chance b on a.source_id = b.id and source_type=1 |
232 | )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 | 232 | )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 |
233 | )a left outer join comment b on a.source_id = b.id and a.source_type=2 | 233 | )a left outer join comment b on a.source_id = b.id and a.source_type=2 |
@@ -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 | } |
@@ -95,7 +98,7 @@ func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastI | @@ -95,7 +98,7 @@ func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastI | ||
95 | sql.Limit(0, pageSize) | 98 | sql.Limit(0, pageSize) |
96 | } | 99 | } |
97 | if lastId > 0 { | 100 | if lastId > 0 { |
98 | - sql.Where(fmt.Sprintf("id>%d", lastId)) | 101 | + sql.Where(fmt.Sprintf("id<%d", lastId)) |
99 | } | 102 | } |
100 | if total, err = sql.Querys(&v); err == nil { | 103 | if total, err = sql.Querys(&v); err == nil { |
101 | return | 104 | return |
@@ -94,7 +94,7 @@ func GetComments(userId int64, sourceType int, sourceId int64, lastId int64, pag | @@ -94,7 +94,7 @@ func GetComments(userId int64, sourceType int, sourceId int64, lastId int64, pag | ||
94 | sql.Limit(0, pageSize) | 94 | sql.Limit(0, pageSize) |
95 | } | 95 | } |
96 | if lastId > 0 { | 96 | if lastId > 0 { |
97 | - sql.Where(fmt.Sprintf("id>%d", lastId)) | 97 | + sql.Where(fmt.Sprintf("id<%d", lastId)) |
98 | } | 98 | } |
99 | if total, err = sql.Querys(&v); err == nil { | 99 | if total, err = sql.Querys(&v); err == nil { |
100 | if total == 0 { | 100 | if total == 0 { |
@@ -16,7 +16,6 @@ type Department struct { | @@ -16,7 +16,6 @@ type Department struct { | ||
16 | Relation string `orm:"column(relation);size(400)" description:"父子级关系树"` | 16 | Relation string `orm:"column(relation);size(400)" description:"父子级关系树"` |
17 | DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` | 17 | DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` |
18 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | 18 | UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` |
19 | - Member int `orm:"column(member)" description:"成员数量"` | ||
20 | Managers string `orm:"column(managers);null" description:"部门负责人id列表 json 数组 [ ]"` | 19 | Managers string `orm:"column(managers);null" description:"部门负责人id列表 json 数组 [ ]"` |
21 | } | 20 | } |
22 | 21 |
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 | +} |
@@ -181,7 +181,7 @@ func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) ( | @@ -181,7 +181,7 @@ func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) ( | ||
181 | sql := `select a.*,b.images,b.speechs,b.videos from ( | 181 | sql := `select a.*,b.images,b.speechs,b.videos from ( |
182 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( | 182 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( |
183 | select id,company_id,receive_user_id,message,source_id,is_read | 183 | select id,company_id,receive_user_id,message,source_id,is_read |
184 | -from user_msg where receive_user_id=? and source_type=1 and (?=0 or id>?) and msg_type=? | 184 | +from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=? |
185 | )a left outer join chance b on a.source_id = b.id | 185 | )a left outer join chance b on a.source_id = b.id |
186 | )a left outer join chance_data b on a.source_id =b.chance_id | 186 | )a left outer join chance_data b on a.source_id =b.chance_id |
187 | order by a.create_at desc | 187 | order by a.create_at desc |
@@ -206,7 +206,7 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa | @@ -206,7 +206,7 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa | ||
206 | select a.*,b.images,b.speechs,b.videos from ( | 206 | select a.*,b.images,b.speechs,b.videos from ( |
207 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from ( | 207 | select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from ( |
208 | select id,message content,source_type,source_id,create_at comment_time from user_msg | 208 | select id,message content,source_type,source_id,create_at comment_time from user_msg |
209 | -where receive_user_id =? and (?=0 or id>?) and msg_type=? | 209 | +where receive_user_id =? and (?=0 or id<?) and msg_type=? |
210 | )a left outer join chance b on a.source_id = b.id and source_type=1 | 210 | )a left outer join chance b on a.source_id = b.id and source_type=1 |
211 | )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 | 211 | )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 |
212 | )a left outer join comment b on a.source_id = b.id and a.source_type=2 | 212 | )a left outer join comment b on a.source_id = b.id and a.source_type=2 |
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 | +} | ||
72 | + | ||
73 | +func GetUserRolesById(roleId int) (v []*UserRole, err error) { | ||
74 | + o := orm.NewOrm() | ||
75 | + sql := ` | ||
76 | +select * from user_role where role_id =? and enable_status =1` | ||
77 | + if _, err = o.Raw(sql, roleId).QueryRows(&v); err == nil { | ||
78 | + return | ||
79 | + } | ||
80 | + return | ||
81 | +} |
@@ -57,6 +57,9 @@ var errmessge ErrorMap = map[int]string{ | @@ -57,6 +57,9 @@ var errmessge ErrorMap = map[int]string{ | ||
57 | 57 | ||
58 | 5510: "评分配置不存在,请联系管理员", | 58 | 5510: "评分配置不存在,请联系管理员", |
59 | 5511: "发现分计算不一致,请重新提交", | 59 | 5511: "发现分计算不一致,请重新提交", |
60 | + | ||
61 | + //评论相关 | ||
62 | + 5601: "评论不存在", | ||
60 | } | 63 | } |
61 | 64 | ||
62 | const ( | 65 | const ( |
@@ -198,7 +198,11 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq | @@ -198,7 +198,11 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq | ||
198 | var sql *bytes.Buffer | 198 | var sql *bytes.Buffer |
199 | sql = bytes.NewBuffer(nil) | 199 | sql = bytes.NewBuffer(nil) |
200 | sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre)) | 200 | sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ", table, column, column, incre)) |
201 | - sql.WriteString(fmt.Sprintf(" where id=%d", id)) | 201 | + if incre > 0 { |
202 | + sql.WriteString(fmt.Sprintf(" where id=%d", id)) | ||
203 | + } else { | ||
204 | + sql.WriteString(fmt.Sprintf(" where id=%d and %v>0", id, column)) | ||
205 | + } | ||
202 | return &utils.SqlData{ | 206 | return &utils.SqlData{ |
203 | Sql: sql.String(), | 207 | Sql: sql.String(), |
204 | } | 208 | } |
@@ -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 { |
@@ -62,10 +63,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc | @@ -62,10 +63,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc | ||
62 | exists bool | 63 | exists bool |
63 | chanceFavoirte *models.ChanceFavorite | 64 | chanceFavoirte *models.ChanceFavorite |
64 | chance *models.Chance | 65 | chance *models.Chance |
66 | + comment *models.Comment | ||
65 | chanceType int | 67 | chanceType int |
66 | incre int = 1 | 68 | incre int = 1 |
67 | table string = "comment" | 69 | table string = "comment" |
68 | message string = protocol.MessageZanComment | 70 | message string = protocol.MessageZanComment |
71 | + sourceId int64 | ||
72 | + userId int64 | ||
69 | ) | 73 | ) |
70 | rsp = &protocol.SympathyActionResponse{} | 74 | rsp = &protocol.SympathyActionResponse{} |
71 | if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows { | 75 | if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows { |
@@ -75,11 +79,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc | @@ -75,11 +79,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc | ||
75 | if request.SourceType == protocol.SourceTypeChance { | 79 | if request.SourceType == protocol.SourceTypeChance { |
76 | message = protocol.MessageZanChance | 80 | message = protocol.MessageZanChance |
77 | if chance, err = models.GetChanceById(request.Id); err != nil { | 81 | if chance, err = models.GetChanceById(request.Id); err != nil { |
78 | - log.Error("机会不存在", err) | 82 | + log.Error(request.Id, "机会不存在", err) |
83 | + err = protocol.NewErrWithMessage(5101) | ||
79 | return | 84 | return |
80 | } | 85 | } |
86 | + sourceId = chance.Id | ||
87 | + userId = chance.UserId | ||
81 | chanceType = chance.ChanceTypeId | 88 | chanceType = chance.ChanceTypeId |
82 | table = "chance" | 89 | table = "chance" |
90 | + } else if request.SourceType == protocol.SourceTypeComment { | ||
91 | + if comment, err = models.GetCommentById(request.Id); err != nil { | ||
92 | + log.Error(request.Id, "评论不存在", err) | ||
93 | + err = protocol.NewErrWithMessage(5601) | ||
94 | + return | ||
95 | + } | ||
96 | + sourceId = comment.Id | ||
97 | + userId = comment.UserId | ||
98 | + } else { | ||
99 | + log.Error(request.SourceType, "type error") | ||
100 | + err = protocol.NewErrWithMessage(2) | ||
101 | + return | ||
83 | } | 102 | } |
84 | if chanceFavoirte != nil { | 103 | if chanceFavoirte != nil { |
85 | exists = true | 104 | exists = true |
@@ -137,10 +156,10 @@ END: | @@ -137,10 +156,10 @@ END: | ||
137 | if request.SympathyType == protocol.UnMarkFlag { | 156 | if request.SympathyType == protocol.UnMarkFlag { |
138 | incre = -1 | 157 | incre = -1 |
139 | //删除点赞消息 | 158 | //删除点赞消息 |
140 | - agg.DeleteSendedMsg(chance.Id, protocol.SourceTypeChance, chance.UserId, protocol.MsgTypeThumbUp) | 159 | + agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp) |
141 | } else { | 160 | } else { |
142 | //发送点赞消息 | 161 | //发送点赞消息 |
143 | - agg.SendMsg(chance.UserId, fmt.Sprintf("%v", chance.UserId), chance.CompanyId, chance.Id, 1, message, protocol.MsgTypeThumbUp) | 162 | + agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, 1, message, protocol.MsgTypeThumbUp) |
144 | } | 163 | } |
145 | if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) { | 164 | if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) { |
146 | // | 165 | // |
@@ -290,7 +309,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -290,7 +309,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
290 | } | 309 | } |
291 | //4.查询审核配置 | 310 | //4.查询审核配置 |
292 | //5.生成审核流 | 311 | //5.生成审核流 |
293 | - if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil { | 312 | + if auditFlows, err = GenAuditFlowProcess(header, chance.Id, chance.DepartmentId, template.Id, auditConfig); err != nil { |
294 | log.Error(err) | 313 | log.Error(err) |
295 | orm.Rollback() | 314 | orm.Rollback() |
296 | return | 315 | return |
@@ -628,7 +647,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, | @@ -628,7 +647,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, | ||
628 | } | 647 | } |
629 | 648 | ||
630 | //生成审批流 | 649 | //生成审批流 |
631 | -func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) { | 650 | +func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, relatedDeparmentId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) { |
632 | var ( | 651 | var ( |
633 | configs []*models.AuditFlowConfig | 652 | configs []*models.AuditFlowConfig |
634 | IsSpecailAuditFlow bool = false | 653 | IsSpecailAuditFlow bool = false |
@@ -637,6 +656,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -637,6 +656,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
637 | company *models.Company | 656 | company *models.Company |
638 | roleName string | 657 | roleName string |
639 | approver *models.User | 658 | approver *models.User |
659 | + roleId []int | ||
640 | ) | 660 | ) |
641 | if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil { | 661 | if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil { |
642 | if err == orm.ErrNoRows { | 662 | if err == orm.ErrNoRows { |
@@ -659,16 +679,18 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -659,16 +679,18 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
659 | groupId = config.AuditGroupId | 679 | groupId = config.AuditGroupId |
660 | continue | 680 | continue |
661 | } | 681 | } |
662 | - if len(config.FromSpecialUser) > 0 { | ||
663 | - if err = json.Unmarshal([]byte(config.FromSpecialUser), &ids); err != nil { | ||
664 | - log.Error(err) | ||
665 | - return | ||
666 | - } | ||
667 | - for j := range ids { | ||
668 | - if ids[j] == header.Uid { | ||
669 | - groupId = config.AuditGroupId | ||
670 | - IsSpecailAuditFlow = true | ||
671 | - break | 682 | + if config.FlowType == protocol.FlowTypeSpecail { |
683 | + if len(config.FromSpecialUser) > 0 { | ||
684 | + if err = json.Unmarshal([]byte(config.FromSpecialUser), &ids); err != nil { | ||
685 | + log.Error(err) | ||
686 | + return | ||
687 | + } | ||
688 | + for j := range ids { | ||
689 | + if ids[j] == header.Uid { | ||
690 | + groupId = config.AuditGroupId | ||
691 | + IsSpecailAuditFlow = true | ||
692 | + break | ||
693 | + } | ||
672 | } | 694 | } |
673 | } | 695 | } |
674 | } | 696 | } |
@@ -704,18 +726,28 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -704,18 +726,28 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
704 | var userIds []int64 | 726 | var userIds []int64 |
705 | switch config.AuditFlowType { | 727 | switch config.AuditFlowType { |
706 | case protocol.AuditByDepartmentor: | 728 | case protocol.AuditByDepartmentor: |
707 | - if userIds, err = getDepartmentors(header); err != nil { | 729 | + if userIds, err = getDepartmentors(header, relatedDeparmentId); err != nil { |
708 | log.Error(err) | 730 | log.Error(err) |
709 | return | 731 | return |
710 | } | 732 | } |
733 | + break | ||
711 | case protocol.AuditByUser: | 734 | case protocol.AuditByUser: |
712 | if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil { | 735 | if err = json.Unmarshal([]byte(config.ToUser), &userIds); err != nil { |
713 | log.Error(err) | 736 | log.Error(err) |
714 | return | 737 | return |
715 | } | 738 | } |
739 | + break | ||
716 | case protocol.AuditByRole: | 740 | case protocol.AuditByRole: |
717 | //roleName="" //TODO:角色 | 741 | //roleName="" //TODO:角色 |
718 | - return | 742 | + if e := json.Unmarshal([]byte(config.ToRole), &roleId); e == nil { |
743 | + if userIds, err = getRoleUsers(header, roleId[0]); err != nil { | ||
744 | + log.Error(err) | ||
745 | + return | ||
746 | + } | ||
747 | + } else { | ||
748 | + log.Error(config.ToRole, e) | ||
749 | + } | ||
750 | + break | ||
719 | } | 751 | } |
720 | if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人 | 752 | if len(userIds) == 0 { //当前步骤没有用户 默认一个空审核人 |
721 | userIds = append(userIds, 0) | 753 | userIds = append(userIds, 0) |
@@ -725,12 +757,15 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -725,12 +757,15 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
725 | if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员 | 757 | if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员 |
726 | uid = company.AdminId | 758 | uid = company.AdminId |
727 | } | 759 | } |
728 | - if uid == header.Uid { //审核人自己 转交给管理员 | 760 | + if uid == 0 { |
761 | + uid = company.AdminId | ||
762 | + } | ||
763 | + if uid == header.UserId { //审核人自己 转交给管理员 | ||
729 | log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId)) | 764 | log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId)) |
730 | uid = company.AdminId | 765 | uid = company.AdminId |
731 | } | 766 | } |
732 | if approver, err = models.GetUserByUcid(uid); err != nil { | 767 | if approver, err = models.GetUserByUcid(uid); err != nil { |
733 | - log.Error(err) | 768 | + log.Error(uid, err) |
734 | return | 769 | return |
735 | } | 770 | } |
736 | item := &models.AuditFlowProcess{ | 771 | item := &models.AuditFlowProcess{ |
@@ -769,33 +804,52 @@ func resolveActionType(t uint) string { | @@ -769,33 +804,52 @@ func resolveActionType(t uint) string { | ||
769 | } | 804 | } |
770 | 805 | ||
771 | //获取部门长用户列表 | 806 | //获取部门长用户列表 |
772 | -func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) { | 807 | +func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) { |
773 | var ( | 808 | var ( |
774 | - departments []*protocol.Department | 809 | + departments *models.Department |
775 | ) | 810 | ) |
776 | - if err = models.GetUserDepartments(header.Uid, header.CompanyId, &departments); err != nil { | ||
777 | - log.Error(err) | 811 | + //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil { |
812 | + // log.Error(header.UserId,header.CompanyId,err) | ||
813 | + // return | ||
814 | + //} | ||
815 | + if departments, err = models.GetDepartmentById(int(relatedDeparmentId)); err != nil { | ||
816 | + log.Error(relatedDeparmentId, err) | ||
778 | return | 817 | return |
779 | } | 818 | } |
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 { | 819 | + if len(departments.Managers) > 0 { |
820 | + var tmpIds []int64 | ||
821 | + if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil { | ||
822 | + if len(tmpIds) > 0 { | ||
787 | ids = append(ids, tmpIds...) | 823 | ids = append(ids, tmpIds...) |
788 | - continue | ||
789 | } | 824 | } |
790 | } | 825 | } |
791 | - //部门长不存在 | ||
792 | - if d.PId == 0 { | ||
793 | - ids = append(ids, 0) | ||
794 | - continue | ||
795 | - } else { | ||
796 | - ids = append(ids, getParentDepartmentors(d.PId)...) | 826 | + } |
827 | + //部门长不存在 | ||
828 | + if len(ids) == 0 { | ||
829 | + ids = append(ids, 0) | ||
830 | + } | ||
831 | + log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v", relatedDeparmentId, departments.Managers, ids)) | ||
832 | + return | ||
833 | +} | ||
834 | + | ||
835 | +//获取角色ids | ||
836 | +func getRoleUsers(header *protocol.RequestHeader, roleId int) (ids []int64, err error) { | ||
837 | + var ( | ||
838 | + userRole []*models.UserRole | ||
839 | + ) | ||
840 | + if userRole, err = models.GetUserRolesById(roleId); err != nil { | ||
841 | + log.Error(roleId, err) | ||
842 | + if err == orm.ErrNoRows { | ||
843 | + err = nil | ||
797 | } | 844 | } |
798 | } | 845 | } |
846 | + for i := range userRole { | ||
847 | + ids = append(ids, userRole[i].UserCompanyId) | ||
848 | + } | ||
849 | + if len(ids) == 0 { | ||
850 | + ids = append(ids, 0) | ||
851 | + } | ||
852 | + log.Info(fmt.Sprintf("生成机会审批流-角色:role_id:%v ids:%v", roleId, ids)) | ||
799 | return | 853 | return |
800 | } | 854 | } |
801 | 855 | ||
@@ -888,7 +942,10 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -888,7 +942,10 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
888 | } | 942 | } |
889 | commItem.ReviewStatus = chance.ReviewStatus | 943 | commItem.ReviewStatus = chance.ReviewStatus |
890 | if request.ReviewStatus == protocol.ReviewStatusPass { | 944 | if request.ReviewStatus == protocol.ReviewStatusPass { |
891 | - jsonUnmarshal(chance.ApproveData, &commItem.ApproveData) | 945 | + var approveData protocol.ApproveData |
946 | + jsonUnmarshal(chance.ApproveData, &approveData) | ||
947 | + //commItem.ApproveData = approveData //TODO:删除不需要 | ||
948 | + commItem.Score = approveData.Score | ||
892 | } | 949 | } |
893 | rsp.List = append(rsp.List, commItem) | 950 | rsp.List = append(rsp.List, commItem) |
894 | } | 951 | } |
@@ -134,7 +134,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) | @@ -134,7 +134,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) | ||
134 | total int | 134 | total int |
135 | exists bool | 135 | exists bool |
136 | ) | 136 | ) |
137 | - if comments, total, err = models.GetComments(header.UserId, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { | 137 | + if comments, total, err = models.GetComments(0, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil { |
138 | log.Error(err) | 138 | log.Error(err) |
139 | return | 139 | return |
140 | } | 140 | } |
@@ -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 |
-
请 注册 或 登录 后发表评论