作者 yangfu

zan

@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 |评论详情-不能评论|完成|2019.11.26|/v1/chance/commentDetailsSingle| 18 |评论详情-不能评论|完成|2019.11.26|/v1/chance/commentDetailsSingle|
19 |我的点赞|进行中| |v1/chance/favorite| 19 |我的点赞|进行中| |v1/chance/favorite|
20 |我的收藏|进行中| |v1/chance/favorite| 20 |我的收藏|进行中| |v1/chance/favorite|
21 -|点赞/取消点赞| | |v1/chance/sympathyAction| 21 +|点赞/取消点赞|进行中| |v1/chance/sympathyAction|
22 |消息中心|完成|2019.11.22|v1/message/messageCenter| 22 |消息中心|完成|2019.11.22|v1/message/messageCenter|
23 |标记已读|完成|2019.11.22|v1/message/msgCenterRead| 23 |标记已读|完成|2019.11.22|v1/message/msgCenterRead|
24 |标记全部已读|完成|2019.11.22|v1/message/msgCenterAllRead| 24 |标记全部已读|完成|2019.11.22|v1/message/msgCenterAllRead|
@@ -138,3 +138,29 @@ func (this *ChanceController) CommentDetailsMulti() { @@ -138,3 +138,29 @@ func (this *ChanceController) CommentDetailsMulti() {
138 header := controllers.GetRequestHeader(this.Ctx) 138 header := controllers.GetRequestHeader(this.Ctx)
139 msg = protocol.NewReturnResponse(chance.CommentDetailsMulti(header, request)) 139 msg = protocol.NewReturnResponse(chance.CommentDetailsMulti(header, request))
140 } 140 }
  141 +
  142 +
  143 +//SympathyAction
  144 +//@router /sympathyAction [post]
  145 +func(this *ChanceController)SympathyAction(){
  146 + var msg *protocol.ResponseMessage
  147 + defer func() {
  148 + this.Resp(msg)
  149 + }()
  150 + var request *protocol.SympathyActionRequest
  151 + if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
  152 + log.Error(err)
  153 + msg = protocol.BadRequestParam(1)
  154 + return
  155 + }
  156 + if b,m :=this.Valid(request);!b{
  157 + msg = m
  158 + return
  159 + }
  160 + if !(request.SourceType==protocol.SourceType_Chance || request.SourceType==protocol.SourceType_Comment){
  161 + msg = protocol.BadRequestParam(2)
  162 + return
  163 + }
  164 + header := controllers.GetRequestHeader(this.Ctx)
  165 + msg = protocol.NewReturnResponse(chance.SympathyAction(header,request))
  166 +}
@@ -17,6 +17,9 @@ func (r *ChanceRepository) GetChanceById(id int64) (v *models.Chance, err error) @@ -17,6 +17,9 @@ func (r *ChanceRepository) GetChanceById(id int64) (v *models.Chance, err error)
17 type IChanceFavoriteRepository interface { 17 type IChanceFavoriteRepository interface {
18 GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*models.ChanceFavorite, total int, err error) 18 GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*models.ChanceFavorite, total int, err error)
19 ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) 19 ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error)
  20 + AddChanceFavorite(m *models.ChanceFavorite) (id int64, err error)
  21 + UpdateChanceFavorite(userId, companyId int64,sourceId int64,objectType int)error
  22 + GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *models.ChanceFavorite,err error)
