“liushuai” 1 éve
szülő
commit
5720d73787

+ 32 - 0
consts/project.go

@@ -39,6 +39,38 @@ func GetProjectPlatform(status int64) string {
 	return "未知"
 }
 
+func GetyoungeeType(status int64) string {
+	toast, contain := ProjectPlatformMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+func GetTeamStage(status int64) string {
+	toast, contain := ProjectPlatformMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+func GetPointIncome(status int64) string {
+	toast, contain := ProjectPlatformMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+func GetMoneyIncome(status int64) string {
+	toast, contain := ProjectPlatformMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
 var ProjectFormMap = map[int64]string{
 	1: "实体商品寄拍",
 	2: "虚拟产品测评",

+ 14 - 0
db/project.go

@@ -323,6 +323,20 @@ func ChangeProjectStatus(ctx context.Context, projectID string, projectStatus st
 	return nil
 }
 
+//// 取消拉黑
+//func unBlack(ctx context.Context, ID string) error {
+//	db := GetReadDB(ctx)
+//	talentInfo := gorm_model.YoungeeTalentInfo{}
+//	if err := db.Debug().Model(&talentInfo).
+//		Where("id = ?", ID).
+//		Updates(gorm_model.YoungeeTalentInfo{InBlacklist: 0}).
+//		Error; err != nil {
+//		logrus.WithContext(ctx).Errorf("[ChangeProjectStatus] error query mysql total, err:%+v", err)
+//		return err
+//	}
+//	return nil
+//}
+
 func GetProjectRecords(ctx context.Context, userId int64, pageSize, pageNum int32) (*http_model.ProjectRecordsData, error) {
 	db := GetReadDB(ctx)
 	enterpriseID := GetEnterpriseIDByUserId(ctx, userId)

+ 27 - 3
db/user.go

@@ -16,7 +16,7 @@ import (
 	"youngee_m_api/util"
 )
 
-//GetUser 查找用户,查不到返回空
+// GetUser 查找用户,查不到返回空
 func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
 	user := &gorm_model.YounggeeUser{}
@@ -31,7 +31,7 @@ func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error)
 	return user, nil
 }
 
-//GetUserByID 查不到返回空
+// GetUserByID 查不到返回空
 func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
 	user := &gorm_model.YounggeeUser{}
@@ -239,7 +239,7 @@ func GetEnterpriseUserList(ctx context.Context, pageSize, pageNum int32, conditi
 
 func GetCreatorList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.CreatorListConditions) ([]*http_model.CreatorListPreview, int64, error) {
 	db := GetReadDB(ctx)
-	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{})
+	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{}).Where("in_blacklist = ?", conditions.InBlacklist)
 	// 根据 条件过滤
 	conditionType := reflect.TypeOf(conditions).Elem()
 	conditionValue := reflect.ValueOf(conditions).Elem()
@@ -401,3 +401,27 @@ func ModifyAccInfo(ctx context.Context, req *http_model.ModifyAccInfoRequest) er
 			UpdatedAdminID:     req.User,
 		}).Error
 }
+
+// 拉黑创作者
+func Block(ctx context.Context, data http_model.BlockRequest) error {
+	err := Black(ctx, data.ID, data.InBlacklist)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project] call ChangeProjectStatus error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+func Black(ctx context.Context, ID string, InBlacklist uint) error {
+	db := GetReadDB(ctx)
+	talentInfo := gorm_model.YoungeeTalentInfo{}
+	if err := db.Debug().Model(&talentInfo).
+		Where("id = ?", ID).
+		//Updates(gorm_model.YoungeeTalentInfo{InBlacklist: InBlacklist}). //这种方法置0不生效
+		UpdateColumn("in_blacklist", InBlacklist).
+		Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[ChangeProjectStatus] error query mysql total, err:%+v", err)
+		return err
+	}
+	return nil
+}

+ 41 - 0
db/youngee.go

@@ -0,0 +1,41 @@
+package db
+
+import (
+	"context"
+	"github.com/sirupsen/logrus"
+	"strconv"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func GetYoungeeRecords(ctx context.Context, talentId string) (*http_model.YoungeeRecordsData, error) {
+	db := GetReadDB(ctx)
+	var youngeeInfos []*gorm_model.YounggeeTalentTeam
+	db = db.Model(&gorm_model.YounggeeTalentTeam{}).Where("talent_id = ?", talentId)
+	// 查询总数
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetyoungeeRecords] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+
+	var youngeeRecords []*http_model.YoungeeRecordsPreview
+	for _, youngeeInfo := range youngeeInfos {
+		pointIncome := strconv.FormatInt(youngeeInfo.PointIncome, 10)
+		youngeeRecordsPreview := new(http_model.YoungeeRecordsPreview)
+		youngeeRecordsPreview.ProjectId = youngeeInfo.ProjectID
+		youngeeRecordsPreview.ProjectName = youngeeInfo.ProjectName
+		youngeeRecordsPreview.ProjectType = consts.GetyoungeeType(youngeeInfo.ProjectType)
+		youngeeRecordsPreview.ProjectPlatform = consts.GetyoungeeType(youngeeInfo.Platform)
+		youngeeRecordsPreview.TeamId = youngeeInfo.TeamID
+		youngeeRecordsPreview.TeamStatus = consts.GetTeamStage(youngeeInfo.TeamStatus)
+		youngeeRecordsPreview.PintIncome = pointIncome
+		youngeeRecordsPreview.MoneyIncome = youngeeInfo.MoneyIncome
+		youngeeRecords = append(youngeeRecords, youngeeRecordsPreview)
+	}
+	youngeeRecordsData := http_model.YoungeeRecordsData{}
+	youngeeRecordsData.YoungeeRecordsPreview = youngeeRecords
+	youngeeRecordsData.Total = strconv.FormatInt(total, 10)
+	return &youngeeRecordsData, nil
+}

