123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- package youngee_talent_service
- import (
- "fmt"
- "youngmini_server/app/dao"
- "youngmini_server/app/model/youngee_talent_model"
- "youngmini_server/app/utils"
- "github.com/gogf/gf/frame/g"
- "github.com/gogf/gf/net/ghttp"
- )
- func OnPostTalentInfo(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- var infos *youngee_talent_model.TalentSelfInputInfo
- err = r.ParseForm(&infos)
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: err.Error()}
- }
- infos.IsBindInfo = 1
- _, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Update(infos, "id", tid)
- if err != nil {
- return &TalentHttpResult{Code: -4, Msg: "update failed"}
- }
- return &TalentHttpResult{Code: 0, Msg: "success"}
- }
- func IsSecCollection(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- selectionId := r.GetQueryString("selection_id")
- collectionInfo := []youngee_talent_model.SelectionCollection{}
- err = g.DB().Model("younggee_selection_collect_info").Where("selection_id=? and talent_id = ?", selectionId, tid).Scan(&collectionInfo)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: err.Error()}
- }
- //已被收藏
- if len(collectionInfo) != 0 && collectionInfo[0].Deleted == 0 { //有数据 且 没取消收藏
- return &TalentHttpResult{Code: 0, Msg: "此选品已被收藏", Data: 0}
- } else {
- return &TalentHttpResult{Code: 0, Msg: "此选品没有被收藏", Data: 1} //没数据 或 有数据但取消了收藏
- }
- //返回的data作为收藏接口的is_collect字段传入
- }
- func OnUpdateTalentInfo(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- var infos *youngee_talent_model.TalentSelfInputInfo
- err = r.ParseForm(&infos)
- fmt.Println("头像地址---->:", infos.Avatar)
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: err.Error()}
- }
- _, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Data(g.Map{"talent_wx_nickname": infos.TalentWxNickname, "avatar": infos.Avatar}).Where("id = ?", tid).Update()
- if err != nil {
- return &TalentHttpResult{Code: -4, Msg: "update failed"}
- }
- return &TalentHttpResult{Code: 0, Msg: "success"}
- }
- func GetTalentInfo(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- talentInfo := youngee_talent_model.TalentInfo{} //结构体实例化
- err = g.DB().Model("youngee_talent_info").WithAll().Where("id", tid).Scan(&talentInfo)
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get talent info failed"}
- }
- return &TalentHttpResult{Code: 0, Msg: "success", Data: talentInfo}
- }
- // 查询任务数量、young之团数量、选品任务数量
- func GetMyInfoNum(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- talentInfoNum := youngee_talent_model.TalentInfoNum{}
- // 查询任务相关数量
- var endTaskStageList = [3]int{3, 5, 16}
- whereCondition := g.Map{
- dao.YoungeeTaskInfo.Columns.TalentId: tid,
- }
- talentInfoNum.AllTaskNum, err = g.DB().Model(dao.YoungeeTaskInfo.Table).Where(whereCondition).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.ApplyTaskNum, err = g.DB().Model(dao.YoungeeTaskInfo.Table).Where("talent_id = ? and task_stage = 1", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.ExeTaskNum, err = g.DB().Model(dao.YoungeeTaskInfo.Table).Where("talent_id = ? and task_stage >= 4 and task_stage <= 14", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.EndTaskNum, err = g.DB().Model(dao.YoungeeTaskInfo.Table).Where("talent_id = ? and task_stage in (?)", tid, endTaskStageList).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- // 查询young之团相关数量
- talentInfoNum.ExeTeamNum, err = g.DB().Model(dao.YounggeeTalentTeam.Table).Where("talent_id = ? and team_status = 2", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.EndTeamNum, err = g.DB().Model(dao.YounggeeTalentTeam.Table).Where("talent_id = ? and team_status = 3", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- // 查询选品任务相关数量
- talentInfoNum.AllSecTaskNum, err = g.DB().Model(youngee_talent_model.SecTaskInfoDetail{}).Where("talent_id = ?", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.GetSampleSecTaskNum, err = g.DB().Model(dao.YounggeeSecTaskInfo.Table).Where("talent_id = ? and free_stage in (3,4, 5)", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.ExeSecTaskNum, err = g.DB().Model(dao.YounggeeSecTaskInfo.Table).Where("talent_id = ? and sale_num_all > 0", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- talentInfoNum.EndSecTaskNum, err = g.DB().Model(dao.YounggeeSecTaskInfo.Table).Where("talent_id = ? and task_ddl < NOW() ", tid).Count()
- if err != nil {
- return &TalentHttpResult{Code: -2, Msg: "Get task num failed"}
- }
- return &TalentHttpResult{Code: 0, Msg: "success", Data: talentInfoNum}
- }
- func AddTalentSkill(r *ghttp.Request) *TalentHttpResult {
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
- }
- skills := r.GetQueryString("skills", "")
- openId := r.GetQueryString("open_id")
- _, err = g.DB().Model("platform_kuaishou_user_info").Where("open_id=? and talent_id=?", openId, tid).Data(g.Map{"skill": skills}).Update()
- if err != nil {
- return &TalentHttpResult{Code: -1, Msg: "Update talent info failed"}
- }
- return &TalentHttpResult{Code: 0, Msg: "success", Data: skills}
- }
|