作者 yangfu

zan

... ... @@ -18,7 +18,7 @@
|评论详情-不能评论|完成|2019.11.26|/v1/chance/commentDetailsSingle|
|我的点赞|进行中| |v1/chance/favorite|
|我的收藏|进行中| |v1/chance/favorite|
|点赞/取消点赞| | |v1/chance/sympathyAction|
|点赞/取消点赞|进行中| |v1/chance/sympathyAction|
|消息中心|完成|2019.11.22|v1/message/messageCenter|
|标记已读|完成|2019.11.22|v1/message/msgCenterRead|
|标记全部已读|完成|2019.11.22|v1/message/msgCenterAllRead|
... ...
... ... @@ -138,3 +138,29 @@ func (this *ChanceController) CommentDetailsMulti() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.CommentDetailsMulti(header, request))
}
//SympathyAction
//@router /sympathyAction [post]
func(this *ChanceController)SympathyAction(){
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.SympathyActionRequest
if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b,m :=this.Valid(request);!b{
msg = m
return
}
if !(request.SourceType==protocol.SourceType_Chance || request.SourceType==protocol.SourceType_Comment){
msg = protocol.BadRequestParam(2)
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.SympathyAction(header,request))
}
\ No newline at end of file
... ...
... ... @@ -17,6 +17,9 @@ func (r *ChanceRepository) GetChanceById(id int64) (v *models.Chance, err error)
type IChanceFavoriteRepository interface {
GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*models.ChanceFavorite, total int, err error)
ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error)
AddChanceFavorite(m *models.ChanceFavorite) (id int64, err error)
UpdateChanceFavorite(userId, companyId int64,sourceId int64,objectType int)error
GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *models.ChanceFavorite,err error)
}
var _ IChanceFavoriteRepository = (*ChanceFavoriteRepository)(nil)
... ... @@ -29,3 +32,15 @@ func (r *ChanceFavoriteRepository) GetChanceFavorites(userId, companyId int64, o
func (r *ChanceFavoriteRepository) ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) {
return models.ExitsChanceFavorite(userId, companyId, sourceId, objectType)
}
func (r *ChanceFavoriteRepository) AddChanceFavorite(m *models.ChanceFavorite) (id int64, err error) {
return models.AddChanceFavorite(m)
}
func (r *ChanceFavoriteRepository) UpdateChanceFavorite(userId, companyId int64,sourceId int64,objectType int) error{
return models.UpdateChanceFavorite(userId,companyId,sourceId,objectType)
}
func (r *ChanceFavoriteRepository) GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *models.ChanceFavorite,err error){
return models.GetChanceFavorite(userId,companyId,sourceId,sourceType)
}
\ No newline at end of file
... ...
... ... @@ -13,13 +13,13 @@ type ChanceFavorite struct {
Id int64 `orm:"column(id);pk" description:"点赞编号"`
UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
CompanyId int64 `orm:"column(company_id)" description:"company.id 公司编号"`
ObjectType int `orm:"column(object_type)" description:"类型 1:点赞 2:收藏"`
MarkFlag int `orm:"column(mark_flag)" description:"类型 1:点赞 2:收藏"`
SourceType int `orm:"column(source_type)" description:"来源类型 1:机会 2:评论"`
SourceId int64 `orm:"column(source_id)" description:"来源id 机会编号/评论编号"`
ChanceType int `orm:"column(chance_type)" description:"机会类型编号 - 附加 "`
EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp);null" description:"删除时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
}
func (t *ChanceFavorite) TableName() string {
... ... @@ -79,15 +79,15 @@ func DeleteChanceFavorite(id int64) (err error) {
return
}
func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
func GetChanceFavorites(userId, companyId int64, markFlag, chanceType int, 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 chanceType > 0 {
sql.Where(fmt.Sprintf("chance_type=%d", chanceType))
}
if objectType > 0 {
sql.Where(fmt.Sprintf("object_type&%d>0", objectType))
if markFlag > 0 {
sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag))
}
if pageSize > 0 {
sql.Limit(0, pageSize)
... ... @@ -103,12 +103,34 @@ func GetChanceFavorites(userId, companyId int64, objectType, chanceType int, las
}
func ExitsChanceFavorite(userId, companyId int64, sourceId int64, objectType int) (exits bool, err error) {
func ExitsChanceFavorite(userId, companyId int64, sourceId int64, markFlag int) (exits bool, err error) {
sql := mybeego.NewSqlExutor().Table("chance_favorite")
sql.Where(fmt.Sprintf("source_id=%d", sourceId)).
Where(fmt.Sprintf("user_id=%d", userId)).
Where(fmt.Sprintf("company_id=%d", companyId)).
Where(fmt.Sprintf("(object_type&%d)>0", objectType)).
Where(fmt.Sprintf("enable_status=1"))
if markFlag>0{
sql.Where(fmt.Sprintf("(mark_flag&%d)>0", markFlag))
}
return sql.QueryExists()
}
func UpdateChanceFavorite(userId, companyId int64,sourceId int64,markFlag int)(err error){
o := orm.NewOrm()
sql := `update chance_favorite set mark_flag = mark_flag ^ ?
where user_id =? and company_id =? and source_id=? ` //
if _,err = o.Raw(sql,markFlag,userId,companyId,sourceId).Exec(); err == nil {
return
}
return
}
func GetChanceFavorite(userId, companyId int64,sourceId int64,sourceType int)(v *ChanceFavorite,err error){
o :=orm.NewOrm()
sql :=`select * from chance_favorite where user_id =? and company_id =? and source_id=? and source_type=?`
if err = o.Raw(sql,userId,companyId,sourceId,sourceType).QueryRow(&v);err!=nil{
return
}
return
}
\ No newline at end of file
... ...
package protocol
import "sort"
//输入框类型
const (
inputTypeCheck string = "check-box" //多选宽
inputTypeText string = "text" //单行文本宽
InputTypeRedio string = "redio" //单选框
)
//InputElement 自定义表单项
type InputElement struct {
Sort int `json:"sort"` //排序
Lable string `json:"lable"` //标题
InputType string `json:"input_type"` //输入类型
ValueList string `json:"value_list"` //输入候选值
Required bool `json:"required"` //是否必填
Placeholder string `json:"Placeholder"` //帮助用户填写输入字段的提示
Disable bool `json:"disable ` //"显示隐藏",
CurrentValue string `json:"current_value"` //"当前填写的值"
}
//自定义表单
type CustomForm []InputElement
var (
_ sort.Interface = new(CustomForm)
)
//实现排序接口
func (a CustomForm) Len() int { return len(a) }
func (a CustomForm) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a CustomForm) Less(i, j int) bool {
return a[i].Sort < a[j].Sort
}
//IValidateInput 自定义输入项校验接口
type IValidateInput interface {
ValidateInput() error //校验当前输入值
ValidateConfig() error //校验自定义的输入项设置
}
type ValidateInputText struct {
InputElement
}
var (
_ IValidateInput = ValidateInputText{}
)
func (input ValidateInputText) ValidateInput() error {
return nil
}
func (input ValidateInputText) ValidateConfig() error {
return nil
}
//ValidateInputRedio 单选项校验
type ValidateInputRedio struct {
InputElement
}
var (
_ IValidateInput = ValidateInputRedio{}
)
func (input ValidateInputRedio) ValidateInput() error {
return nil
}
func (input ValidateInputRedio) ValidateConfig() error {
return nil
}
package protocol
const (
ObjectType_Zan = 1
ObjectType_Collect = 2
MarkFlag_Zan = 1
MarkFlag_Collect = 2
)
const(
UnMarkFlag =0
MarkFlag = 1 //是否标记 /点赞 /收藏
)
/*Favorite */
... ... @@ -39,3 +44,14 @@ type Chance struct {
CommentTotal int `json:"comment_total"`
ZanTotal int `json:"zan_total"`
}
/*SympathyAction */
type SympathyActionRequest struct {
MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏
SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论
Id int64 `json:"id" valid:"Required"`
SympathyType int `json:"sympathy_type"` //1:标记 0:取消标记
}
type SympathyActionResponse struct {
}
\ No newline at end of file
... ...
... ... @@ -6,16 +6,16 @@ var errmessge ErrorMap = map[int]string{
2: "参数错误",
101: "clientId或clientSecret无效",
113: "签名验证失败",
1009: "验证码已超时,登录失败",
1011: "短信验证码次数超过限制,请稍后重试",
1012: "验证码错误",
1009: "验证码已失效",
1011: "获取验证码次数超出限制,请联系管理员",
1012: "请输入正确的验证码",
2001: "请输入正确的手机号码",
2002: "后台未配置账号信息,请联系管理员配置",
2002: "您还不是正式用户,请联系管理员",
2009: "上传的文件流为空",
//2020: "帐号不存在,请联系管理员",
2021: "登录失败,手机号或密码错误",
2025: "短信验证码验证失败",
2026: "两次输入的密码不一致",
2026: "新密码与确认密码不一致",
2027:"密码必须至少有6个字符",
4139: "authCode无效或过期",
4140: "refreshToken过期,需要重新登录授权",
4141: "accessToken过期或无效,需要进行重新获取令牌",
... ...
... ... @@ -9,186 +9,194 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "AccessToken",
Router: `/accessToken`,
Method: "AccessToken",
Router: `/accessToken`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "Login",
Router: `/login`,
Method: "Login",
Router: `/login`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "RefreshToken",
Router: `/refreshToken`,
Method: "RefreshToken",
Router: `/refreshToken`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "Revoke",
Router: `/revoke`,
Method: "Revoke",
Router: `/revoke`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "SmsCode",
Router: `/smsCode`,
Method: "SmsCode",
Router: `/smsCode`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:AuthController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:AuthController"],
beego.ControllerComments{
Method: "UpdateDevice",
Router: `/updateDevice`,
Method: "UpdateDevice",
Router: `/updateDevice`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CommentDetailsMulti",
Router: `/commentDetailsMulti`,
Method: "CommentDetailsMulti",
Router: `/commentDetailsMulti`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "CommentDetailsSingle",
Router: `/commentDetailsSingle`,
Method: "CommentDetailsSingle",
Router: `/commentDetailsSingle`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Comments",
Router: `/comments`,
Method: "Comments",
Router: `/comments`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Favorite",
Router: `/favorite`,
Method: "Favorite",
Router: `/favorite`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "IComment",
Router: `/iComment`,
Method: "IComment",
Router: `/iComment`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "IComments",
Router: `/iComments`,
Method: "IComments",
Router: `/iComments`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "SympathyAction",
Router: `/sympathyAction`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"],
beego.ControllerComments{
Method: "Company",
Router: `/company`,
Method: "Company",
Router: `/company`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MessageCenter",
Router: `/messageCenter`,
Method: "MessageCenter",
Router: `/messageCenter`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCenterAllRead",
Router: `/msgCenterAllRead`,
Method: "MsgCenterAllRead",
Router: `/msgCenterAllRead`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCenterRead",
Router: `/msgCenterRead`,
Method: "MsgCenterRead",
Router: `/msgCenterRead`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgInteractive",
Router: `/msgInteractive`,
Method: "MsgInteractive",
Router: `/msgInteractive`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Image",
Router: `/image`,
Method: "Image",
Router: `/image`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UploadController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UploadController"],
beego.ControllerComments{
Method: "Voice",
Router: `/voice`,
Method: "Voice",
Router: `/voice`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ChangePassword",
Router: `/changePassword`,
Method: "ChangePassword",
Router: `/changePassword`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ChangePhone",
Router: `/changePhone`,
Method: "ChangePhone",
Router: `/changePhone`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "CheckSmsCode",
Router: `/checkSmsCode`,
Method: "CheckSmsCode",
Router: `/checkSmsCode`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:UserController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:UserController"],
beego.ControllerComments{
Method: "ResetPassword",
Router: `/resetPassword`,
Method: "ResetPassword",
Router: `/resetPassword`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
MethodParams: param.Make(),
Params: nil})
}
... ...
package agg
import (
"bytes"
"fmt"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/repository"
"opp/internal/utils"
"opp/models"
"opp/protocol"
"sync"
... ... @@ -88,3 +91,13 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.Chance, err error)
}
return
}
func GetIncrementSql(table string,column string,incre int,id int64)(*utils.SqlData){
var sql *bytes.Buffer
sql = bytes.NewBuffer(nil)
sql.WriteString(fmt.Sprintf("update %s set %s=%s+%d ",table,column,column,incre))
sql.WriteString(fmt.Sprintf(" where id=%d",id))
return &utils.SqlData{
Sql:sql.String(),
}
}
\ No newline at end of file
... ...
... ... @@ -56,6 +56,9 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp
}
break
case protocol.LoginTypeSmdcode:
if beego.BConfig.RunMode =="dev"{
goto Success
}
if result, err = CheckSmsCode(request.Phone, request.Code, protocol.SmsCode); result && err == nil {
goto Success
} else {
... ...
package chance
import (
"github.com/prometheus/common/log"
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/repository"
"opp/internal/utils"
"opp/models"
"opp/protocol"
"opp/services/agg"
"time"
)
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)
log.Error(err)
return
}
chance.IsZan = (f.ObjectType & protocol.ObjectType_Zan) == protocol.ObjectType_Zan
chance.IsCollect = (f.ObjectType & protocol.ObjectType_Collect) == protocol.ObjectType_Collect
chance.IsZan = (f.MarkFlag & protocol.MarkFlag_Zan) == protocol.MarkFlag_Zan
chance.IsCollect = (f.MarkFlag & protocol.MarkFlag_Collect) == protocol.MarkFlag_Collect
item.Favorite = chance
case protocol.SourceType_Comment:
}
... ... @@ -47,3 +52,89 @@ func Favorite(header *protocol.RequestHeader, request *protocol.FavoriteRequest)
}
return
}
//点赞/收藏 取消点赞/收藏
func SympathyAction(header *protocol.RequestHeader,request *protocol.SympathyActionRequest)(rsp *protocol.SympathyActionResponse,err error){
var (
exists bool
chanceFavoirte *models.ChanceFavorite
chance *models.Chance
chanceType int
incre int = 1
table string = "comment"
)
rsp =&protocol.SympathyActionResponse{}
if chanceFavoirte,err = repository.ChanceFavorite.GetChanceFavorite(header.Uid,header.CompanyId,request.Id,request.SourceType);err!=nil && err!=orm.ErrNoRows{
log.Error(err)
return
}
if request.SourceType == protocol.SourceType_Chance{
if chance,err = repository.Chance.GetChanceById(request.Id);err!=nil{
log.Error("机会不存在",err)
return
}
chanceType = chance.ChanceType
table = "chance"
}
if chanceFavoirte!=nil{
exists = true
if request.MarkType ==protocol.MarkFlag_Zan {
if request.SympathyType==protocol.UnMarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Zan)==0{
err = protocol.NewSuccessWithMessage("已经取消赞,不能重复取消赞")
return
}
if request.SympathyType==protocol.MarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Zan)>0{
err = protocol.NewSuccessWithMessage("已经赞,不能重复点赞")
return
}
}else if (request.MarkType==protocol.MarkFlag_Collect){
if request.SympathyType==protocol.UnMarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Collect)==0{
err = protocol.NewSuccessWithMessage("已经取消收藏,不能重复取消收藏")
return
}
if request.SympathyType==protocol.MarkFlag && (chanceFavoirte.MarkFlag & protocol.MarkFlag_Collect)>0{
err = protocol.NewSuccessWithMessage("已经收藏,不能重复收藏")
return
}
}
}
if exists{
if err = repository.ChanceFavorite.UpdateChanceFavorite(header.Uid,header.CompanyId,request.Id,1<<(uint(request.MarkType-1)));err!=nil{
log.Error(request.MarkType,err)
return
}
goto END
}
//add
chanceFavoirte = &models.ChanceFavorite{
Id:idgen.Next(),
UserId:header.Uid,
CompanyId:header.CompanyId,
MarkFlag:request.SympathyType,
SourceType:request.SourceType,
SourceId:request.Id,
ChanceType:chanceType,
CreateAt:time.Now(),
EnableStatus:1,
}
if _,err = repository.ChanceFavorite.AddChanceFavorite(chanceFavoirte);err!=nil{
log.Error(err)
return
}else{
log.Debug(fmt.Sprintf("SympathyAction user:%d id:%d sympathy:%v",header.Uid,request.Id,request.SympathyType))
goto END
}
END:
{
if request.MarkType!=protocol.MarkFlag_Zan {
return
}
if request.SympathyType==protocol.UnMarkFlag{
incre = -1
}
if !utils.ExecuteSqlByRoll(true,agg.GetIncrementSql(table,"zan_total",incre,request.Id)){
//
}
}
return
}
\ No newline at end of file
... ...
... ... @@ -134,7 +134,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
ZanTotal: comment.ZanTotal,
CommentTotal: comment.CommentTotal,
}
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.ObjectType_Zan); exists {
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
item.IsZan = 1
}
rsp.Comments = append(rsp.Comments, item)
... ... @@ -167,7 +167,7 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
ZanTotal: comment.ZanTotal,
CommentTotal: comment.CommentTotal,
}
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.ObjectType_Zan); exists {
if exists, _ = repository.ChanceFavorite.ExitsChanceFavorite(header.Uid, header.CompanyId, comment.Id, protocol.MarkFlag_Zan); exists {
rsp.Comment.IsZan = 1
}
return
... ...
... ... @@ -39,7 +39,7 @@ func Commend(header *protocol.RequestHeader, request *protocol.CommendRequest) (
NickName: user.NickName,
//TODO:out index
Department: userBaseInfo.Department[0].Name,
Position: userBaseInfo.Position[1].Name,
Position: userBaseInfo.Position[0].Name,
},
}
rsp.Lists = append(rsp.Lists, cInfo)
... ...