+ 58 - 0
handler/creatblock.go

@@ -0,0 +1,58 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapBlockHandler(ctx *gin.Context) {
+	handler := NewBlockHandler(ctx)
+	BaseRun(handler)
+}
+
+func NewBlockHandler(ctx *gin.Context) *BlockHandler {
+	return &BlockHandler{
+		ctx:  ctx,
+		req:  http_model.NewBlockRequest(),
+		resp: http_model.NewBlockResponse(),
+	}
+}
+
+type BlockHandler struct {
+	ctx  *gin.Context
+	req  *http_model.BlockRequest
+	resp *http_model.CommonResponse
+}
+
+func (p BlockHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p BlockHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p BlockHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p BlockHandler) run() {
+	data := http_model.BlockRequest{}
+	data = *p.req
+	err := db.Block(p.ctx, data)
+	if err != nil {
+		logrus.Errorf("[BlockHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("Block fail,req:%+v", p.req)
+		return
+	}
+	p.resp.Message = "处理成功"
+}
+
+func (p BlockHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/get_youngee_record.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetYoungeeRecordsHandler(ctx *gin.Context) {
+	handler := newGetYoungeeRecordsHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetYoungeeRecordsHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetYoungeeRecordsRequest
+	resp *http_model.CommonResponse
+}
+
+func (g GetYoungeeRecordsHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetYoungeeRecordsHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetYoungeeRecordsHandler) getRequest() interface{} {
+	return g.req
+}
+
+func newGetYoungeeRecordsHandler(ctx *gin.Context) *GetYoungeeRecordsHandler {
+	return &GetYoungeeRecordsHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetYoungeeRecordsRequest(),
+		resp: http_model.NewGetYoungeeRecordsResponse(),
+	}
+}
+
+func (g GetYoungeeRecordsHandler) run() {
+	data, err := db.GetYoungeeRecords(g.ctx, g.req.TalentId)
+	if err != nil {
+		logrus.WithContext(g.ctx).Errorf("[GetYoungeeRecordsHandler] error GetYoungeeRecords, err:%+v", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	g.resp.Data = data
+}
+
+func (g GetYoungeeRecordsHandler) checkParam() error {
+	return nil
+}

+ 1 - 0
model/common_model/creator_list.go

@@ -4,4 +4,5 @@ type CreatorListConditions struct {
 	Id               string `condition:"id"`                 // 达人id
 	TalentWxNickname string `condition:"talent_wx_nickname"` // 达人的微信昵称
 	CreateDate       string `condition:"create_date"`        // 创建时间
+	InBlacklist      int    `condition:"in_blacklist"`       // 是否拉黑
 }

+ 29 - 0
model/gorm_model/youngee_info.go

@@ -0,0 +1,29 @@
+package gorm_model
+
+import (
+	"time"
+)
+
+type YounggeeTalentTeam struct {
+	ID              int       `gorm:"column:id;primary_key;AUTO_INCREMENT"` // 递增id
+	TeamID          string    `gorm:"column:team_id"`                       // young之团id,10位随机数
+	TalentID        string    `gorm:"column:talent_id"`                     // 团长达人id,对应youngee_talent_info中id字段
+	ProjectID       string    `gorm:"column:project_id"`                    // 项目id
+	SelectionID     string    `gorm:"column:selection_id"`                  // 选品id
+	ProjectType     int64     `gorm:"column:project_type"`                  // 项目类型,1为项目,2为选品
+	ProjectName     string    `gorm:"column:project_name"`                  // 项目名称
+	ProjectPhoto    string    `gorm:"column:project_photo"`                 // 项目主图
+	Platform        int64     `gorm:"column:platform"`                      // 项目平台
+	TeamStatus      int64     `gorm:"column:team_status"`                   // young之团状态,1表示创建中,2表示开团中,3表示已结束
+	NumApply        int       `gorm:"column:num_apply"`                     // 报名人数
+	NumApplySuccess int       `gorm:"column:num_apply_success"`             // 申请成功人数
+	NumEnd          int       `gorm:"column:num_end"`                       // 结案人数
+	PointIncome     int64     `gorm:"column:point_income"`                  // 积分收益
+	MoneyIncome     string    `gorm:"column:money_income"`                  // 现金收益
+	CreateAt        time.Time `gorm:"column:create_at"`                     // 成团时间
+	EndAt           time.Time `gorm:"column:end_at"`                        // 结束时间
+}
+
+func (m *YounggeeTalentTeam) TableName() string {
+	return "younggee_talent_team"
+}

+ 15 - 0
model/http_model/creatblock.go

@@ -0,0 +1,15 @@
+package http_model
+
+type BlockRequest struct {
+	ID          string `json:"id"`           // 达人id
+	InBlacklist uint   `json:"in_blacklist"` // 项目状态
+}
+
+func NewBlockRequest() *BlockRequest {
+	return new(BlockRequest)
+}
+
+func NewBlockResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 2 - 0
model/http_model/creator_list.go

@@ -6,6 +6,8 @@ type CreatorListRequest struct {
 	Id               string `json:"id"`                 // 达人id
 	TalentWxNickname string `json:"talent_wx_nickname"` // 达人的微信昵称
 	CreateDate       string `json:"create_date"`        // 创建时间
+	InBlacklist      int    `json:"in_blacklist"`       // 是否拉黑
+
 }
 
 type CreatorListPreview struct {

+ 31 - 0
model/http_model/youngee_records.go

@@ -0,0 +1,31 @@
+package http_model
+
+type GetYoungeeRecordsRequest struct {
+	TalentId string `json:"talent_id"`
+}
+
+type YoungeeRecordsPreview struct {
+	ProjectId       string `json:"project_id"`
+	ProjectName     string `json:"project_name"`
+	ProjectType     string `json:"project_type"`
+	ProjectPlatform string `json:"platform"`
+	TeamId          string `json:"team_id"`
+	TeamStatus      string `json:"team_status"`
+	PintIncome      string `json:"point_income"`
+	MoneyIncome     string `json:"money_income"`
+}
+
+type YoungeeRecordsData struct {
+	YoungeeRecordsPreview []*YoungeeRecordsPreview `json:"Youngee_records_preview"`
+	Total                 string                   `json:"total"`
+}
+
+func NewGetYoungeeRecordsRequest() *GetYoungeeRecordsRequest {
+	return new(GetYoungeeRecordsRequest)
+}
+
+func NewGetYoungeeRecordsResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(YoungeeRecordsData)
+	return resp
+}

+ 1 - 0
pack/creator_list_conditions.go

@@ -11,6 +11,7 @@ func HttpCreatorListRequestToCondition(req *http_model.CreatorListRequest) *comm
 		Id:               req.Id,
 		TalentWxNickname: req.TalentWxNickname,
 		CreateDate:       req.CreateDate,
+		InBlacklist:      req.InBlacklist,
 	}
 }
 

+ 7 - 4
route/init.go

@@ -118,10 +118,12 @@ func InitRoute(r *gin.Engine) {
 		u.POST("/creatorList", handler.WrapCreatorListHandler)       // 查找创作者信息
 		u.POST("/platformAccInfo", handler.WrapPlatformAccInfoHandler)
 		u.POST("/talentInfo", handler.WrapTalentInfoHandler)
-		u.POST("/accountInfo", handler.WrapAccountInfoHandler)     // 达人端账号信息
-		u.POST("/deleteAccount", handler.WrapDeleteAccountHandler) // 解绑达人端账号
-		u.POST("/getTaskRecord", handler.WrapGetTaskRecordHandler)
-		u.POST("/modifyAccInfo", handler.WrapModifyAccInfoHandler) // 更新用户账号信息
+		u.POST("/accountInfo", handler.WrapAccountInfoHandler)            // 达人端账号信息
+		u.POST("/deleteAccount", handler.WrapDeleteAccountHandler)        // 解绑达人端账号
+		u.POST("/getTaskRecord", handler.WrapGetTaskRecordHandler)        // 创作者详细-任务记录
+		u.POST("/getYoungeeRecord", handler.WrapGetYoungeeRecordsHandler) // 创作者详细-youngee记录
+		u.POST("/modifyAccInfo", handler.WrapModifyAccInfoHandler)        // 更新用户账号信息
+		u.POST("/block", handler.WrapBlockHandler)                        // 创作者用户拉黑与还原
 	}
 	o := r.Group("/youngee/m/operate")
 	{
@@ -187,5 +189,6 @@ func InitRoute(r *gin.Engine) {
 	{
 		s.Use(middleware.LoginAuthMiddleware)
 		s.GET("/reviewnumber", handler.WrapSelectionReviewNumberHandler) //查询选品待审核的数量
+
 	}
 }