|
@@ -4,6 +4,8 @@ import (
|
|
|
"encoding/json"
|
|
|
"hongze/hongze_cygxzs/models"
|
|
|
"hongze/hongze_cygxzs/utils"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -32,9 +34,11 @@ func (this *UserController) ChooseDetail() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
+ resp := new(models.CygxXzsChooseSendResp)
|
|
|
mobile := user.Mobile
|
|
|
mapIndustrial := make(map[int][]*models.IndustrialManagementRep)
|
|
|
mapFllow := make(map[int]int)
|
|
|
+ ampCheckList := make(map[int][]int, 0)
|
|
|
fllowList, err := models.GetCygxIndustryFllowList(mobile)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取信息失败"
|
|
@@ -53,6 +57,8 @@ func (this *UserController) ChooseDetail() {
|
|
|
for _, v := range industrialList {
|
|
|
if mapFllow[v.IndustrialManagementId] > 0 {
|
|
|
v.IsFllow = true
|
|
|
+ //添加所关注的行业赛道
|
|
|
+ ampCheckList[v.ChartPermissionId] = append(ampCheckList[v.ChartPermissionId], v.IndustrialManagementId)
|
|
|
}
|
|
|
mapIndustrial[v.ChartPermissionId] = append(mapIndustrial[v.ChartPermissionId], v)
|
|
|
}
|
|
@@ -64,6 +70,12 @@ func (this *UserController) ChooseDetail() {
|
|
|
}
|
|
|
for k, v := range permissionList {
|
|
|
permissionList[k].List = mapIndustrial[v.ChartPermissionId]
|
|
|
+ if len(ampCheckList[v.ChartPermissionId]) == 0 {
|
|
|
+ permissionList[k].CheckList = make([]int, 0)
|
|
|
+ } else {
|
|
|
+ permissionList[k].CheckList = ampCheckList[v.ChartPermissionId]
|
|
|
+ }
|
|
|
+ permissionList[k].AllTracks = "全部赛道"
|
|
|
}
|
|
|
count, err := models.GetXzsChooseSendCountByMobile(mobile)
|
|
|
if err != nil {
|
|
@@ -71,7 +83,7 @@ func (this *UserController) ChooseDetail() {
|
|
|
br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- resp := new(models.CygxXzsChooseSendResp)
|
|
|
+
|
|
|
if count == 0 {
|
|
|
resp.IsObjective = 1
|
|
|
resp.IsSubjective = 1
|
|
@@ -85,7 +97,7 @@ func (this *UserController) ChooseDetail() {
|
|
|
|
|
|
// @Title 提交用户的选择详情
|
|
|
// @Description 提交用户的选择详情接口
|
|
|
-// @Param request body models.ActivityIdRep true "type json string"
|
|
|
+// @Param request body models.SubmitChooseSendResp true "type json string"
|
|
|
// @Success 200 {object} models.CygxXzsChooseSendResp
|
|
|
// @router /choose/submit [post]
|
|
|
func (this *UserController) ChooseSubmit() {
|
|
@@ -101,7 +113,11 @@ func (this *UserController) ChooseSubmit() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ if user.Mobile == "" {
|
|
|
+ br.Msg = "提交失败!"
|
|
|
+ br.ErrMsg = "提交失败,手机号不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
var req models.SubmitChooseSendResp
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
@@ -109,6 +125,27 @@ func (this *UserController) ChooseSubmit() {
|
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ industrialManagementIds := req.IndustrialManagementIds
|
|
|
+ sliceIndustrial := strings.Split(industrialManagementIds, ",")
|
|
|
+
|
|
|
+ var itemsFllow []*models.CygxIndustryFllow
|
|
|
+ for _, v := range sliceIndustrial {
|
|
|
+ item := new(models.CygxIndustryFllow)
|
|
|
+ industrialManagementId, _ := strconv.Atoi(v)
|
|
|
+ item.IndustrialManagementId = industrialManagementId
|
|
|
+ item.UserId = user.UserId
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.Type = 1
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.Source = 2
|
|
|
+ itemsFllow = append(itemsFllow, item)
|
|
|
+ }
|
|
|
+
|
|
|
mobile := user.Mobile
|
|
|
item := new(models.CygxXzsChooseSend)
|
|
|
item.UserId = user.UserId
|
|
@@ -128,23 +165,11 @@ func (this *UserController) ChooseSubmit() {
|
|
|
br.ErrMsg = "GetXzsChooseSendCountByMobile,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ //如果有记录就新增,没有记录就修改
|
|
|
if count == 0 {
|
|
|
- err = models.AddCygxXzsChooseSend(item)
|
|
|
+ err = models.AddCygxXzsChooseSend(item, itemsFllow)
|
|
|
} else {
|
|
|
- updateParams := make(map[string]interface{})
|
|
|
- updateParams["UserId"] = item.UserId
|
|
|
- updateParams["Mobile"] = item.Mobile
|
|
|
- updateParams["Email"] = item.Email
|
|
|
- updateParams["CompanyId"] = item.CompanyId
|
|
|
- updateParams["CompanyName"] = item.CompanyName
|
|
|
- updateParams["RealName"] = item.RealName
|
|
|
- updateParams["ModifyTime"] = time.Now()
|
|
|
- updateParams["IsRefuse"] = item.IsRefuse
|
|
|
- updateParams["IsSubjective"] = item.IsSubjective
|
|
|
- updateParams["IsObjective"] = item.IsObjective
|
|
|
-
|
|
|
- whereParam := map[string]interface{}{"mobile": item.Mobile}
|
|
|
- err = models.UpdateByExpr(models.CygxXzsChooseSend{}, whereParam, updateParams)
|
|
|
+ err = models.UpdateCygxXzsChooseSend(item, itemsFllow)
|
|
|
}
|
|
|
if err != nil {
|
|
|
br.Msg = "保存失败!"
|