20 } 23 }
21 24
22 var _ IChanceFavoriteRepository = (*ChanceFavoriteRepository)(nil) 25 var _ IChanceFavoriteRepository = (*ChanceFavoriteRepository)(nil)
@@ -29,3 +32,15 @@ func (r *ChanceFavoriteRepository) GetChanceFavorites(userId, companyId int64, o @@ -29,3 +32,15 @@ func (r *ChanceFavoriteRepository) GetChanceFavorites(userId, companyId int64, o
29 func (r *ChanceFavoriteRepository) ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) { 32 func (r *ChanceFavoriteRepository) ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) {
30 return models.ExitsChanceFavorite(userId, companyId, sourceId, objectType) 33 return models.ExitsChanceFavorite(userId, companyId, sourceId, objectType)
31 } 34 }
  35 +func (r *ChanceFavoriteRepository) AddChanceFavorite(m *models.ChanceFavorite) (id int64, err error) {
  36 + return models.AddChanceFavorite(m)
  37 +}
  38 +
  39 +func (r *ChanceFavoriteRepository) UpdateChanceFavorite(userId, companyId int64,sourceId int64,objectType int) error{
  40 + return models.UpdateChanceFavorite(userId,companyId,sourceId,objectType)
  41 +}
  42 +
  43 +
  44 +func (r *ChanceFavoriteRepository) GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *models.ChanceFavorite,err error){
  45 + return models.GetChanceFavorite(userId,companyId,sourceId,sourceType)
  46 +}
@@ -13,13 +13,13 @@ type ChanceFavorite struct { @@ -13,13 +13,13 @@ type ChanceFavorite struct {
13 Id int64 `orm:"column(id);pk" description:"点赞编号"` 13 Id int64 `orm:"column(id);pk" description:"点赞编号"`
14 UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"` 14 UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
15 CompanyId int64 `orm:"column(company_id)" description:"company.id 公司编号"` 15 CompanyId int64 `orm:"column(company_id)" description:"company.id 公司编号"`
16 - ObjectType int `orm:"column(object_type)" description:"类型 1:点赞 2:收藏"` 16 + MarkFlag int `orm:"column(mark_flag)" description:"类型 1:点赞 2:收藏"`
17 SourceType int `orm:"column(source_type)" description:"来源类型 1:机会 2:评论"` 17 SourceType int `orm:"column(source_type)" description:"来源类型 1:机会 2:评论"`
18 SourceId int64 `orm:"column(source_id)" description:"来源id 机会编号/评论编号"` 18 SourceId int64 `orm:"column(source_id)" description:"来源id 机会编号/评论编号"`
19 ChanceType int `orm:"column(chance_type)" description:"机会类型编号 - 附加 "` 19 ChanceType int `orm:"column(chance_type)" description:"机会类型编号 - 附加 "`
20 EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"` 20 EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"`
21 CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` 21 CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
22 - DeleteAt time.Time `orm:"column(delete_at);type(timestamp);null" description:"删除时间"` 22 + UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
23 } 23 }
24 24
25 func (t *ChanceFavorite) TableName() string { 25 func (t *ChanceFavorite) TableName() string {
@@ -79,15 +79,15 @@ func DeleteChanceFavorite(id int64) (err error) { @@ -79,15 +79,15 @@ func DeleteChanceFavorite(id int64) (err error) {
79 return 79 return
80 } 80 }
81 81
82 -func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { 82 +func GetChanceFavorites(userId, companyId int64, markFlag, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
83 sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") 83 sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
84 sql.Where(fmt.Sprintf("user_id=%d", userId)) 84 sql.Where(fmt.Sprintf("user_id=%d", userId))
85 sql.Where(fmt.Sprintf("company_id=%d", companyId)) 85 sql.Where(fmt.Sprintf("company_id=%d", companyId))
86 if chanceType > 0 { 86 if chanceType > 0 {
87 sql.Where(fmt.Sprintf("chance_type=%d", chanceType)) 87 sql.Where(fmt.Sprintf("chance_type=%d", chanceType))
88 } 88 }
89 - if objectType > 0 {  
90 - sql.Where(fmt.Sprintf("object_type&%d>0", objectType)) 89 + if markFlag > 0 {
  90 + sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag))
91 } 91 }
92 if pageSize > 0 { 92 if pageSize > 0 {
93 sql.Limit(0, pageSize) 93 sql.Limit(0, pageSize)
@@ -103,12 +103,34 @@ func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, las @@ -103,12 +103,34 @@ func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, las
103 103
104 } 104 }
105 105
106 -func ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) { 106 +func ExitsChanceFavorite(userId, companyId int64, sourceId int64, markFlag int) (exits bool, err error) {
107 sql := mybeego.NewSqlExutor().Table("chance_favorite") 107 sql := mybeego.NewSqlExutor().Table("chance_favorite")
108 sql.Where(fmt.Sprintf("source_id=%d", sourceId)). 108 sql.Where(fmt.Sprintf("source_id=%d", sourceId)).
109 Where(fmt.Sprintf("user_id=%d", userId)). 109 Where(fmt.Sprintf("user_id=%d", userId)).
110 Where(fmt.Sprintf("company_id=%d", companyId)). 110 Where(fmt.Sprintf("company_id=%d", companyId)).
111 - Where(fmt.Sprintf("(object_type&%d)>0", objectType)).  
112 Where(fmt.Sprintf("enable_status=1")) 111 Where(fmt.Sprintf("enable_status=1"))
  112 + if markFlag>0{
  113 + sql.Where(fmt.Sprintf("(mark_flag&%d)>0", markFlag))
  114 + }
113 return sql.QueryExists() 115 return sql.QueryExists()
114 } 116 }
  117 +
  118 +
  119 +func UpdateChanceFavorite(userId, companyId int64,sourceId int64,markFlag int)(err error){
  120 + o := orm.NewOrm()
  121 + sql := `update chance_favorite set mark_flag = mark_flag ^ ?
  122 +where user_id =? and company_id =? and source_id=? ` //
  123 + if _,err = o.Raw(sql,markFlag,userId,companyId,sourceId).Exec(); err == nil {
  124 + return
  125 + }
  126 + return
  127 +}
  128 +
  129 +func GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *ChanceFavorite,err error){
  130 + o :=orm.NewOrm()
  131 + sql :=`select * from chance_favorite where user_id =? and company_id =? and source_id=? and source_type=?`
  132 + if err = o.Raw(sql,userId,companyId,sourceId,sourceType).QueryRow(&v);err!=nil{
  133 + return
  134 + }
  135 + return
  136 +}
