作者 yangfu

点赞列表修改

... ... @@ -108,7 +108,7 @@ where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?)
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
//update_at
sqlCount := fmt.Sprintf(`select count(0) from (
select id,user_id,create_at,source_content from chance
where user_id=? and company_id=? and review_status in (%v)
... ...
... ... @@ -81,13 +81,16 @@ func DeleteChanceFavorite(id int64) (err error) {
//按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数
//获取用户点赞收藏机会
func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, sourceId int64, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
sql.Where(fmt.Sprintf("user_id=%d", userId))
sql.Where(fmt.Sprintf("company_id=%d", companyId))
if sourceType > 0 {
sql.Where(fmt.Sprintf("source_type=%d", sourceType))
}
if sourceId > 0 {
sql.Where(fmt.Sprintf("source_id=%d", sourceId))
}
if markFlag > 0 {
sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag))
}
... ...
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type Role struct {
Id int `orm:"column(id);auto" description:"编号"`
Pid int `orm:"column(pid)" description:"关联的上级组id"`
Types int8 `orm:"column(types)" description:"类型【1:角色】【2:角色组】"`
Name string `orm:"column(name);size(30)" description:"角色名称"`
CompanyId int `orm:"column(company_id)" description:"表company.id 编号"`
Descript string `orm:"column(descript);size(255)" description:"描述"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now_add" description:"创建时间"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)"`
IsDefault int8 `orm:"column(is_default)" description:"是否是默认项【0:不是默认】【1:是默认】"`
}
func (t *Role) TableName() string {
return "role"
}
func init() {
orm.RegisterModel(new(Role))
}
// AddRole insert a new Role into database and returns
// last inserted Id on success.
func AddRole(m *Role) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetRoleById retrieves Role by Id. Returns error if
// Id doesn't exist
func GetRoleById(id int) (v *Role, err error) {
o := orm.NewOrm()
v = &Role{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateRole updates Role by Id and returns error if
// the record to be updated doesn't exist
func UpdateRoleById(m *Role) (err error) {
o := orm.NewOrm()
v := Role{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteRole deletes Role by Id and returns error if
// the record to be deleted doesn't exist
func DeleteRole(id int) (err error) {
o := orm.NewOrm()
v := Role{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&Role{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}
... ...
package models
import (
"fmt"
"github.com/astaxie/beego/orm"
)
type UserRole struct {
Id int `orm:"column(id);auto"`
RoleId int `orm:"column(role_id)"`
EnableStatus int8 `orm:"column(enable_status)" description:"是否有效 1:有效 2:无效"`
CompanyId int64 `orm:"column(company_id)"`
UserCompanyId int64 `orm:"column(user_company_id)" description:"表user_company的id"`
}
func (t *UserRole) TableName() string {
return "user_role"
}
func init() {
orm.RegisterModel(new(UserRole))
}
// AddUserRole insert a new UserRole into database and returns
// last inserted Id on success.
func AddUserRole(m *UserRole) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetUserRoleById retrieves UserRole by Id. Returns error if
// Id doesn't exist
func GetUserRoleById(id int) (v *UserRole, err error) {
o := orm.NewOrm()
v = &UserRole{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateUserRole updates UserRole by Id and returns error if
// the record to be updated doesn't exist
func UpdateUserRoleById(m *UserRole) (err error) {
o := orm.NewOrm()
v := UserRole{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteUserRole deletes UserRole by Id and returns error if
// the record to be deleted doesn't exist
func DeleteUserRole(id int) (err error) {
o := orm.NewOrm()
v := UserRole{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&UserRole{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}
... ...
... ... @@ -27,6 +27,7 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
header.CompanyId,
request.ObjectType,
request.ChanceType,
0,
request.LastId,
request.PageSize)
if err != nil {
... ... @@ -290,7 +291,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
}
//4.查询审核配置
//5.生成审核流
if auditFlows, err = GenAuditFlowProcess(header, chance.Id, template.Id, auditConfig); err != nil {
if auditFlows, err = GenAuditFlowProcess(header, chance.Id, chance.DepartmentId, template.Id, auditConfig); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -628,7 +629,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64,
}
//生成审批流
func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) {
func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, relatedDeparmentId int64, templateId int64, auditConfig *protocol.AuditConfig) (v []*models.AuditFlowProcess, err error) {
var (
configs []*models.AuditFlowConfig
IsSpecailAuditFlow bool = false
... ... @@ -704,7 +705,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
var userIds []int64
switch config.AuditFlowType {
case protocol.AuditByDepartmentor:
if userIds, err = getDepartmentors(header); err != nil {
if userIds, err = getDepartmentors(header, relatedDeparmentId); err != nil {
log.Error(err)
return
}
... ... @@ -730,7 +731,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
uid = company.AdminId
}
if approver, err = models.GetUserByUcid(uid); err != nil {
log.Error(err)
log.Error(uid, err)
return
}
item := &models.AuditFlowProcess{
... ... @@ -769,33 +770,28 @@ func resolveActionType(t uint) string {
}
//获取部门长用户列表
func getDepartmentors(header *protocol.RequestHeader) (ids []int64, err error) {
func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) {
var (
departments []*protocol.Department
departments *models.Department
)
if err = models.GetUserDepartments(header.Uid, header.CompanyId, &departments); err != nil {
log.Error(err)
//if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil {
// log.Error(header.UserId,header.CompanyId,err)
// return
//}
if departments, err = models.GetDepartmentById(int(relatedDeparmentId)); err != nil {
log.Error(relatedDeparmentId, err)
return
}
for i := 0; i < len(departments); i++ {
d := departments[i]
//部门长存在
if len(d.ManagerString) > 0 {
var tmpIds []int64
if err = json.Unmarshal([]byte(d.ManagerString), &tmpIds); err == nil && len(ids) > 0 {
ids = append(ids, tmpIds...)
continue
}
}
//部门长不存在
if d.PId == 0 {
ids = append(ids, 0)
continue
} else {
ids = append(ids, getParentDepartmentors(d.PId)...)
if len(departments.Managers) > 0 {
var tmpIds []int64
if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil && len(ids) > 0 {
ids = append(ids, tmpIds...)
}
}
//部门长不存在
if len(ids) == 0 {
ids = append(ids, 0)
}
return
}
... ... @@ -888,7 +884,10 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
}
commItem.ReviewStatus = chance.ReviewStatus
if request.ReviewStatus == protocol.ReviewStatusPass {
jsonUnmarshal(chance.ApproveData, &commItem.ApproveData)
var approveData protocol.ApproveData
jsonUnmarshal(chance.ApproveData, &approveData)
//commItem.ApproveData = approveData //TODO:删除不需要
commItem.Score = approveData.Score
}
rsp.List = append(rsp.List, commItem)
}
... ...
... ... @@ -172,7 +172,7 @@ func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsReques
baseUserInfo *protocol.BaseUserInfo
)
rsp = &protocol.ThumbsupsResponse{}
if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.LastId, request.PageSize); err != nil {
if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.SourceId, request.LastId, request.PageSize); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ...