|
@@ -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() {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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 = "操作成功"
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ chartPermissionidsSlice := strings.Split(detail.ChartPermissionids, ",")
|
|
|
+ activityTypeidsSlice := strings.Split(detail.ActivityTypeids, ",")
|
|
|
+ activeStateSlice := strings.Split(detail.ActiveState, ",")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|