作者 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过期或无效,需要进行重新获取令牌",
@@ -9,186 +9,194 @@ func init() { @@ -9,186 +9,194 @@ func init() {
9 9
10 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 10 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
11 beego.ControllerComments{ 11 beego.ControllerComments{
12 - Method: "AccessToken",  
13 - Router: `/accessToken`, 12 + Method: "AccessToken",
  13 + Router: `/accessToken`,
14 AllowHTTPMethods: []string{"post"}, 14 AllowHTTPMethods: []string{"post"},
15 - MethodParams: param.Make(),  
16 - Params: nil}) 15 + MethodParams: param.Make(),
  16 + Params: nil})
17 17
18 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 18 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
19 beego.ControllerComments{ 19 beego.ControllerComments{
20 - Method: "Login",  
21 - Router: `/login`, 20 + Method: "Login",
  21 + Router: `/login`,
22 AllowHTTPMethods: []string{"post"}, 22 AllowHTTPMethods: []string{"post"},
23 - MethodParams: param.Make(),  
24 - Params: nil}) 23 + MethodParams: param.Make(),
  24 + Params: nil})
25 25
26 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 26 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
27 beego.ControllerComments{ 27 beego.ControllerComments{
28 - Method: "RefreshToken",  
29 - Router: `/refreshToken`, 28 + Method: "RefreshToken",
  29 + Router: `/refreshToken`,
30 AllowHTTPMethods: []string{"post"}, 30 AllowHTTPMethods: []string{"post"},
31 - MethodParams: param.Make(),  
32 - Params: nil}) 31 + MethodParams: param.Make(),
  32 + Params: nil})
33 33
34 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 34 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
35 beego.ControllerComments{ 35 beego.ControllerComments{
36 - Method: "Revoke",  
37 - Router: `/revoke`, 36 + Method: "Revoke",
  37 + Router: `/revoke`,
38 AllowHTTPMethods: []string{"post"}, 38 AllowHTTPMethods: []string{"post"},
39 - MethodParams: param.Make(),  
40 - Params: nil}) 39 + MethodParams: param.Make(),
  40 + Params: nil})
41 41
42 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 42 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
43 beego.ControllerComments{ 43 beego.ControllerComments{
44 - Method: "SmsCode",  
45 - Router: `/smsCode`, 44 + Method: "SmsCode",
  45 + Router: `/smsCode`,
46 AllowHTTPMethods: []string{"post"}, 46 AllowHTTPMethods: []string{"post"},
47 - MethodParams: param.Make(),  
48 - Params: nil}) 47 + MethodParams: param.Make(),
  48 + Params: nil})
49 49
50 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"], 50 beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
51 beego.ControllerComments{ 51 beego.ControllerComments{
52 - Method: "UpdateDevice",  
53 - Router: `/updateDevice`, 52 + Method: "UpdateDevice",
  53 + Router: `/updateDevice`,
54 AllowHTTPMethods: []string{"post"}, 54 AllowHTTPMethods: []string{"post"},
55 - MethodParams: param.Make(),  
56 - Params: nil}) 55 + MethodParams: param.Make(),
  56 + Params: nil})
57 57
58 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 58 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
59 beego.ControllerComments{ 59 beego.ControllerComments{
60 - Method: "CommentDetailsMulti",  
61 - Router: `/commentDetailsMulti`, 60 + Method: "CommentDetailsMulti",
  61 + Router: `/commentDetailsMulti`,
62 AllowHTTPMethods: []string{"post"}, 62 AllowHTTPMethods: []string{"post"},
63 - MethodParams: param.Make(),  
64 - Params: nil}) 63 + MethodParams: param.Make(),
  64 + Params: nil})
65 65
66 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 66 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
67 beego.ControllerComments{ 67 beego.ControllerComments{
68 - Method: "CommentDetailsSingle",  
69 - Router: `/commentDetailsSingle`, 68 + Method: "CommentDetailsSingle",
  69 + Router: `/commentDetailsSingle`,
70 AllowHTTPMethods: []string{"post"}, 70 AllowHTTPMethods: []string{"post"},
71 - MethodParams: param.Make(),  
72 - Params: nil}) 71 + MethodParams: param.Make(),
  72 + Params: nil})
73 73
74 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 74 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
75 beego.ControllerComments{ 75 beego.ControllerComments{
76 - Method: "Comments",  
77 - Router: `/comments`, 76 + Method: "Comments",
  77 + Router: `/comments`,
78 AllowHTTPMethods: []string{"post"}, 78 AllowHTTPMethods: []string{"post"},
79 - MethodParams: param.Make(),  
80 - Params: nil}) 79 + MethodParams: param.Make(),
  80 + Params: nil})
81 81
82 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 82 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
83 beego.ControllerComments{ 83 beego.ControllerComments{
84 - Method: "Favorite",  
85 - Router: `/favorite`, 84 + Method: "Favorite",
  85 + Router: `/favorite`,
86 AllowHTTPMethods: []string{"post"}, 86 AllowHTTPMethods: []string{"post"},
87 - MethodParams: param.Make(),  
88 - Params: nil}) 87 + MethodParams: param.Make(),
  88 + Params: nil})
89 89
90 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 90 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
91 beego.ControllerComments{ 91 beego.ControllerComments{
92 - Method: "IComment",  
93 - Router: `/iComment`, 92 + Method: "IComment",
  93 + Router: `/iComment`,
94 AllowHTTPMethods: []string{"post"}, 94 AllowHTTPMethods: []string{"post"},
95 - MethodParams: param.Make(),  
96 - Params: nil}) 95 + MethodParams: param.Make(),
  96 + Params: nil})
97 97
98 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], 98 beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
99 beego.ControllerComments{ 99 beego.ControllerComments{
100 - Method: "IComments",  
101 - Router: `/iComments`, 100 + Method: "IComments",
  101 + Router: `/iComments`,
102 AllowHTTPMethods: []string{"post"}, 102 AllowHTTPMethods: []string{"post"},
103 - MethodParams: param.Make(),  
104 - Params: nil}) 103 + MethodParams: param.Make(),
  104 + Params: nil})
  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})
105 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",  
109 - Router: `/company`, 116 + Method: "Company",
  117 + Router: `/company`,
110 AllowHTTPMethods: []string{"post"}, 118 AllowHTTPMethods: []string{"post"},
111 - MethodParams: param.Make(),  
112 - Params: nil}) 119 + MethodParams: param.Make(),
  120 + Params: nil})
113 121
114 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 122 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
115 beego.ControllerComments{ 123 beego.ControllerComments{
116 - Method: "MessageCenter",  
117 - Router: `/messageCenter`, 124 + Method: "MessageCenter",
  125 + Router: `/messageCenter`,
118 AllowHTTPMethods: []string{"post"}, 126 AllowHTTPMethods: []string{"post"},
119 - MethodParams: param.Make(),  
120 - Params: nil}) 127 + MethodParams: param.Make(),
  128 + Params: nil})
121 129
122 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 130 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
123 beego.ControllerComments{ 131 beego.ControllerComments{
124 - Method: "MsgCenterAllRead",  
125 - Router: `/msgCenterAllRead`, 132 + Method: "MsgCenterAllRead",
  133 + Router: `/msgCenterAllRead`,
126 AllowHTTPMethods: []string{"post"}, 134 AllowHTTPMethods: []string{"post"},
127 - MethodParams: param.Make(),  
128 - Params: nil}) 135 + MethodParams: param.Make(),
  136 + Params: nil})
129 137
130 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 138 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
131 beego.ControllerComments{ 139 beego.ControllerComments{
132 - Method: "MsgCenterRead",  
133 - Router: `/msgCenterRead`, 140 + Method: "MsgCenterRead",
  141 + Router: `/msgCenterRead`,
134 AllowHTTPMethods: []string{"post"}, 142 AllowHTTPMethods: []string{"post"},
135 - MethodParams: param.Make(),  
136 - Params: nil}) 143 + MethodParams: param.Make(),
  144 + Params: nil})
137 145
138 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], 146 beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
139 beego.ControllerComments{ 147 beego.ControllerComments{
140 - Method: "MsgInteractive",  
141 - Router: `/msgInteractive`, 148 + Method: "MsgInteractive",
  149 + Router: `/msgInteractive`,
142 AllowHTTPMethods: []string{"post"}, 150 AllowHTTPMethods: []string{"post"},
143 - MethodParams: param.Make(),  
144 - Params: nil}) 151 + MethodParams: param.Make(),
  152 + Params: nil})
145 153
146 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 154 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
147 beego.ControllerComments{ 155 beego.ControllerComments{
148 - Method: "Image",  
149 - Router: `/image`, 156 + Method: "Image",
  157 + Router: `/image`,
150 AllowHTTPMethods: []string{"post"}, 158 AllowHTTPMethods: []string{"post"},
151 - MethodParams: param.Make(),  
152 - Params: nil}) 159 + MethodParams: param.Make(),
  160 + Params: nil})
153 161
154 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"], 162 beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
155 beego.ControllerComments{ 163 beego.ControllerComments{
156 - Method: "Voice",  
157 - Router: `/voice`, 164 + Method: "Voice",
  165 + Router: `/voice`,
158 AllowHTTPMethods: []string{"post"}, 166 AllowHTTPMethods: []string{"post"},
159 - MethodParams: param.Make(),  
160 - Params: nil}) 167 + MethodParams: param.Make(),
  168 + Params: nil})
161 169
162 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 170 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
163 beego.ControllerComments{ 171 beego.ControllerComments{
164 - Method: "ChangePassword",  
165 - Router: `/changePassword`, 172 + Method: "ChangePassword",
  173 + Router: `/changePassword`,
166 AllowHTTPMethods: []string{"post"}, 174 AllowHTTPMethods: []string{"post"},
167 - MethodParams: param.Make(),  
168 - Params: nil}) 175 + MethodParams: param.Make(),
  176 + Params: nil})
169 177
170 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 178 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
171 beego.ControllerComments{ 179 beego.ControllerComments{
172 - Method: "ChangePhone",  
173 - Router: `/changePhone`, 180 + Method: "ChangePhone",
  181 + Router: `/changePhone`,
174 AllowHTTPMethods: []string{"post"}, 182 AllowHTTPMethods: []string{"post"},
175 - MethodParams: param.Make(),  
176 - Params: nil}) 183 + MethodParams: param.Make(),
  184 + Params: nil})
177 185
178 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 186 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
179 beego.ControllerComments{ 187 beego.ControllerComments{
180 - Method: "CheckSmsCode",  
181 - Router: `/checkSmsCode`, 188 + Method: "CheckSmsCode",
  189 + Router: `/checkSmsCode`,
182 AllowHTTPMethods: []string{"post"}, 190 AllowHTTPMethods: []string{"post"},
183 - MethodParams: param.Make(),  
184 - Params: nil}) 191 + MethodParams: param.Make(),
  192 + Params: nil})
185 193
186 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"], 194 beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
187 beego.ControllerComments{ 195 beego.ControllerComments{
188 - Method: "ResetPassword",  
189 - Router: `/resetPassword`, 196 + Method: "ResetPassword",
  197 + Router: `/resetPassword`,
190 AllowHTTPMethods: []string{"post"}, 198 AllowHTTPMethods: []string{"post"},
191 - MethodParams: param.Make(),  
192 - Params: nil}) 199 + MethodParams: param.Make(),
  200 + Params: nil})
193 201
194 } 202 }
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)