1 -package protocol  
2 -  
3 -import "sort"  
4 -  
5 -//输入框类型  
6 -const (  
7 - inputTypeCheck string = "check-box" //多选宽  
8 - inputTypeText string = "text" //单行文本宽  
9 - InputTypeRedio string = "redio" //单选框  
10 -)  
11 -  
12 -//InputElement 自定义表单项  
13 -type InputElement struct {  
14 - Sort int `json:"sort"` //排序  
15 - Lable string `json:"lable"` //标题  
16 - InputType string `json:"input_type"` //输入类型  
17 - ValueList string `json:"value_list"` //输入候选值  
18 - Required bool `json:"required"` //是否必填  
19 - Placeholder string `json:"Placeholder"` //帮助用户填写输入字段的提示  
20 - Disable bool `json:"disable ` //"显示隐藏",  
21 - CurrentValue string `json:"current_value"` //"当前填写的值"  
22 -}  
23 -  
24 -//自定义表单  
25 -type CustomForm []InputElement  
26 -  
27 -var (  
28 - _ sort.Interface = new(CustomForm)  
29 -)  
30 -  
31 -//实现排序接口  
32 -func (a CustomForm) Len() int { return len(a) }  
33 -func (a CustomForm) Swap(i, j int) { a[i], a[j] = a[j], a[i] }  
34 -func (a CustomForm) Less(i, j int) bool {  
35 - return a[i].Sort < a[j].Sort  
36 -}  
37 -  
38 -//IValidateInput 自定义输入项校验接口  
39 -type IValidateInput interface {  
40 - ValidateInput() error //校验当前输入值  
41 - ValidateConfig() error //校验自定义的输入项设置  
42 -}  
43 -  
44 -type ValidateInputText struct {  
45 - InputElement  
46 -}  
47 -  
48 -var (  
49 - _ IValidateInput = ValidateInputText{}  
50 -)  
51 -  
52 -func (input ValidateInputText) ValidateInput() error {  
53 - return nil  
54 -}  
55 -func (input ValidateInputText) ValidateConfig() error {  
56 - return nil  
57 -}  
58 -  
59 -//ValidateInputRedio 单选项校验  
60 -type ValidateInputRedio struct {  
61 - InputElement  
62 -}  
63 -  
64 -var (  
65 - _ IValidateInput = ValidateInputRedio{}  
66 -)  
67 -  
68 -func (input ValidateInputRedio) ValidateInput() error {  
69 - return nil  
70 -}  
71 -  
72 -func (input ValidateInputRedio) ValidateConfig() error {  
73 - return nil  
74 -}  
1 package protocol 1 package protocol
2 2
3 const ( 3 const (
4 - ObjectType_Zan = 1  
5 - ObjectType_Collect = 2 4 + MarkFlag_Zan = 1
  5 + MarkFlag_Collect = 2
  6 +)
  7 +
  8 +const(
  9 + UnMarkFlag =0
  10 + MarkFlag = 1 //是否标记 /点赞 /收藏
6 ) 11 )
7 12
8 /*Favorite */ 13 /*Favorite */
@@ -39,3 +44,14 @@ type Chance struct { @@ -39,3 +44,14 @@ type Chance struct {
39 CommentTotal int `json:"comment_total"` 44 CommentTotal int `json:"comment_total"`
40 ZanTotal int `json:"zan_total"` 45 ZanTotal int `json:"zan_total"`
41 } 46 }
  47 +
  48 +
  49 +/*SympathyAction */
  50 +type SympathyActionRequest struct {
  51 + MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏
  52 + SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论
  53 + Id int64 `json:"id" valid:"Required"`
  54 + SympathyType int `json:"sympathy_type"` //1:标记 0:取消标记
  55 +}
  56 +type SympathyActionResponse struct {
  57 +}
