package ctrl_v1

import (
	"gd_management_gateway/errors"
	"gd_management_gateway/params/param_base"
	"gd_management_gateway/params/param_v1_0"
	"gd_management_gateway/rpc_apis"
	"gd_management_gateway/rpc_apis/gd_management"
	"fmt"
	"time"

	"gd_management_gateway/common.in/httper"
	"gd_management_gateway/common.in/task"
	"gd_management_gateway/common.in/utils"
	"go.uber.org/zap"

	"github.com/astaxie/beego"
)

// Operations about base api
type H5ServiceController struct {
	metadata interface{} // 中继元数据
	beego.Controller
	LogID string
}

// @Title add h5 service
// @Description 添加 h5 服务
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   service_name    query   string true "服务名称"
// @Param   version    query   string true "版本"
// @Param   type    query   string true "类别"
// @Success 200 	{object} params.param_v1_0.ManagementAddH5ServiceResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service [post]
func (u *H5ServiceController) ManagementAddH5Service() {
	u.LogID = fmt.Sprintf("ManagementAddH5Service[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementAddH5ServiceReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementAddH5ServiceReq{}
		mreq.ServiceName = req.ServiceName
		mreq.Version = req.Version
		mreq.Type = req.Type

		reply, err := rpc_apis.Management.ManagementAddH5Service(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementAddH5Service"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementAddH5ServiceResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.H5ServiceId = reply.H5ServiceId
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title del h5 service
// @Description 删除 h5 服务
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query   int64 true "h5_service_id"
// @Success 200 	{object} params.param_v1_0.ManagementDelH5ServiceResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service [delete]
func (u *H5ServiceController) ManagementDelH5Service() {
	u.LogID = fmt.Sprintf("ManagementDelH5Service[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementDelH5ServiceReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementDelH5ServiceReq{}
		mreq.H5ServiceId = req.H5ServiceId

		_, err := rpc_apis.Management.ManagementDelH5Service(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementDelH5Service"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementDelH5ServiceResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title update h5 service
// @Description 更新 h5 服务
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query   int64 true "h5_service_id"
// @Param   service_name 	 query   string true "service_name"
// @Param   version    query   string false "版本"
// @Param   type    query   string false "类别"
// @Success 200 	{object} params.param_v1_0.ManagementUpdateH5ServiceResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service [put]
func (u *H5ServiceController) ManagementUpdateH5Service() {
	u.LogID = fmt.Sprintf("ManagementUpdateH5Service[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementUpdateH5ServiceReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementUpdateH5ServiceReq{}
		mreq.H5ServiceId = req.H5ServiceId
		mreq.ServiceName = req.ServiceName
		mreq.Type = req.Type
		mreq.Version = req.Version

		_, err := rpc_apis.Management.ManagementUpdateH5Service(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementUpdateH5Service"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementUpdateH5ServiceResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title release h5 service
// @Description 发布 h5 服务
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query   int64 true "h5_service_id"
// @Success 200 	{object} params.param_v1_0.ManagementReleaseH5ServiceResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_release [put]
func (u *H5ServiceController) ManagementReleaseH5Service() {
	u.LogID = fmt.Sprintf("ManagementReleaseH5Service[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementReleaseH5ServiceReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementReleaseH5ServiceReq{}
		mreq.H5ServiceId = req.H5ServiceId

		_, err := rpc_apis.Management.ManagementReleaseH5Service(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementReleaseH5Service"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementReleaseH5ServiceResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title get h5 service list
// @Description 获取 h5 服务列表
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   page_number    query   int true "page_number"
// @Param   is_all   		query bool true "is_all"
// @Success 200 	{object} params.param_v1_0.ManagementGetH5ServiceListResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_list [get]
func (u *H5ServiceController) ManagementGetH5ServiceList() {
	u.LogID = fmt.Sprintf("ManagementGetH5ServiceList[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementGetH5ServiceListReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementGetH5ServiceListReq{}
		mreq.PageNumber = req.PageNumber
		mreq.IsAll = req.IsAll

		reply, err := rpc_apis.Management.ManagementGetH5ServiceList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementGetH5ServiceList"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementGetH5ServiceListResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.PageNumber = reply.PageNumber
		resp.PageSize = reply.PageSize
		resp.Total = reply.Total
		resp.H5ServiceList = reply.H5ServiceList
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service add h5 api
// @Description h5 服务添加h5 api
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   data    body   params.param_v1_0.H5ServiceAddH5ApiData true "data"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceAddH5ApiResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_h5_api [post]
func (u *H5ServiceController) ManagementH5ServiceAddH5Api() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceAddH5Api[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceAddH5ApiReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceAddH5ApiReq{}
		mreq.H5ServiceId = req.Data.H5ServiceId
		mreq.H5ApiIds = req.Data.H5ApiIds

		_, err := rpc_apis.Management.ManagementH5ServiceAddH5Api(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceAddH5Api"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceAddH5ApiResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service get h5 api list
// @Description 获取h5 服务中的h5 api 列表
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query  int64 true "h5_service_id"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceGetH5ApiListResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_h5_api_list [get]
func (u *H5ServiceController) ManagementH5ServiceGetH5ApiList() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceGetH5ApiList[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceGetH5ApiListReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceGetH5ApiListReq{}
		mreq.H5ServiceId = req.H5ServiceId

		reply, err := rpc_apis.Management.ManagementH5ServiceGetH5ApiList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceGetH5ApiList"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceGetH5ApiListResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.H5ApiList = reply.H5ApiList
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service add combo
// @Description h5 服务添加套餐
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_combo_data    body  rpc_apis.gd_management.ManagementH5ServiceAddComboReq true "h5_combo_data"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceAddComboResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_combo [post]
func (u *H5ServiceController) ManagementH5ServiceAddCombo() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceAddCombo[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceAddComboReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceAddComboReq{}
		mreq.H5ComboList = req.ComboData.H5ComboList

		_, err := rpc_apis.Management.ManagementH5ServiceAddCombo(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceAddCombo"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceAddComboResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service del combo
// @Description h5 服务删除套餐
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_combo_id    query  int64 true "h5_combo_id"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceDelComboResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_combo [delete]
func (u *H5ServiceController) ManagementH5ServiceDelCombo() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceDelCombo[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceDelComboReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceDelComboReq{}
		mreq.ComboId = req.ComboId

		_, err := rpc_apis.Management.ManagementH5ServiceDelCombo(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceDelCombo"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceDelComboResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service update combo
// @Description h5 服务更新套餐
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_combo_id    query  int64 true "h5_combo_id"
// @Param   h5_combo_count query int true "h5_combo_count query"
// @Param	h5_combo_total_day query int true "h5_combo_total_day"
// @Param	h5_combo_price query float64 true "h5_combo_price"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceUpdateComboResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_combo [put]
func (u *H5ServiceController) ManagementH5ServiceUpdateCombo() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceUpdateCombo[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceUpdateComboReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceUpdateComboReq{}
		mreq.ComboId = req.ComboId
		mreq.TotalDay = req.TotalDay
		mreq.Count = req.Count
		mreq.Price = req.Price

		_, err := rpc_apis.Management.ManagementH5ServiceUpdateCombo(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceUpdateCombo"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceUpdateComboResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service get combo list
// @Description h5 服务获取套餐列表
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query  int64 true "h5_service_id"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceGetComboListResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_combo_list [get]
func (u *H5ServiceController) ManagementH5ServiceGetComboList() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceGetComboList[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceGetComboListReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceGetComboListReq{}
		mreq.H5ServiceId = req.H5ServiceId

		reply, err := rpc_apis.Management.ManagementH5ServiceGetComboList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceGetComboList"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceGetComboListResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.IsFree = reply.IsFree
		resp.DayCountCombos = reply.DayCountCombos
		resp.TotalCountCombos = reply.TotalCountCombos
		resp.FreeCombos = reply.FreeCombos
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 service set free combo
// @Description h5 服务设置免费套餐
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   h5_service_id    query  int64 true "h5_service_id"
// @Param   h5_service_is_free    query  bool true ""
// @Param   count    query  int true "count"
// @Success 200 	{object} params.param_v1_0.ManagementH5ServiceSetComboFreeResp "响应信息"
// @Failure 500 	服务器错误
// @router /h5_service_set_combo_free [put]
func (u *H5ServiceController) ManagementH5ServiceSetComboFree() {
	u.LogID = fmt.Sprintf("ManagementH5ServiceSetComboFree[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementH5ServiceSetComboFreeReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementH5ServiceSetComboFreeReq{}
		mreq.H5ServiceId = req.H5ServiceId
		mreq.H5ServiceIsFree = req.H5ServiceIsFree
		mreq.Count = req.Count

		_, err := rpc_apis.Management.ManagementH5ServiceSetComboFree(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementH5ServiceSetComboFree"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementH5ServiceSetComboFreeResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 add theme color
// @Description h5 添加主题颜色
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   theme_color    query  string true "theme_color"
// @Success 200 	{object} params.param_v1_0.ManagementAddH5ThemeColorResp "响应信息"
// @Failure 500 	服务器错误
// @router /theme_color [post]
func (u *H5ServiceController) ManagementAddH5ThemeColor() {
	u.LogID = fmt.Sprintf("ManagementAddH5ThemeColor[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementAddH5ThemeColorReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementAddH5ThemeColorReq{}
		mreq.ThemeColor = req.ThemeColor

		reply, err := rpc_apis.Management.ManagementAddH5ThemeColor(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementAddH5ThemeColor"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementAddH5ThemeColorResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.ThemeColorId = reply.ThemeColorId
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 del theme color
// @Description h5 删除主题颜色
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   theme_color_id    query  int64 true "theme_color_id"
// @Success 200 	{object} params.param_v1_0.ManagementDelH5ThemeColorResp "响应信息"
// @Failure 500 	服务器错误
// @router /theme_color [delete]
func (u *H5ServiceController) ManagementDelH5ThemeColor() {
	u.LogID = fmt.Sprintf("ManagementDelH5ThemeColor[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementDelH5ThemeColorReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementDelH5ThemeColorReq{}
		mreq.ThemeColorId = req.ThemeColorId

		_, err := rpc_apis.Management.ManagementDelH5ThemeColor(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementDelH5ThemeColor"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementDelH5ThemeColorResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 update theme color
// @Description h5 更新主题颜色
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Param   theme_color_id    query  int64 true "theme_color_id"
// @Param   theme_color    query  string true "theme_color"
// @Success 200 	{object} params.param_v1_0.ManagementUpdateH5ThemeColorResp "响应信息"
// @Failure 500 	服务器错误
// @router /theme_color [put]
func (u *H5ServiceController) ManagementUpdateH5ThemeColor() {
	u.LogID = fmt.Sprintf("ManagementUpdateH5ThemeColor[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementUpdateH5ThemeColorReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementUpdateH5ThemeColorReq{}
		mreq.ThemeColorId = req.ThemeColorId
		mreq.ThemeColor = req.ThemeColor

		_, err := rpc_apis.Management.ManagementUpdateH5ThemeColor(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementUpdateH5ThemeColor"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementUpdateH5ThemeColorResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}

// @Title  h5 get theme color list
// @Description h5 获取主题颜色列表
// @Param   token    header   string true "token"
// @Param   uid    header   string true "uid"
// @Success 200 	{object} params.param_v1_0.ManagementGetH5ThemeColorListResp "响应信息"
// @Failure 500 	服务器错误
// @router /theme_color [get]
func (u *H5ServiceController) ManagementGetH5ThemeColorList() {
	u.LogID = fmt.Sprintf("ManagementGetH5ThemeColorList[%d]", time.Now().UnixNano())

	req := &param_v1_0.ManagementGetH5ThemeColorListReq{}
	getParamsTask := func() error {
		httper.FillRequireParams(u.Ctx, req, u.LogID)
		return nil
	}

	handleDataTask := func() error {
		mreq := gd_management.ManagementGetH5ThemeColorListReq{}

		reply, err := rpc_apis.Management.ManagementGetH5ThemeColorList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
		if err != nil {
			l.Error("rpc",
				zap.String("call", "ManagementGetH5ThemeColorList"),
				zap.String("args", utils.MarshalJsonString(req)),
				zap.String("error", err.Error()))
			return errors.ErrorTransform(err)
		}
		resp := param_v1_0.ManagementGetH5ThemeColorListResp{
			SimpleResp: param_base.SimpleResp{
				Code: 0,
				Msg:  "SUCCESS",
			},
		}
		resp.ThemeColorList = reply.ThemeColorList
		httper.JSON(u.Ctx, resp, u.LogID)
		return nil
	}

	// 执行以上定义的任务
	task.Do(&task.PanicRecover{
		Ctx:   u.Ctx,
		LogID: u.LogID}, u.Ctx,
		getParamsTask, handleDataTask,
	)
}
