|
@@ -1,6 +1,7 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"rdluck_tools/paging"
|
|
@@ -53,6 +54,7 @@ func (this *ActivityCoAntroller) List() {
|
|
|
// @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
|
|
|
// @Param KeyWord query string false "搜索关键词"
|
|
|
// @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
|
|
|
+// @Param IsShowJurisdiction query int false "是否仅展示有权限的,1是,0否 默认为零"
|
|
|
// @Success 200 {object} models.GetCygxActivityListRep
|
|
|
// @router /list [get]
|
|
|
func (this *ActivityCoAntroller) ActivityList() {
|
|
@@ -73,12 +75,34 @@ func (this *ActivityCoAntroller) ActivityList() {
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
chartPermissionIds := this.GetString("ChartPermissionIds")
|
|
|
activityTypeIds := this.GetString("ActivityTypeIds")
|
|
|
+ isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
|
|
|
|
|
|
keyWord := this.GetString("KeyWord")
|
|
|
activeState := this.GetString("ActiveState")
|
|
|
if activeState != "2" && activeState != "3" {
|
|
|
activeState = "1"
|
|
|
}
|
|
|
+ if isShowJurisdiction != 1 {
|
|
|
+ isShowJurisdiction = 0
|
|
|
+ }
|
|
|
+ itemSearch := new(models.CygxActivityUserSearchContent)
|
|
|
+ itemSearch.UserId = uid
|
|
|
+ itemSearch.CreateTime = time.Now()
|
|
|
+ itemSearch.Mobile = user.Mobile
|
|
|
+ itemSearch.Email = user.Email
|
|
|
+ itemSearch.CompanyId = user.CompanyId
|
|
|
+ itemSearch.CompanyName = user.CompanyName
|
|
|
+ itemSearch.ModifyTime = time.Now()
|
|
|
+ itemSearch.ChartPermissionids = chartPermissionIds
|
|
|
+ itemSearch.ActivityTypeids = activityTypeIds
|
|
|
+ itemSearch.ActiveState = activeState
|
|
|
+ itemSearch.IsShowJurisdiction = isShowJurisdiction
|
|
|
+ _, errSearch := models.AddUserSearchContent(itemSearch)
|
|
|
+ if errSearch != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSearch.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
|
pageSize = utils.PageSize20
|
|
@@ -221,3 +245,170 @@ func (this *ActivityCoAntroller) Detail() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = activityInfo
|
|
|
}
|
|
|
+
|
|
|
+// @Title 活动的报名
|
|
|
+// @Description 活动的报名接口
|
|
|
+// @Param request body models.ActivityIdRep true "type json string"
|
|
|
+// @Success 200 操作成功
|
|
|
+// @router /signup/add [post]
|
|
|
+func (this *ActivityCoAntroller) PublishAndCancel() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,用户信息为空"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ var req models.ActivityIdRep
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId := req.ActivityId
|
|
|
+ item := new(models.CygxActivitySignup)
|
|
|
+ activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
|
|
|
+ if activityInfo == nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if errInfo != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errInfo.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item.UserId = uid
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = user.CompanyName
|
|
|
+ _, errSignup := models.AddActivitySignup(item)
|
|
|
+ if errSignup != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + errSignup.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 用户搜索详情
|
|
|
+// @Description 获取活动详情接口
|
|
|
+// @Param ActivityId query int true "活动ID"
|
|
|
+// @Param IsShowJurisdiction query int true "是否仅展示有权限的,1是,0否 默认为0"
|
|
|
+// @Success Ret=200 {object} models.ActivityDetail
|
|
|
+// @router /getUserSearchContent [get]
|
|
|
+func (this *ActivityCoAntroller) GetUserSearchContent() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,用户信息为空"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ detail, err := models.GetUserSearchContentByUid(uid)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //ChartPermissionids string `description:"行业id"`
|
|
|
+ //ActivityTypeids string `description:"活动类型id"`
|
|
|
+ //ActiveState string `description:
|
|
|
+ //IsShowJurisdiction int `description:"是否仅展示有权限的,1是,0否"`
|
|
|
+ chartPermissionidsSlice := strings.Split(detail.ChartPermissionids, ",")
|
|
|
+ activityTypeidsSlice := strings.Split(detail.ActivityTypeids, ",")
|
|
|
+ activeStateSlice := strings.Split(detail.ActiveState, ",")
|
|
|
+
|
|
|
+ //activeStateSlice := [3]int{1, 2, 3} //"活动进行状态 未开始:1、进行中2、已结束3"`
|
|
|
+
|
|
|
+ listActivityType, errActivityType := models.GetActivityTypeList()
|
|
|
+ if errActivityType != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range activityTypeidsSlice {
|
|
|
+ for k2, v2 := range listActivityType {
|
|
|
+ if strconv.Itoa(v2.ActivityTypeId) == v {
|
|
|
+ listActivityType[k2].IsChoose = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ listChartPermissionid, errChart := models.GetChartPermissionActivity()
|
|
|
+ if errChart != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range chartPermissionidsSlice {
|
|
|
+ for k2, v2 := range listChartPermissionid {
|
|
|
+ if strconv.Itoa(v2.ChartPermissionId) == v {
|
|
|
+ listChartPermissionid[k2].IsChoose = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp := new(models.ActivityUserSearchContentList)
|
|
|
+ resp.ListActivityType = listActivityType
|
|
|
+ resp.ListChartPermission = listChartPermissionid
|
|
|
+
|
|
|
+ if detail.IsShowJurisdiction == 1 {
|
|
|
+ resp.IsShowJurisdiction = true
|
|
|
+ }
|
|
|
+ activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始"}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
|
|
|
+
|
|
|
+ for _, v := range activeStateSlice {
|
|
|
+ for k2, v2 := range activeStateList {
|
|
|
+ if strconv.Itoa(v2.Id) == v {
|
|
|
+ activeStateList[k2].IsChoose = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
|
|
|
+ activeStateList[0].IsChoose = true
|
|
|
+ }
|
|
|
+ resp.ListActivityStaus = activeStateList
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+type Arrayse struct {
|
|
|
+ Id int
|
|
|
+ IsChoose bool
|
|
|
+ Name string
|
|
|
+}
|
|
|
+
|
|
|
+//"list" : [
|
|
|
+// {
|
|
|
+// "id" :1,
|
|
|
+// "IsChoose": bool
|
|
|
+// },
|
|
|
+// {
|
|
|
+// "id" :2,
|
|
|
+// "IsChoose": bool
|
|
|
+// },
|
|
|
+// {
|
|
|
+// "id" :3,
|
|
|
+// "IsChoose": bool
|
|
|
+// }
|
|
|
+//]
|