@@ -6,16 +6,16 @@ var errmessge ErrorMap = map[int]string{ @@ -6,16 +6,16 @@ var errmessge ErrorMap = map[int]string{
6 2: "参数错误", 6 2: "参数错误",
7 101: "clientId或clientSecret无效", 7 101: "clientId或clientSecret无效",
8 113: "签名验证失败", 8 113: "签名验证失败",
9 - 1009: "验证码已超时,登录失败",  
10 - 1011: "短信验证码次数超过限制,请稍后重试",  
11 - 1012: "验证码错误", 9 + 1009: "验证码已失效",
  10 + 1011: "获取验证码次数超出限制,请联系管理员",
  11 + 1012: "请输入正确的验证码",
12 2001: "请输入正确的手机号码", 12 2001: "请输入正确的手机号码",
13 - 2002: "后台未配置账号信息,请联系管理员配置", 13 + 2002: "您还不是正式用户,请联系管理员",
14 2009: "上传的文件流为空", 14 2009: "上传的文件流为空",
15 - //2020: "帐号不存在,请联系管理员",  
16 2021: "登录失败,手机号或密码错误", 15 2021: "登录失败,手机号或密码错误",
17 2025: "短信验证码验证失败", 16 2025: "短信验证码验证失败",
18 - 2026: "两次输入的密码不一致", 17 + 2026: "新密码与确认密码不一致",
  18 + 2027:"密码必须至少有6个字符",
19 4139: "authCode无效或过期", 19 4139: "authCode无效或过期",
20 4140: "refreshToken过期,需要重新登录授权", 20 4140: "refreshToken过期,需要重新登录授权",
21 4141: "accessToken过期或无效,需要进行重新获取令牌", 21 4141: "accessToken过期或无效,需要进行重新获取令牌",
@@ -103,6 +103,14 @@ func init() { @@ -103,6 +103,14 @@ func init() {
103 MethodParams: param.Make(), 103 MethodParams: param.Make(),
104 Params: nil}) 104 Params: nil})
105 105
  106 + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
  107 + beego.ControllerComments{
  108 + Method: "SympathyAction",
  109 + Router: `/sympathyAction`,
  110 + AllowHTTPMethods: []string{"post"},
  111 + MethodParams: param.Make(),
  112 + Params: nil})
  113 +
106 beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"], 114 beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"],
107 beego.ControllerComments{ 115 beego.ControllerComments{
108 Method: "Company", 116 Method: "Company",
1 package agg 1 package agg
2 2
3 import ( 3 import (
  4 + "bytes"
  5 + "fmt"
4 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
5 "opp/internal/repository" 7 "opp/internal/repository"
  8 + "opp/internal/utils"
6 "opp/models" 9 "opp/models"
7 "opp/protocol" 10 "opp/protocol"
8 "sync" 11 "sync"
@@ -88,3 +91,13 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.Chance, err error) @@ -88,3 +91,13 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.Chance, err error)
88 } 91 }
89 return 92 return
90 } 93 }
  94 +
  95 +func GetIncrementSql(table string,column string,incre int,id int64)(*utils.SqlData){
  96 + var sql *bytes.Buffer
  97 + sql = bytes.NewBuffer(nil)
  98 + sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ",table,column,column,incre))
  99 + sql.WriteString(fmt.Sprintf(" where id=%d",id))
  100 + return &utils.SqlData{
  101 + Sql:sql.String(),
  102 + }
  103 +}
@@ -56,6 +56,9 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp @@ -56,6 +56,9 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp
56 } 56 }
57 break 57 break
58 case protocol.LoginTypeSmdcode: 58 case protocol.LoginTypeSmdcode:
  59 + if beego.BConfig.RunMode =="dev"{
  60 + goto Success
  61 + }
59 if result, err = CheckSmsCode(request.Phone, request.Code, protocol.SmsCode); result && err == nil { 62 if result, err = CheckSmsCode(request.Phone, request.Code, protocol.SmsCode); result && err == nil {
60 goto Success 63 goto Success
61 } else { 64 } else {
1 package chance 1 package chance
2 2
3 import ( 3 import (
4 - "github.com/prometheus/common/log" 4 + "fmt"
  5 + "github.com/astaxie/beego/orm"
  6 + "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
  7 + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
5 "opp/internal/repository" 8 "opp/internal/repository"
  9 + "opp/internal/utils"
6 "opp/models" 10 "opp/models"
7 "opp/protocol" 11 "opp/protocol"
8 "opp/services/agg" 12 "opp/services/agg"
  13 + "time"
9 ) 14 )
10 15
11 func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) (rsp *protocol.FavoriteResponse, err error) { 16 func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) (rsp *protocol.FavoriteResponse, err error) {
@@ -38,8 +43,8 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -38,8 +43,8 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
38 log.Error(err) 43 log.Error(err)
39 return 44 return
40 } 45 }
41 - chance.IsZan = (f.ObjectType & protocol.ObjectType_Zan) == protocol.ObjectType_Zan  
42 - chance.IsCollect = (f.ObjectType & protocol.ObjectType_Collect) == protocol.ObjectType_Collect 46 + chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
  47 + chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
43 item.Favorite = chance 48 item.Favorite = chance
44 case protocol.SourceType_Comment: 49 case protocol.SourceType_Comment:
45 } 50 }
@@ -47,3 +52,89 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest) @@ -47,3 +52,89 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
47 } 52 }
48 return 53 return
49 } 54 }
  55 +
  56 +//点赞/收藏 取消点赞/收藏
  57 +func SympathyAction(header *protocol.RequestHeader,request *protocol.SympathyActionRequest)(rsp *protocol.SympathyActionResponse,err error){
  58 + var (
  59 + exists bool
  60 + chanceFavoirte *models.ChanceFavorite
  61 + chance *models.Chance
  62 + chanceType int
  63 + incre int = 1
  64 + table string = "comment"
  65 + )
  66 + rsp =&protocol.SympathyActionResponse{}
  67 + if chanceFavoirte,err = repository.ChanceFavorite.GetChanceFavorite(header.Uid,header.CompanyId,request.Id,request.SourceType);err!=nil && err!=orm.ErrNoRows{
  68 + log.Error(err)
  69 + return
  70 + }
  71 + if request.SourceType == protocol.SourceType_Chance{
  72 + if chance,err = repository.Chance.GetChanceById(request.Id);err!=nil{
  73 + log.Error("机会不存在",err)
  74 + return
  75 + }
  76 + chanceType = chance.ChanceType
  77 + table = "chance"
  78 + }
  79 + if chanceFavoirte!=nil{
  80 + exists = true
  81 + if request.MarkType ==protocol.MarkFlag_Zan {
  82 + if request.SympathyType==protocol.UnMarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Zan)==0{
  83 + err = protocol.NewSuccessWithMessage("已经取消赞,不能重复取消赞")
  84 + return
  85 + }
  86 + if request.SympathyType==protocol.MarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Zan)>0{
  87 + err = protocol.NewSuccessWithMessage("已经赞,不能重复点赞")
  88 + return
  89 + }
  90 + }else if (request.MarkType==protocol.MarkFlag_Collect){
  91 + if request.SympathyType==protocol.UnMarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Collect)==0{
  92 + err = protocol.NewSuccessWithMessage("已经取消收藏,不能重复取消收藏")
  93 + return
  94 + }
  95 + if request.SympathyType==protocol.MarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Collect)>0{
  96 + err = protocol.NewSuccessWithMessage("已经收藏,不能重复收藏")
  97 + return
  98 + }
  99 + }
  100 + }
  101 + if exists{
  102 + if err = repository.ChanceFavorite.UpdateChanceFavorite(header.Uid,header.CompanyId,request.Id,1<<(uint(request.MarkType-1)));err!=nil{
  103 + log.Error(request.MarkType,err)
  104 + return
  105 + }
  106 + goto END
  107 + }
  108 + //add
  109 + chanceFavoirte = &models.ChanceFavorite{
  110 + Id:idgen.Next(),
  111 + UserId:header.Uid,
  112 + CompanyId:header.CompanyId,
  113 + MarkFlag:request.SympathyType,
  114 + SourceType:request.SourceType,
  115 + SourceId:request.Id,
  116 + ChanceType:chanceType,
  117 + CreateAt:time.Now(),
  118 + EnableStatus:1,
  119 + }
  120 + if _,err = repository.ChanceFavorite.AddChanceFavorite(chanceFavoirte);err!=nil{
  121 + log.Error(err)
  122 + return
  123 + }else{
  124 + log.Debug(fmt.Sprintf("SympathyAction user:%d id:%d sympathy:%v",header.Uid,request.Id,request.SympathyType))
  125 + goto END
  126 + }
  127 + END:
  128 + {
  129 + if request.MarkType!=protocol.MarkFlag_Zan {
  130 + return
  131 + }
  132 + if request.SympathyType==protocol.UnMarkFlag{
  133 + incre = -1
  134 + }
  135 + if !utils.ExecuteSqlByRoll(true,agg.GetIncrementSql(table,"zan_total",incre,request.Id)){
  136 + //
  137 + }
  138 + }
  139 + return
  140 +}
@@ -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 ZanTotal: comment.ZanTotal, 134 ZanTotal: comment.ZanTotal,
135 CommentTotal: comment.CommentTotal, 135 CommentTotal: comment.CommentTotal,
136 } 136 }
137 - if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.ObjectType_Zan); exists { 137 + if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
138 item.IsZan = 1 138 item.IsZan = 1
139 } 139 }
140 rsp.Comments = append(rsp.Comments, item) 140 rsp.Comments = append(rsp.Comments, item)
@@ -167,7 +167,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm @@ -167,7 +167,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
167 ZanTotal: comment.ZanTotal, 167 ZanTotal: comment.ZanTotal,
168 CommentTotal: comment.CommentTotal, 168 CommentTotal: comment.CommentTotal,
169 } 169 }
170 - if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.ObjectType_Zan); exists { 170 + if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
171 rsp.Comment.IsZan = 1 171 rsp.Comment.IsZan = 1
172 } 172 }
173 return 173 return
@@ -39,7 +39,7 @@ func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) ( @@ -39,7 +39,7 @@ func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) (
39 NickName: user.NickName, 39 NickName: user.NickName,
40 //TODO:out index 40 //TODO:out index
41 Department: userBaseInfo.Department[0].Name, 41 Department: userBaseInfo.Department[0].Name,
42 - Position: userBaseInfo.Position[1].Name, 42 + Position: userBaseInfo.Position[0].Name,
43 }, 43 },
44 } 44 }
45 rsp.Lists = append(rsp.Lists, cInfo) 45 rsp.Lists = append(rsp.Lists, cInfo)