jyq 4 lat temu
commit
3ae553ed66

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+
+.idea
+*.log
+go.sum

+ 51 - 0
build_api_app.ps1

@@ -0,0 +1,51 @@
+$beginPWD = $PWD
+$module = "video_course"
+try {
+    Write-Output "set location to script path: $PSScriptRoot"
+    Set-Location $PSScriptRoot
+
+    git checkout master
+    git checkout .
+    git pull
+#     git submodule foreach git checkout master
+#     git submodule foreach git pull
+#     .\scrips\gen_proto.ps1
+
+    $cmd = "git describe --tags"
+    $version = Invoke-Expression $cmd
+    Write-Output "version: $version"
+
+    $stableVersionParttern = ".*-stable$"
+
+    $isStable = $version -match $stableVersionParttern
+    if ($isStable) {
+        Write-Output "is stable version"
+    }
+
+    Write-Output "use origin golang compiler"
+    Set-Location ($PSScriptRoot + "/assembly/$module/main")
+
+    $cmd = "go build -o $module -ldflags ""-X main._VERSION_='$version'"""
+    Write-Output $cmd
+    Invoke-Expression $cmd
+    Write-Output "compile finish"
+
+    Remove-Item "$PSScriptRoot/docker/$module/$module"
+    Move-Item "$module" "$PSScriptRoot/docker/$module/$module"
+    $dockerImage = "docker.beswell.com:5050/loallout/$module"
+    $dockerImageWithVersion = "${dockerImage}:$version"
+    $dockerImageLatest = "${dockerImage}:latest"
+    $cmd = "docker build -t $dockerImageWithVersion $PSScriptRoot/docker/$module"
+    Invoke-Expression $cmd
+    $cmd = "docker tag $dockerImageWithVersion $dockerImageLatest"
+    Invoke-Expression $cmd
+    $cmd = "docker push $dockerImageWithVersion"
+    Invoke-Expression $cmd
+    $cmd = "docker push $dockerImageLatest"
+    Invoke-Expression $cmd
+}
+catch {
+    $err = $Error[0]
+    Write-Error $err
+}
+Set-Location $beginPWD

+ 33 - 0
controller/auth.go

@@ -0,0 +1,33 @@
+package controller
+
+import (
+	"github.com/sirupsen/logrus"
+	"net/http"
+)
+
+type Auth struct {
+	BaseController
+}
+
+// SignUp godoc
+// @Summary 用户添加
+// @tags Auth
+// @Description 用户添加
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param userCode formData string true "用户名"
+// @Param password formData string true "密码"
+// @Param email formData string false "邮箱"
+// @Param phone formData string false "手机号"
+// @Param name formData string false "姓名"
+// @Success 200 {object} controller.ResponseBase
+// @Router /Auth/SignUp [post]
+func (a *Auth) HttpPostSignUp() (err error) {
+	userCode := a.Ctx().PostForm("userCode")
+	test := a.PostFromInt("test")
+	test2 := a.PostFromIntPtr("test2")
+	logrus.Info(userCode, test, test2)
+
+	a.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}

+ 111 - 0
controller/base.go

@@ -0,0 +1,111 @@
+/*
+@Time : 2019-06-26 9:31
+@Author : zr
+@Software: GoLand
+*/
+package controller
+
+import (
+	"fmt"
+	"gitee.com/zr233/bsf"
+	"net/http"
+	"strconv"
+	"time"
+	"video_course/errors"
+	"video_course/model"
+	"video_course/utils"
+)
+
+type Controller interface {
+}
+type BaseController struct {
+	*bsf.ControllerBase
+}
+
+type ResponseBase struct {
+	Code errors.ErrorCode
+	Memo string
+}
+
+func newResponseBase() ResponseBase {
+	return ResponseBase{
+		Code: errors.CodeSUCCESS,
+		Memo: "执行成功",
+	}
+}
+
+func (b BaseController) getSession() *model.Session {
+	if s, ok := b.Ctx().Get("session"); ok {
+		s, ok := s.(*model.Session)
+		if ok {
+			return s
+		}
+	}
+	return nil
+}
+
+func (b *BaseController) postInt(key string) (value *int) {
+	valueStr := b.Ctx().PostForm(key)
+	if valueStr != "" {
+		valueInt, err := strconv.Atoi(valueStr)
+		if err != nil {
+			panic(errors.NewParamErr(err))
+		}
+		value = &valueInt
+	}
+
+	return
+}
+func (b *BaseController) postIntNecessary(key string) (value int) {
+	valueStr := b.Ctx().PostForm(key)
+	var err error
+	if valueStr != "" {
+		value, err = strconv.Atoi(valueStr)
+		if err != nil {
+			panic(errors.FromParamErr(key, err))
+		}
+	} else {
+		panic(errors.FromParamErr(key, fmt.Errorf("参数不能为空。")))
+	}
+	return
+}
+
+func (b *BaseController) postString(key string, necessary bool) string {
+	str := b.Ctx().PostForm(key)
+	if necessary && str == "" {
+		err := errors.FromParamErr(key, fmt.Errorf("参数不能为空。"))
+		panic(err)
+	}
+	return str
+}
+
+// 日期校验
+func (b *BaseController) getPostFromDate(key string) (value time.Time) {
+	valueStr := b.Ctx().PostForm(key)
+	value, e := time.Parse(utils.TimeFormatterDate(), valueStr)
+	if e != nil {
+		err := errors.FromParamErr(key, e)
+		panic(err)
+	}
+	return value
+}
+
+func (b *BaseController) postFloatToInt(key string, necessary bool) int {
+	str := b.Ctx().PostForm(key)
+	if necessary && str == "" {
+		err := errors.FromParamErr(key, fmt.Errorf("参数不能为空。"))
+		panic(err)
+	}
+	wt, err := strconv.ParseFloat(str, 32)
+	if err != nil {
+		err := errors.FromParamErr(key, err)
+		panic(err)
+	}
+	i := int(wt * 10) // 乘以10转int型,保留1位小数
+	return i
+}
+
+// 返回json
+func (b BaseController) json(obj interface{}) {
+	b.Ctx().JSON(http.StatusOK, obj)
+}

+ 342 - 0
controller/hrSensors.go

@@ -0,0 +1,342 @@
+/**
+ * @ File:
+ * @ Date: 2021/1/25 16:15
+ * @ Author: JYQ
+ * @ Description:
+ */
+package controller
+
+type HrSensors struct {
+	BaseController
+}
+
+// AddHrSensors godoc
+// @Summary 添加商家公共心率设备
+// @tags HrSensors
+// @Description 添加商家公共心率设备
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "商家ID"
+// @Param sn formData int true "心率带Sn"
+// @Param venueNo formData string false "场馆内编号  01 02"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/AddHrSensors [post]
+func (h *HrSensors) AddHrSensors() (err error) {
+	//sess := h.Ctx().PostForm("Token")
+	//sn := h.postString("sn", true)
+	//venueNo := h.Ctx().PostForm("venueNo")
+	//shopId := h.postIntNecessary("shopId")
+	//
+	//logInfo, err := service.HrSensors{}.AddHrSensors(sess, sn, venueNo, shopId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+// AddPvtHrSensors godoc
+// @Summary 添加会员私有心率设备
+// @tags HrSensors
+// @Description 添加会员私有心率设备
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "商家ID"
+// @Param sn formData int true "心率带Sn"
+// @Param userId formData int true "用户ID"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/AddPvtHrSensors [post]
+func (h *HrSensors) AddPvtHrSensors() (err error) {
+	//sess := h.Ctx().PostForm("Token")
+	//sn := h.postString("sn", true)
+	//shopId := h.postIntNecessary("shopId")
+	//userId := h.postIntNecessary("userId")
+	//
+	//logInfo, err := service.HrSensors{}.AddPvtHrSensors(sess, sn, userId, shopId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+// EditHrSensors godoc
+// @Summary 修改商家心率设备信息
+// @tags HrSensors
+// @Description 修改商家心率设备信息
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param hrId formData int true "心率带ID"
+// @Param sn formData string true "心率带Sn"
+// @Param shopId formData string true "商家ID"
+// @Param venueNo formData string false "场馆内编号  01 02"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/EditHrSensors [post]
+func (h *HrSensors) EditHrSensors() (err error) {
+	//sess := h.getSession()
+	//sn := h.postString("sn", true)
+	//venueNo := h.Ctx().PostForm("venueNo")
+	//hrId := h.postIntNecessary("hrId")
+	//shopId := h.postIntNecessary("shopId")
+	//
+	//logInfo, err := service.HrSensors{}.EditHrSensors(sess, sn, venueNo, shopId, hrId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+// HrSensorsStatusEdit godoc
+// @Summary 修改商家心率设备状态
+// @tags HrSensors
+// @Description 修改商家心率设备状态
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param hrId formData int true "心率带ID"
+// @Param status formData int true "状态, 1:启用,8:暂停,9:删除"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/HrSensorsStatusEdit [post]
+func (h *HrSensors) HrSensorsStatusEdit() (err error) {
+	//sess := h.getSession()
+	//hrId := h.postIntNecessary("hrId")
+	//status := h.postIntNecessary("status")
+	//
+	//logInfo, err := service.HrSensors{}.HrSensorsStatusEdit(sess, hrId, status)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+type QueryHrSensorsInfo struct {
+	ResponseBase
+	Rs string
+}
+
+// QueryHrSensors godoc
+// @Summary 查询商家公共心率设备
+// @tags HrSensors
+// @Description 查询商家公共心率设备
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "商家ID"
+// @Param status formData int false "设备状态"
+// @Param str formData string false "模糊查询sn与场内编号"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/QueryHrSensors [post]
+func (h *HrSensors) QueryHrSensors() (err error) {
+	//sess := h.getSession()
+	//str := h.Ctx().PostForm("str")
+	//shopId := h.postIntNecessary("shopId")
+	//status := h.postInt("status")
+	//hr, err := service.HrSensors{}.QueryHrSensors(sess, shopId, str, status)
+	//if err != nil {
+	//	return
+	//}
+	//h.json(QueryHrSensorsInfo{
+	//	ResponseBase: ResponseBase{},
+	//	Rs:           hr,
+	//})
+	return
+}
+
+// QueryPvtHrSensors godoc
+// @Summary 查询商家会员私有心率设备
+// @tags HrSensors
+// @Description 查询商家会员私有心率设备
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "商家ID"
+// @Param status formData int false "设备状态"
+// @Param userName formData string false "用户姓名"
+// @Param str formData string false "模糊查询sn与场内编号"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/QueryPvtHrSensors [post]
+func (h *HrSensors) QueryPvtHrSensors() (err error) {
+	//sess := h.getSession()
+	//str := h.Ctx().PostForm("str")
+	//userName := h.Ctx().PostForm("userName")
+	//shopId := h.postIntNecessary("shopId")
+	//status := h.postInt("status")
+	//hr, err := service.HrSensors{}.QueryPvtHrSensors(sess, shopId, str, userName, status)
+	//if err != nil {
+	//	return
+	//}
+	//h.json(QueryHrSensorsInfo{
+	//	ResponseBase: ResponseBase{},
+	//	Rs:           hr,
+	//})
+	return
+}
+
+// BindHrSensorsToUser godoc
+// @Summary 心率带绑定用户
+// @tags HrSensors
+// @Description 心率带绑定用户
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param sn formData string true "心率带Sn"
+// @Param cfId formData int true "课堂记录Id,必传字段"
+// @Param userId formData int true "用户Id"
+// @Param shopId formData int true "商家ID"
+// @Param hrId formData int true "心率带ID"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/BindHrSensorsToUser [post]
+func (h *HrSensors) BindHrSensorsToUser() (err error) {
+	//sess := h.getSession()
+	//sn := h.postString("sn", true)
+	//cfId := h.postIntNecessary("cfId")
+	//userId := h.postIntNecessary("userId")
+	//shopId := h.postIntNecessary("shopId")
+	//hrId := h.postIntNecessary("hrId")
+	////dpId := h.postInt("dpId")  // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
+	////oldSn := h.Ctx().PostForm("oldSn")
+	//
+	//logInfo, err := service.HrSensors{}.HrSensorsBindUser(sess, sn, cfId, userId, shopId, hrId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+// UnBindHrSensorsToUser godoc
+// @Summary 心率带解绑用户
+// @tags HrSensors
+// @Description 心率带解绑用户
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param cfId formData int true "课堂记录Id,必传字段"
+// @Param bindId formData int true "绑定ID"
+// @Param userId formData int true "用户ID"
+// @Param sn formData string true "心率带Sn"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/UnBindHrSensorsToUser [post]
+func (h *HrSensors) UnBindHrSensorsToUser() (err error) {
+	//sess := h.getSession()
+	//cfId := h.postIntNecessary("cfId")
+	//bindId := h.postIntNecessary("bindId")
+	//userId := h.postIntNecessary("userId")
+	//sn := h.postString("sn", true)
+	//
+	//logInfo, err := service.HrSensors{}.UnBindHrSensorsToUser(sess, sn, cfId, bindId, userId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}
+
+type SelectHrSensorsRs struct {
+	ResponseBase
+	Rs string
+	//Rs []*model.HrSensors
+}
+
+// SelectHrSensors godoc
+// @Summary 查询未绑定的心率带--下拉框用
+// @tags HrSensors
+// @Description 查询未绑定的心率带--下拉框用
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param userId formData int false "用户ID"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/SelectHrSensors [post]
+func (h *HrSensors) SelectHrSensors() (err error) {
+	//sess := h.getSession()
+	//userId := h.postInt("userId")
+	//rs, err := service.HrSensors{}.SelectHrSensors(sess, userId)
+	//if err != nil {
+	//	return
+	//}
+	//h.json(SelectHrSensorsRs{
+	//	ResponseBase: ResponseBase{},
+	//	Rs:           rs,
+	//})
+	return
+}
+
+type HrSensorsBindHistoryRs struct {
+	ResponseBase
+	Rs string
+}
+
+// HrSensorsBindHistory godoc
+// @Summary 查询心率带绑定历史记录
+// @tags HrSensors
+// @Description 查询心率带绑定历史记录
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param hrId formData int false "心率带ID"
+// @Param bt formData string true "开始时间  2020-10-10 00:00:01"
+// @Param et formData string true "结束时间  2020-10-10 23:59:59"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/HrSensorsBindHistory [post]
+func (h *HrSensors) HrSensorsBindHistory() (err error) {
+	//sess := h.getSession()
+	//bt, err := h.getPostFromTime("bt")
+	//if err != nil {
+	//	return
+	//}
+	//et, err := h.getPostFromTime("et")
+	//if err != nil {
+	//	return
+	//}
+	//hrId := h.postInt("hrId")
+	//
+	//rs, err := service.HrSensors{}.HrSensorsBindHistory(sess, hrId, bt, et)
+	//if err != nil {
+	//	return
+	//}
+	//h.json(HrSensorsBindHistoryRs{
+	//	ResponseBase: ResponseBase{},
+	//	Rs:           rs,
+	//})
+	return
+}
+
+// GetHrSensorsPowerPercent godoc
+// @Summary 获取心率带电量
+// @tags HrSensors
+// @Description 获取心率带电量
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "商家ID"
+// @Param hrId formData int false "心率带Id"
+// @Success 200 {object} controller.ResponseBase
+// @Router /HrSensors/GetHrSensorsPowerPercent [post]
+func (h *HrSensors) GetHrSensorsPowerPercent() (err error) {
+	//sess := h.getSession()
+	//shopId := h.postIntNecessary("shopId")
+	//hrId := h.postInt("hrId")
+	////jsonStr := h.postString("jsonStr", false)
+	////dpId := h.postInt("dpId")  // 用来判断是否上课的依据,目前不需要前台传递,根据cfId进行反查。且未确认上课时cf表中dpId=0
+	////oldSn := h.Ctx().PostForm("oldSn")
+	//
+	//logInfo, err := service.HrSensors{}.GetHrSensorsPowerPercent(sess, shopId, hrId)
+	//if err != nil {
+	//	return
+	//}
+	//h.saveOptLogInfo(logInfo)
+	//h.json(newResponseBase())
+	return
+}

+ 60 - 0
controller/test.go

@@ -0,0 +1,60 @@
+package controller
+
+import (
+	"net/http"
+	"video_course/service"
+)
+
+type Test struct {
+	BaseController
+}
+
+// UserAdd godoc
+// @Summary 会员用户添加
+// @tags Test
+// @Description 会员用户添加
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param name formData string true "姓名"
+// @Success 200 {object} controller.ResponseBase
+// @Router /Test/UserAdd [post]
+func (t *Test) UserAdd() (err error) {
+
+	name := t.postString("name", true)
+
+	err = service.Test{}.UserAdd(name)
+	if err != nil {
+		return
+	}
+
+	t.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+type UserList struct {
+	ResponseBase
+	Rs []interface{}
+	//Rs []*gorm.ShopUserSimpleInfo
+}
+
+// UserListQuery godoc
+// @Summary 会员用户查询
+// @tags Test
+// @Description 会员用户查询
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Success 200 {object} controller.UserList
+// @Router /Test/UserListQuery [post]
+func (t *Test) UserListQuery() (err error) {
+
+	rs, err := service.Test{}.UserListQuery()
+	if err != nil {
+		return
+	}
+	rp := UserList{
+		newResponseBase(),
+		rs,
+	}
+	t.Ctx().JSON(http.StatusOK, rp)
+	return
+}

+ 385 - 0
controller/user.go

@@ -0,0 +1,385 @@
+/**
+ * @ File:
+ * @ Date: 2021/1/25 9:54
+ * @ Author: JYQ
+ * @ Description:
+ */
+package controller
+
+type User struct {
+	BaseController
+}
+
+type ShopUserInfo struct {
+	ResponseBase
+	PageCount int64
+	Rs        string
+}
+
+// ShopUserListQuery godoc
+// @Summary 会员用户列表(带分页)
+// @tags User
+// @Description 会员用户列表(带分页)
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param phone formData string false "手机号"
+// @Param name formData string false "姓名"
+// @Param start formData string true "当前条"
+// @Param tableMax formData string true "每页条数"
+// @Success 200 {object} controller.ShopUserInfo
+// @Router /User/ShopUserListQuery [post]
+func (u *User) ShopUserListQuery() (err error) {
+	//sess := u.Ctx().PostForm("Token")
+	//phone := u.Ctx().PostForm("phone")
+	//name := u.Ctx().PostForm("name")
+	//start := u.postIntNecessary("start")
+	//tableMax := u.postIntNecessary("tableMax")
+	//pageIndex := start/tableMax + 1
+	//
+	//rs, pageCount, err := service.User{}.ShopUserListQuery(sess, phone, name, pageIndex, tableMax)
+	//
+	//rp := ShopUserInfo{
+	//	newResponseBase(),
+	//	pageCount,
+	//	rs,
+	//}
+	//u.Ctx().JSON(http.StatusOK, rp)
+
+	return
+}
+
+type ShopUserSimpleInfo struct {
+	ResponseBase
+	Rs string
+	//Rs []*gorm.ShopUserSimpleInfo
+}
+
+// ShopUserSimpleQuery godoc
+// @Summary 本店会员用户基本信息查询
+// @tags User
+// @Description 本店会员用户基本信息查询
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int false "商家ID"
+// @Success 200 {object} controller.ShopUserSimpleInfo
+// @Router /User/ShopUserSimpleQuery [post]
+func (u *User) ShopUserSimpleQuery() (err error) {
+
+	//shopId := u.postInt("shopId")
+	//
+	//sess := u.Ctx().PostForm("Token")
+	//rs, err := service.User{}.ShopUserSimpleQuery(sess, shopId)
+	//
+	//rp := ShopUserSimpleInfo{
+	//	newResponseBase(),
+	//	rs,
+	//}
+	//u.Ctx().JSON(http.StatusOK, rp)
+
+	return
+}
+
+// ShopUserAdd godoc
+// @Summary 会员用户添加
+// @tags User
+// @Description 会员用户添加
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "店铺ID"
+// @Param phone formData string true "登陆用户名也是手机号"
+// @Param name formData string true "姓名"
+// @Param sex formData int true "性别  1:男, 2:女"
+// @Param birthday formData string true "生日"
+// @Param height formData int true "身高"
+// @Param weight formData string true "体重 "
+// @Param staticHr formData int false "静态心率"
+// @Param head formData string false "头像"
+// @Param memo formData string false "备注"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopUserAdd [post]
+func (u *User) ShopUserAdd() (err error) {
+	//usercode := u.postString("phone", true)
+	//name := u.postString("name", true)
+	//phone := u.postString("phone", true)
+	//memo := u.Ctx().PostForm("memo")
+	//
+	//sex := u.postIntNecessary("sex")
+	//birthday := u.getPostFromDate("birthday")
+	//
+	//height := u.postIntNecessary("height")
+	//staticHr := u.postInt("staticHr")
+	//head := u.Ctx().PostForm("head")
+	//w := u.postFloatToInt("weight", true)
+	//
+	//// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
+	//if staticHr == nil {
+	//	age := utils.GetAgeByBirthday(birthday)
+	//	hr := utils.GetStaticHrByAge(age)
+	//
+	//	staticHr = &hr
+	//}
+	//
+	//
+	//sess := u.getSession()
+	//s := service.NewUserService()
+	//logInfo, err := s.ShopUserAdd(sess, usercode, name, phone, memo, sex, birthday, height, w, staticHr, head)
+	//if err != nil {
+	//
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+// ShopUserEdit godoc
+// @Summary 会员用户基本信息修改
+// @tags User
+// @Description 会员用户基本信息修改
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param userId formData int true "用户Id"
+// @Param phone formData string false "手机号"
+// @Param name formData string false "姓名"
+// @Param memo formData string false "备注"
+// @Param birthday formData string true "生日"
+// @Param height formData int true "身高"
+// @Param weight formData string true "体重"
+// @Param sex formData int true "性别  1:男, 2:女"
+// @Param staticHr formData int false "静态心率"
+// @Param head formData string false "头像URL"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopUserEdit [post]
+func (u *User) ShopUserEdit() (err error) {
+	//userId := u.postIntNecessary("userId")
+	//name := u.Ctx().PostForm("name")
+	//phone := u.Ctx().PostForm("phone")
+	//memo := u.Ctx().PostForm("memo")
+	//
+	////ubId := u.postInt("ubId")
+	//height := u.postIntNecessary("height")
+	//w := u.postFloatToInt("weight", true)
+	//sex := u.postIntNecessary("sex")
+	//staticHr := u.postInt("staticHr")
+	//head := u.Ctx().PostForm("head")
+	//birthday := u.getPostFromDate("birthday")
+	//
+	//// 如果未传入静息心率,则通过生日计算年龄后获取此年龄段的平均静息心率
+	//if staticHr == nil {
+	//	age := utils.GetAgeByBirthday(birthday)
+	//	hr := utils.GetStaticHrByAge(age)
+	//	staticHr = &hr
+	//}
+	//
+	//sess := u.getSession()
+	//logInfo, err := service.User{}.ShopUserEdit(sess, userId, name, phone, memo, height, w, sex, staticHr, head, birthday)
+	//if err != nil {
+	//
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+// ShopUserStatusEdit godoc
+// @Summary 会员用户状态修改
+// @tags User
+// @Description 会员用户状态修改
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param userId formData int true "用户ID"
+// @Param status formData int true "状态  1:启用	 8:禁用  9:删除"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopUserStatusEdit [post]
+func (u *User) ShopUserStatusEdit() (err error) {
+	//userId := u.postIntNecessary("userId")
+	//status := u.postIntNecessary("status")
+	//
+	//sess := u.getSession()
+	//logInfo, err := service.User{}.ShopUserStatusEdit(sess, userId, status)
+	//if err != nil {
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+// ShopCoachAdd godoc
+// @Summary 商家教练添加
+// @tags User
+// @Description 商家教练添加
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int true "店铺ID"
+// @Param phone formData string true "登陆用户名也是手机号"
+// @Param name formData string true "姓名"
+// @Param pwd formData string true "密码"
+// @Param sex formData int true "性别  1:男, 2:女"
+// @Param memo formData string false "备注"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopCoachAdd [post]
+func (u *User) ShopCoachAdd() (err error) {
+	//usercode := u.postString("phone", true)
+	//name := u.postString("name", true)
+	//phone := u.postString("phone", true)
+	//pwd := u.postString("pwd", true)
+	//memo := u.Ctx().PostForm("memo")
+	//
+	//sex := u.postIntNecessary("sex")
+
+	//sess := u.getSession()
+	//s := service.NewUserService()
+	//logInfo, err := s.ShopCoachAdd(sess, usercode, name, phone, memo, sex, pwd)
+	//if err != nil {
+	//
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+// ShopCoachEdit godoc
+// @Summary 商家教练基本信息修改
+// @tags User
+// @Description 商家教练基本信息修改
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param ssId formData int true "教练ID"
+// @Param phone formData string false "手机号"
+// @Param pwd formData string false "密码"
+// @Param name formData string false "姓名"
+// @Param memo formData string false "备注"
+// @Param sex formData int true "性别  1:男, 2:女"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopCoachEdit [post]
+func (u *User) ShopCoachEdit() (err error) {
+	//ssId := u.postIntNecessary("ssId")
+	//name := u.Ctx().PostForm("name")
+	//phone := u.Ctx().PostForm("phone")
+	//pwd := u.Ctx().PostForm("pwd")
+	//memo := u.Ctx().PostForm("memo")
+	//
+	//sex := u.postIntNecessary("sex")
+	//
+	//sess := u.getSession()
+	//logInfo, err := service.User{}.ShopCoachEdit(sess, ssId, name, phone, memo, sex, pwd)
+	//if err != nil {
+	//
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+// ShopCoachStatusEdit godoc
+// @Summary 商家教练状态修改
+// @tags User
+// @Description 商家教练状态修改
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param ssId formData int true "教练ID"
+// @Param status formData int true "状态  1:启用	 8:禁用  9:删除"
+// @Success 200 {object} controller.ResponseBase
+// @Router /User/ShopCoachStatusEdit [post]
+func (u *User) ShopCoachStatusEdit() (err error) {
+	//ssId := u.postIntNecessary("ssId")
+	//status := u.postIntNecessary("status")
+	//
+	//sess := u.getSession()
+	//logInfo, err := service.User{}.ShopCoachStatusEdit(sess, ssId, status)
+	//if err != nil {
+	//	return
+	//}
+	//u.saveOptLogInfo(logInfo)
+	//
+	//u.Ctx().JSON(http.StatusOK, newResponseBase())
+	return
+}
+
+type ShopCoachInfo struct {
+	ResponseBase
+	PageCount int64
+	Rs        string
+}
+
+// ShopCoachListQuery godoc
+// @Summary 会员用户列表(带分页)
+// @tags User
+// @Description 会员用户列表(带分页)
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param phone formData string false "手机号"
+// @Param name formData string false "姓名"
+// @Param start formData string true "当前条"
+// @Param tableMax formData string true "每页条数"
+// @Success 200 {object} controller.ShopUserInfo
+// @Router /User/ShopCoachListQuery [post]
+func (u *User) ShopCoachListQuery() (err error) {
+	//sess := u.Ctx().PostForm("Token")
+	//phone := u.Ctx().PostForm("phone")
+	//name := u.Ctx().PostForm("name")
+	//start := u.postIntNecessary("start")
+	//tableMax := u.postIntNecessary("tableMax")
+	//pageIndex := start/tableMax + 1
+	//
+	//rs, pageCount, err := service.User{}.ShopCoachListQuery(sess, phone, name, pageIndex, tableMax)
+	//
+	//rp := ShopCoachInfo{
+	//	newResponseBase(),
+	//	pageCount,
+	//	rs,
+	//}
+	//u.Ctx().JSON(http.StatusOK, rp)
+
+	return
+}
+
+type ShopCoachSimpleInfo struct {
+	ResponseBase
+	Rs string
+	//Rs []*gorm.ShopUserSimpleInfo
+}
+
+// ShopCoachSimpleQuery godoc
+// @Summary 本店会员用户基本信息查询
+// @tags User
+// @Description 本店会员用户基本信息查询
+// @Accept  x-www-form-urlencoded
+// @Produce  json
+// @Param token formData string true "Token"
+// @Param shopId formData int false "商家ID"
+// @Success 200 {object} controller.ShopCoachSimpleInfo
+// @Router /User/ShopCoachSimpleQuery [post]
+func (u *User) ShopCoachSimpleQuery() (err error) {
+
+	//shopId := u.postInt("shopId")
+	//
+	//sess := u.Ctx().PostForm("Token")
+	//rs, err := service.User{}.ShopCoachSimpleQuery(sess, shopId)
+	//
+	//rp := ShopCoachSimpleInfo{
+	//	newResponseBase(),
+	//	rs,
+	//}
+	//u.Ctx().JSON(http.StatusOK, rp)
+
+	return
+}

+ 9 - 0
docker/deploy/Dockerfile

@@ -0,0 +1,9 @@
+FROM golang:1.14
+
+WORKDIR /
+
+COPY hr_sensors .
+RUN chmod 755 hr_sensors
+EXPOSE 19096
+ENV SERVICE_19096_NAME "loallout/hr_sensors"
+CMD ["./hr_sensors"]

+ 9 - 0
docker/video_course/Dockerfile

@@ -0,0 +1,9 @@
+FROM golang:1.14
+
+WORKDIR /
+
+COPY api_app .
+RUN chmod 755 api_app
+EXPOSE 58080
+ENV SERVICE_58080_NAME "loallout/video_course"
+CMD ["./video_course"]

+ 1046 - 0
docs/docs.go

@@ -0,0 +1,1046 @@
+// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+// This file was generated by swaggo/swag
+
+package docs
+
+import (
+	"bytes"
+	"encoding/json"
+	"strings"
+
+	"github.com/alecthomas/template"
+	"github.com/swaggo/swag"
+)
+
+var doc = `{
+    "schemes": {{ marshal .Schemes }},
+    "swagger": "2.0",
+    "info": {
+        "description": "{{.Description}}",
+        "title": "{{.Title}}",
+        "termsOfService": "http://swagger.io/terms/",
+        "contact": {
+            "name": "API Support",
+            "url": "http://www.swagger.io/support",
+            "email": "support@swagger.io"
+        },
+        "license": {
+            "name": "Apache 2.0",
+            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+        },
+        "version": "{{.Version}}"
+    },
+    "host": "{{.Host}}",
+    "basePath": "{{.BasePath}}",
+    "paths": {
+        "/Auth/SignUp": {
+            "post": {
+                "description": "用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Auth"
+                ],
+                "summary": "用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户名",
+                        "name": "userCode",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "password",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "邮箱",
+                        "name": "email",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/HrSensors/AddHrSensors": {
+            "post": {
+                "description": "添加商家公共心率设备",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "HrSensors"
+                ],
+                "summary": "添加商家公共心率设备",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "心率带Sn",
+                        "name": "sn",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "场馆内编号  01 02",
+                        "name": "venueNo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/HrSensors/AddPvtHrSensors": {
+            "post": {
+                "description": "添加会员私有心率设备",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "HrSensors"
+                ],
+                "summary": "添加会员私有心率设备",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "心率带Sn",
+                        "name": "sn",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/Test/UserAdd": {
+            "post": {
+                "description": "会员用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Test"
+                ],
+                "summary": "会员用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/Test/UserListQuery": {
+            "post": {
+                "description": "会员用户查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Test"
+                ],
+                "summary": "会员用户查询",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.UserList"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachAdd": {
+            "post": {
+                "description": "商家教练添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "店铺ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "登陆用户名也是手机号",
+                        "name": "phone",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "pwd",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachEdit": {
+            "post": {
+                "description": "商家教练基本信息修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练基本信息修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "教练ID",
+                        "name": "ssId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "pwd",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachListQuery": {
+            "post": {
+                "description": "会员用户列表(带分页)",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户列表(带分页)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "当前条",
+                        "name": "start",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "每页条数",
+                        "name": "tableMax",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachSimpleQuery": {
+            "post": {
+                "description": "本店会员用户基本信息查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "本店会员用户基本信息查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopCoachSimpleInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachStatusEdit": {
+            "post": {
+                "description": "商家教练状态修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练状态修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "教练ID",
+                        "name": "ssId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态  1:启用\t 8:禁用  9:删除",
+                        "name": "status",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserAdd": {
+            "post": {
+                "description": "会员用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "店铺ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "登陆用户名也是手机号",
+                        "name": "phone",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "生日",
+                        "name": "birthday",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "身高",
+                        "name": "height",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "体重 ",
+                        "name": "weight",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "静态心率",
+                        "name": "staticHr",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像",
+                        "name": "head",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserEdit": {
+            "post": {
+                "description": "会员用户基本信息修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户基本信息修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户Id",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "生日",
+                        "name": "birthday",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "身高",
+                        "name": "height",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "体重",
+                        "name": "weight",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "静态心率",
+                        "name": "staticHr",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像URL",
+                        "name": "head",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserListQuery": {
+            "post": {
+                "description": "会员用户列表(带分页)",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户列表(带分页)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "当前条",
+                        "name": "start",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "每页条数",
+                        "name": "tableMax",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserSimpleQuery": {
+            "post": {
+                "description": "本店会员用户基本信息查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "本店会员用户基本信息查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserSimpleInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserStatusEdit": {
+            "post": {
+                "description": "会员用户状态修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户状态修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态  1:启用\t 8:禁用  9:删除",
+                        "name": "status",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        }
+    },
+    "definitions": {
+        "controller.ResponseBase": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopCoachSimpleInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopUserInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "pageCount": {
+                    "type": "integer"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopUserSimpleInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.UserList": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "array",
+                    "items": {
+                        "type": "object"
+                    }
+                }
+            }
+        }
+    },
+    "securityDefinitions": {
+        "ApiKeyAuth": {
+            "type": "apiKey",
+            "name": "Authorization",
+            "in": "header"
+        },
+        "BasicAuth": {
+            "type": "basic"
+        },
+        "OAuth2AccessCode": {
+            "type": "oauth2",
+            "flow": "accessCode",
+            "authorizationUrl": "https://example.com/oauth/authorize",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information"
+            }
+        },
+        "OAuth2Application": {
+            "type": "oauth2",
+            "flow": "application",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "write": " Grants write access"
+            }
+        },
+        "OAuth2Implicit": {
+            "type": "oauth2",
+            "flow": "implicit",
+            "authorizationUrl": "https://example.com/oauth/authorize",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "write": " Grants write access"
+            }
+        },
+        "OAuth2Password": {
+            "type": "oauth2",
+            "flow": "password",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "read": " Grants read access",
+                "write": " Grants write access"
+            }
+        }
+    }
+}`
+
+type swaggerInfo struct {
+	Version     string
+	Host        string
+	BasePath    string
+	Schemes     []string
+	Title       string
+	Description string
+}
+
+// SwaggerInfo holds exported Swagger Info so clients can modify it
+var SwaggerInfo = swaggerInfo{
+	Version:     "1.0",
+	Host:        "",
+	BasePath:    "/v1",
+	Schemes:     []string{},
+	Title:       "web框架",
+	Description: "web框架 API 文档",
+}
+
+type s struct{}
+
+func (s *s) ReadDoc() string {
+	sInfo := SwaggerInfo
+	sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
+
+	t, err := template.New("swagger_info").Funcs(template.FuncMap{
+		"marshal": func(v interface{}) string {
+			a, _ := json.Marshal(v)
+			return string(a)
+		},
+	}).Parse(doc)
+	if err != nil {
+		return doc
+	}
+
+	var tpl bytes.Buffer
+	if err := t.Execute(&tpl, sInfo); err != nil {
+		return doc
+	}
+
+	return tpl.String()
+}
+
+func init() {
+	swag.Register(swag.Name, &s{})
+}

+ 983 - 0
docs/swagger.json

@@ -0,0 +1,983 @@
+{
+    "swagger": "2.0",
+    "info": {
+        "description": "web框架 API 文档",
+        "title": "web框架",
+        "termsOfService": "http://swagger.io/terms/",
+        "contact": {
+            "name": "API Support",
+            "url": "http://www.swagger.io/support",
+            "email": "support@swagger.io"
+        },
+        "license": {
+            "name": "Apache 2.0",
+            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+        },
+        "version": "1.0"
+    },
+    "basePath": "/v1",
+    "paths": {
+        "/Auth/SignUp": {
+            "post": {
+                "description": "用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Auth"
+                ],
+                "summary": "用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "用户名",
+                        "name": "userCode",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "password",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "邮箱",
+                        "name": "email",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/HrSensors/AddHrSensors": {
+            "post": {
+                "description": "添加商家公共心率设备",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "HrSensors"
+                ],
+                "summary": "添加商家公共心率设备",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "心率带Sn",
+                        "name": "sn",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "场馆内编号  01 02",
+                        "name": "venueNo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/HrSensors/AddPvtHrSensors": {
+            "post": {
+                "description": "添加会员私有心率设备",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "HrSensors"
+                ],
+                "summary": "添加会员私有心率设备",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "心率带Sn",
+                        "name": "sn",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/Test/UserAdd": {
+            "post": {
+                "description": "会员用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Test"
+                ],
+                "summary": "会员用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/Test/UserListQuery": {
+            "post": {
+                "description": "会员用户查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Test"
+                ],
+                "summary": "会员用户查询",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.UserList"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachAdd": {
+            "post": {
+                "description": "商家教练添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "店铺ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "登陆用户名也是手机号",
+                        "name": "phone",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "pwd",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachEdit": {
+            "post": {
+                "description": "商家教练基本信息修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练基本信息修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "教练ID",
+                        "name": "ssId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "密码",
+                        "name": "pwd",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachListQuery": {
+            "post": {
+                "description": "会员用户列表(带分页)",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户列表(带分页)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "当前条",
+                        "name": "start",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "每页条数",
+                        "name": "tableMax",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachSimpleQuery": {
+            "post": {
+                "description": "本店会员用户基本信息查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "本店会员用户基本信息查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopCoachSimpleInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopCoachStatusEdit": {
+            "post": {
+                "description": "商家教练状态修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "商家教练状态修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "教练ID",
+                        "name": "ssId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态  1:启用\t 8:禁用  9:删除",
+                        "name": "status",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserAdd": {
+            "post": {
+                "description": "会员用户添加",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户添加",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "店铺ID",
+                        "name": "shopId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "登陆用户名也是手机号",
+                        "name": "phone",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "生日",
+                        "name": "birthday",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "身高",
+                        "name": "height",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "体重 ",
+                        "name": "weight",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "静态心率",
+                        "name": "staticHr",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像",
+                        "name": "head",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserEdit": {
+            "post": {
+                "description": "会员用户基本信息修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户基本信息修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户Id",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "备注",
+                        "name": "memo",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "生日",
+                        "name": "birthday",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "身高",
+                        "name": "height",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "体重",
+                        "name": "weight",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "性别  1:男, 2:女",
+                        "name": "sex",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "静态心率",
+                        "name": "staticHr",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像URL",
+                        "name": "head",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserListQuery": {
+            "post": {
+                "description": "会员用户列表(带分页)",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户列表(带分页)",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "手机号",
+                        "name": "phone",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "姓名",
+                        "name": "name",
+                        "in": "formData"
+                    },
+                    {
+                        "type": "string",
+                        "description": "当前条",
+                        "name": "start",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "每页条数",
+                        "name": "tableMax",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserSimpleQuery": {
+            "post": {
+                "description": "本店会员用户基本信息查询",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "本店会员用户基本信息查询",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商家ID",
+                        "name": "shopId",
+                        "in": "formData"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ShopUserSimpleInfo"
+                        }
+                    }
+                }
+            }
+        },
+        "/User/ShopUserStatusEdit": {
+            "post": {
+                "description": "会员用户状态修改",
+                "consumes": [
+                    "application/x-www-form-urlencoded"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "User"
+                ],
+                "summary": "会员用户状态修改",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "Token",
+                        "name": "token",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userId",
+                        "in": "formData",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "状态  1:启用\t 8:禁用  9:删除",
+                        "name": "status",
+                        "in": "formData",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/controller.ResponseBase"
+                        }
+                    }
+                }
+            }
+        }
+    },
+    "definitions": {
+        "controller.ResponseBase": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopCoachSimpleInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopUserInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "pageCount": {
+                    "type": "integer"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.ShopUserSimpleInfo": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "string"
+                }
+            }
+        },
+        "controller.UserList": {
+            "type": "object",
+            "properties": {
+                "code": {
+                    "type": "integer"
+                },
+                "memo": {
+                    "type": "string"
+                },
+                "rs": {
+                    "type": "array",
+                    "items": {
+                        "type": "object"
+                    }
+                }
+            }
+        }
+    },
+    "securityDefinitions": {
+        "ApiKeyAuth": {
+            "type": "apiKey",
+            "name": "Authorization",
+            "in": "header"
+        },
+        "BasicAuth": {
+            "type": "basic"
+        },
+        "OAuth2AccessCode": {
+            "type": "oauth2",
+            "flow": "accessCode",
+            "authorizationUrl": "https://example.com/oauth/authorize",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information"
+            }
+        },
+        "OAuth2Application": {
+            "type": "oauth2",
+            "flow": "application",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "write": " Grants write access"
+            }
+        },
+        "OAuth2Implicit": {
+            "type": "oauth2",
+            "flow": "implicit",
+            "authorizationUrl": "https://example.com/oauth/authorize",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "write": " Grants write access"
+            }
+        },
+        "OAuth2Password": {
+            "type": "oauth2",
+            "flow": "password",
+            "tokenUrl": "https://example.com/oauth/token",
+            "scopes": {
+                "admin": " Grants read and write access to administrative information",
+                "read": " Grants read access",
+                "write": " Grants write access"
+            }
+        }
+    }
+}

+ 665 - 0
docs/swagger.yaml

@@ -0,0 +1,665 @@
+basePath: /v1
+definitions:
+  controller.ResponseBase:
+    properties:
+      code:
+        type: integer
+      memo:
+        type: string
+    type: object
+  controller.ShopCoachSimpleInfo:
+    properties:
+      code:
+        type: integer
+      memo:
+        type: string
+      rs:
+        type: string
+    type: object
+  controller.ShopUserInfo:
+    properties:
+      code:
+        type: integer
+      memo:
+        type: string
+      pageCount:
+        type: integer
+      rs:
+        type: string
+    type: object
+  controller.ShopUserSimpleInfo:
+    properties:
+      code:
+        type: integer
+      memo:
+        type: string
+      rs:
+        type: string
+    type: object
+  controller.UserList:
+    properties:
+      code:
+        type: integer
+      memo:
+        type: string
+      rs:
+        items:
+          type: object
+        type: array
+    type: object
+info:
+  contact:
+    email: support@swagger.io
+    name: API Support
+    url: http://www.swagger.io/support
+  description: web框架 API 文档
+  license:
+    name: Apache 2.0
+    url: http://www.apache.org/licenses/LICENSE-2.0.html
+  termsOfService: http://swagger.io/terms/
+  title: web框架
+  version: "1.0"
+paths:
+  /Auth/SignUp:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 用户添加
+      parameters:
+      - description: 用户名
+        in: formData
+        name: userCode
+        required: true
+        type: string
+      - description: 密码
+        in: formData
+        name: password
+        required: true
+        type: string
+      - description: 邮箱
+        in: formData
+        name: email
+        type: string
+      - description: 手机号
+        in: formData
+        name: phone
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 用户添加
+      tags:
+      - Auth
+  /HrSensors/AddHrSensors:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 添加商家公共心率设备
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 商家ID
+        in: formData
+        name: shopId
+        required: true
+        type: integer
+      - description: 心率带Sn
+        in: formData
+        name: sn
+        required: true
+        type: integer
+      - description: 场馆内编号  01 02
+        in: formData
+        name: venueNo
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 添加商家公共心率设备
+      tags:
+      - HrSensors
+  /HrSensors/AddPvtHrSensors:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 添加会员私有心率设备
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 商家ID
+        in: formData
+        name: shopId
+        required: true
+        type: integer
+      - description: 心率带Sn
+        in: formData
+        name: sn
+        required: true
+        type: integer
+      - description: 用户ID
+        in: formData
+        name: userId
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 添加会员私有心率设备
+      tags:
+      - HrSensors
+  /Test/UserAdd:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户添加
+      parameters:
+      - description: 姓名
+        in: formData
+        name: name
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 会员用户添加
+      tags:
+      - Test
+  /Test/UserListQuery:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户查询
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.UserList'
+      summary: 会员用户查询
+      tags:
+      - Test
+  /User/ShopCoachAdd:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 商家教练添加
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 店铺ID
+        in: formData
+        name: shopId
+        required: true
+        type: integer
+      - description: 登陆用户名也是手机号
+        in: formData
+        name: phone
+        required: true
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        required: true
+        type: string
+      - description: 密码
+        in: formData
+        name: pwd
+        required: true
+        type: string
+      - description: 性别  1:男, 2:女
+        in: formData
+        name: sex
+        required: true
+        type: integer
+      - description: 备注
+        in: formData
+        name: memo
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 商家教练添加
+      tags:
+      - User
+  /User/ShopCoachEdit:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 商家教练基本信息修改
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 教练ID
+        in: formData
+        name: ssId
+        required: true
+        type: integer
+      - description: 手机号
+        in: formData
+        name: phone
+        type: string
+      - description: 密码
+        in: formData
+        name: pwd
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        type: string
+      - description: 备注
+        in: formData
+        name: memo
+        type: string
+      - description: 性别  1:男, 2:女
+        in: formData
+        name: sex
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 商家教练基本信息修改
+      tags:
+      - User
+  /User/ShopCoachListQuery:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户列表(带分页)
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 手机号
+        in: formData
+        name: phone
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        type: string
+      - description: 当前条
+        in: formData
+        name: start
+        required: true
+        type: string
+      - description: 每页条数
+        in: formData
+        name: tableMax
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ShopUserInfo'
+      summary: 会员用户列表(带分页)
+      tags:
+      - User
+  /User/ShopCoachSimpleQuery:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 本店会员用户基本信息查询
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 商家ID
+        in: formData
+        name: shopId
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ShopCoachSimpleInfo'
+      summary: 本店会员用户基本信息查询
+      tags:
+      - User
+  /User/ShopCoachStatusEdit:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 商家教练状态修改
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 教练ID
+        in: formData
+        name: ssId
+        required: true
+        type: integer
+      - description: "状态  1:启用\t 8:禁用  9:删除"
+        in: formData
+        name: status
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 商家教练状态修改
+      tags:
+      - User
+  /User/ShopUserAdd:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户添加
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 店铺ID
+        in: formData
+        name: shopId
+        required: true
+        type: integer
+      - description: 登陆用户名也是手机号
+        in: formData
+        name: phone
+        required: true
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        required: true
+        type: string
+      - description: 性别  1:男, 2:女
+        in: formData
+        name: sex
+        required: true
+        type: integer
+      - description: 生日
+        in: formData
+        name: birthday
+        required: true
+        type: string
+      - description: 身高
+        in: formData
+        name: height
+        required: true
+        type: integer
+      - description: '体重 '
+        in: formData
+        name: weight
+        required: true
+        type: string
+      - description: 静态心率
+        in: formData
+        name: staticHr
+        type: integer
+      - description: 头像
+        in: formData
+        name: head
+        type: string
+      - description: 备注
+        in: formData
+        name: memo
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 会员用户添加
+      tags:
+      - User
+  /User/ShopUserEdit:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户基本信息修改
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 用户Id
+        in: formData
+        name: userId
+        required: true
+        type: integer
+      - description: 手机号
+        in: formData
+        name: phone
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        type: string
+      - description: 备注
+        in: formData
+        name: memo
+        type: string
+      - description: 生日
+        in: formData
+        name: birthday
+        required: true
+        type: string
+      - description: 身高
+        in: formData
+        name: height
+        required: true
+        type: integer
+      - description: 体重
+        in: formData
+        name: weight
+        required: true
+        type: string
+      - description: 性别  1:男, 2:女
+        in: formData
+        name: sex
+        required: true
+        type: integer
+      - description: 静态心率
+        in: formData
+        name: staticHr
+        type: integer
+      - description: 头像URL
+        in: formData
+        name: head
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 会员用户基本信息修改
+      tags:
+      - User
+  /User/ShopUserListQuery:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户列表(带分页)
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 手机号
+        in: formData
+        name: phone
+        type: string
+      - description: 姓名
+        in: formData
+        name: name
+        type: string
+      - description: 当前条
+        in: formData
+        name: start
+        required: true
+        type: string
+      - description: 每页条数
+        in: formData
+        name: tableMax
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ShopUserInfo'
+      summary: 会员用户列表(带分页)
+      tags:
+      - User
+  /User/ShopUserSimpleQuery:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 本店会员用户基本信息查询
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 商家ID
+        in: formData
+        name: shopId
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ShopUserSimpleInfo'
+      summary: 本店会员用户基本信息查询
+      tags:
+      - User
+  /User/ShopUserStatusEdit:
+    post:
+      consumes:
+      - application/x-www-form-urlencoded
+      description: 会员用户状态修改
+      parameters:
+      - description: Token
+        in: formData
+        name: token
+        required: true
+        type: string
+      - description: 用户ID
+        in: formData
+        name: userId
+        required: true
+        type: integer
+      - description: "状态  1:启用\t 8:禁用  9:删除"
+        in: formData
+        name: status
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/controller.ResponseBase'
+      summary: 会员用户状态修改
+      tags:
+      - User
+securityDefinitions:
+  ApiKeyAuth:
+    in: header
+    name: Authorization
+    type: apiKey
+  BasicAuth:
+    type: basic
+  OAuth2AccessCode:
+    authorizationUrl: https://example.com/oauth/authorize
+    flow: accessCode
+    scopes:
+      admin: ' Grants read and write access to administrative information'
+    tokenUrl: https://example.com/oauth/token
+    type: oauth2
+  OAuth2Application:
+    flow: application
+    scopes:
+      admin: ' Grants read and write access to administrative information'
+      write: ' Grants write access'
+    tokenUrl: https://example.com/oauth/token
+    type: oauth2
+  OAuth2Implicit:
+    authorizationUrl: https://example.com/oauth/authorize
+    flow: implicit
+    scopes:
+      admin: ' Grants read and write access to administrative information'
+      write: ' Grants write access'
+    type: oauth2
+  OAuth2Password:
+    flow: password
+    scopes:
+      admin: ' Grants read and write access to administrative information'
+      read: ' Grants read access'
+      write: ' Grants write access'
+    tokenUrl: https://example.com/oauth/token
+    type: oauth2
+swagger: "2.0"

+ 72 - 0
errors/error.go

@@ -0,0 +1,72 @@
+/*
+@Time : 2019-06-26 16:21
+@Author : zr
+@File : error
+@Software: GoLand
+*/
+package errors
+
+import (
+	"fmt"
+	"gitee.com/zr233/bsf/errors"
+)
+
+type ErrorCode int
+
+const (
+	CodeUNKNOWN                       = ErrorCode(errors.ErrorCode_Unknown)
+	CodeSUCCESS             ErrorCode = 0
+	CodeBusy                ErrorCode = 1
+	CodeServiceNotAvailable ErrorCode = 2
+	CodeKeyNotExist         ErrorCode = 3
+	CodePermissionDenied    ErrorCode = 1004
+	CodePasswordErr         ErrorCode = 1006
+	CodeTokenErr            ErrorCode = 1010
+	CodeNoRecord            ErrorCode = 1014
+	BirthdayErr             ErrorCode = 1036
+	StaticHrErr             ErrorCode = 1037
+	CodeParamErr            ErrorCode = 5000
+	CodeDATABASE            ErrorCode = 9000
+	CodeREDIS               ErrorCode = 10000
+	CodeParam                         = ErrorCode(errors.CodeParam)
+)
+
+var (
+	ErrStaticHr = NewServiceErr(StaticHrErr, "会员年龄太小,请重新输入用户生日。")
+	ErrBirthday = NewServiceErr(BirthdayErr, "用户生日不得大于当前年份,请重新输入")
+)
+
+func (e ErrorCode) ShowMsg() string {
+	switch e {
+	case CodeSUCCESS:
+		return "执行成功"
+	case CodePasswordErr:
+		return "密码错误"
+	case CodeTokenErr:
+		return "登录失效"
+	default:
+		return fmt.Sprintf("系统错误[%d],请联系管理员", e)
+	}
+}
+
+func NewParamErr(err error) error {
+	return errors.NewParamErr(err)
+}
+
+func FromError(err error) (stdErr *errors.StandardError) {
+	return errors.NewFromError(err, errors.ErrorCode(CodeUNKNOWN))
+}
+
+func NewFromError(err error, code ErrorCode) (stdErr *errors.StandardError) {
+	return errors.NewFromError(err, errors.ErrorCode(code))
+}
+
+func FromParamErr(paramName string, err error) (stdErr *errors.StandardError) {
+	err = fmt.Errorf("参数名: %s, %w", paramName, err)
+	return NewFromError(err, CodeParam)
+}
+
+func NewServiceErr(code ErrorCode, msg string) (stdErr *errors.StandardError) {
+	err := fmt.Errorf(msg)
+	return NewFromError(err, code)
+}

+ 40 - 0
global/global.go

@@ -0,0 +1,40 @@
+package global
+
+import (
+	"github.com/ZR233/gconfig/v2"
+	"github.com/hashicorp/consul/api"
+	"github.com/sirupsen/logrus"
+	"github.com/spf13/viper"
+	"path"
+)
+
+const (
+	envName_CONSUL_ADDR = "CONSUL_ADDR"
+)
+
+func Init() (db gconfig.DB) {
+	err := viper.BindEnv(envName_CONSUL_ADDR)
+	if err != nil {
+		panic(err)
+	}
+
+	var consulCfg *api.Config
+	consulAddr := viper.GetString(envName_CONSUL_ADDR)
+	if consulAddr != "" {
+		ConsulAddr = consulAddr
+
+		consulCfg = &api.Config{
+			Address: ConsulAddr,
+		}
+		logrus.Info("consul addr: %s", ConsulAddr)
+	}
+
+	Config = gconfig.NewConfig(path.Join(ProjectName, AppName)).UseConsul(consulCfg)
+	err = Config.Unmarshal(&Project)
+	if err != nil {
+		panic(err)
+	}
+	logrus.Info("config finish")
+
+	return
+}

+ 21 - 0
global/init.go

@@ -0,0 +1,21 @@
+package global
+
+import "github.com/ZR233/gconfig/v2"
+
+const (
+	ProjectName = "loallout"
+	AppName     = "video_course"
+	Port        = 58080
+)
+
+var (
+	ConsulAddr string
+	Config     *gconfig.Config
+
+	Project struct {
+		DBName   string
+		LogLevel string
+		Host     string
+		Debug    bool
+	}
+)

+ 22 - 0
go.mod

@@ -0,0 +1,22 @@
+module video_course
+
+go 1.15
+
+require (
+	gitee.com/zr233/bsf v1.2.3
+	github.com/ZR233/gconfig/v2 v2.0.4
+	github.com/ZR233/glog v0.0.7
+	github.com/ZR233/goutils v1.4.12
+	github.com/ZR233/session v1.1.5
+	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
+	github.com/gin-gonic/gin v1.6.3
+	github.com/go-redis/redis v6.15.9+incompatible // indirect
+	github.com/go-redis/redis/v7 v7.2.0
+	github.com/hashicorp/consul/api v1.8.1
+	github.com/jackc/pgconn v1.8.0
+	github.com/jackc/pgx/v4 v4.10.1
+	github.com/sirupsen/logrus v1.7.0
+	github.com/spf13/viper v1.7.1
+	github.com/swaggo/gin-swagger v1.3.0
+	github.com/swaggo/swag v1.7.0
+)

+ 39 - 0
lib/session/session.go

@@ -0,0 +1,39 @@
+/*
+@Time : 2019-08-21 11:19
+@Author : zr
+*/
+package session
+
+import (
+	"github.com/ZR233/session"
+	"github.com/go-redis/redis/v7"
+	"sync"
+	"video_course/global"
+)
+
+var sessionManager *session.Manager
+var once sync.Once
+
+func newSM() {
+
+	cfg, err := global.Config.GetRedis()
+	if err != nil {
+		panic(err)
+	}
+
+	opt := &redis.UniversalOptions{
+		Addrs:      cfg.Addrs,
+		Password:   cfg.Password,
+		MasterName: cfg.Mastername,
+	}
+
+	db := session.NewRedisAdapter(opt, global.ProjectName+":"+global.AppName)
+
+	sessionManager = session.NewManager(db)
+}
+
+func GetSessionManager() *session.Manager {
+	once.Do(newSM)
+
+	return sessionManager
+}

+ 32 - 0
logger/init.go

@@ -0,0 +1,32 @@
+package logger
+
+import (
+	"github.com/ZR233/glog"
+	"github.com/sirupsen/logrus"
+	"video_course/global"
+)
+
+var processor *glog.Processor
+
+func Init() {
+	processor = glog.NewProcessor(global.ProjectName, global.AppName)
+
+}
+func SetOnlineWriters() {
+	level, err := logrus.ParseLevel(global.Project.LogLevel)
+	if err != nil {
+		panic(err)
+	}
+	logrus.SetLevel(level)
+
+	writer := glog.NewWriterConfigLogstash()
+	zk, err := global.Config.GetZookeeper()
+	if err != nil {
+		panic(err)
+	}
+
+	writer.ZkHosts = zk.Hosts
+	processor.AddWriters(writer)
+
+	return
+}

+ 109 - 0
main.go

@@ -0,0 +1,109 @@
+package main
+
+import (
+	"flag"
+	"fmt"
+	"gitee.com/zr233/bsf"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	ginSwagger "github.com/swaggo/gin-swagger"
+	"github.com/swaggo/gin-swagger/swaggerFiles"
+	"os"
+	"video_course/controller"
+	"video_course/docs"
+	"video_course/global"
+	"video_course/logger"
+	"video_course/middleware"
+	"video_course/repository/postgres"
+)
+
+var _VERSION_ = "unknown"
+
+func flagInit() {
+
+	flag.BoolVar(&global.Project.Debug, "d", global.Project.Debug, "是否debug")
+	flag.StringVar(&global.Project.Host, "s", global.Project.Host, "swag host")
+	flag.BoolVar(&help, "h", false, "this help")
+
+	flag.Parse()
+	if help {
+		flag.Usage()
+		os.Exit(0)
+	}
+}
+
+// @title web框架
+// @version 1.0
+// @description web框架 API 文档
+// @termsOfService http://swagger.io/terms/
+
+// @contact.name API Support
+// @contact.url http://www.swagger.io/support
+// @contact.email support@swagger.io
+
+// @license.name Apache 2.0
+// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
+
+// @BasePath /v1
+
+// @securityDefinitions.basic BasicAuth
+
+// @securityDefinitions.apikey ApiKeyAuth
+// @in header
+// @name Authorization
+
+// @securitydefinitions.oauth2.application OAuth2Application
+// @tokenUrl https://example.com/oauth/token
+// @scope.write Grants write access
+// @scope.admin Grants read and write access to administrative information
+
+// @securitydefinitions.oauth2.implicit OAuth2Implicit
+// @authorizationurl https://example.com/oauth/authorize
+// @scope.write Grants write access
+// @scope.admin Grants read and write access to administrative information
+
+// @securitydefinitions.oauth2.password OAuth2Password
+// @tokenUrl https://example.com/oauth/token
+// @scope.read Grants read access
+// @scope.write Grants write access
+// @scope.admin Grants read and write access to administrative information
+
+// @securitydefinitions.oauth2.accessCode OAuth2AccessCode
+// @tokenUrl https://example.com/oauth/token
+// @authorizationurl https://example.com/oauth/authorize
+// @scope.admin Grants read and write access to administrative information
+func main() {
+	logger.Init()
+	global.Init()
+	logger.SetOnlineWriters()
+	flagInit()
+	postgres.Init()
+
+	r := bsf.NewDefaultEngine()
+	gin.SetMode(gin.ReleaseMode)
+	r.Use(
+		middleware.ErrorResponse(),
+		middleware.Logger(),
+		middleware.Session(),
+	)
+	r.AutoRegisterController("/v1", &controller.Auth{})
+	r.AutoRegisterController("/v1", &controller.Test{})
+	//debug模式下启用swag文档
+	if global.Project.Debug {
+		gin.SetMode(gin.DebugMode)
+		//设置swagger文档主机
+		docs.SwaggerInfo.Host = fmt.Sprintf("%s:%d", global.Project.Host, global.Port)
+		// 注册swagger文档
+		// 查看地址为 /v1/docs/index.html     /v1/SignIn/docs/doc.json
+		r.GET("/v1/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
+	}
+
+	logrus.Infof("Version:[%s]\n", _VERSION_)
+
+	_ = r.Run(fmt.Sprintf(":%d", global.Port))
+
+}
+
+var (
+	help bool
+)

+ 20 - 0
middleware/base.go

@@ -0,0 +1,20 @@
+/*
+@Time : 2019-07-15 14:32
+@Author : zr
+*/
+package middleware
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+type base struct {
+	c *gin.Context
+}
+
+func newBase(c *gin.Context) base {
+	b := base{
+		c,
+	}
+	return b
+}

+ 75 - 0
middleware/logger.go

@@ -0,0 +1,75 @@
+/*
+@Time : 2019-06-28 17:48
+@Author : zr
+@File : logger
+@Software: GoLand
+*/
+package middleware
+
+import (
+	"encoding/json"
+	"github.com/ZR233/goutils/stackx"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"time"
+	"video_course/errors"
+	"video_course/model"
+)
+
+func Logger() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		beginTime := time.Now()
+
+		defer func() {
+			code := 0
+			logMsg := "success"
+
+			if p := recover(); p != nil {
+				err := p.(error)
+
+				stdErr := errors.FromError(err)
+				logMsg = stdErr.Error() + "\n" + string(stackx.Stack(0))
+
+				code = int(stdErr.Code)
+				_ = c.Error(err)
+			}
+
+			userid := 0
+			src := ""
+
+			endTime := time.Now()
+
+			if i, exists := c.Get("session"); exists {
+				s, ok := i.(*model.Session)
+				if ok {
+					if s != nil {
+						userid = s.UserId
+						src = s.Channel
+					}
+				}
+			}
+
+			postForm := c.Request.PostForm
+			params, _ := json.Marshal(postForm)
+			url := c.Request.URL.Path
+
+			event := logrus.WithFields(logrus.Fields{
+				"execTime":  endTime.Sub(beginTime).Milliseconds(),
+				"trace":     url,
+				"optUserId": userid,
+				"src":       src,
+				"code":      code,
+				"params":    string(params),
+			})
+			event.Time = beginTime
+			if len(c.Errors) > 0 {
+				event.Warn(logMsg)
+			} else {
+				event.Info(logMsg)
+			}
+
+		}()
+
+		c.Next()
+	}
+}

+ 48 - 0
middleware/response.go

@@ -0,0 +1,48 @@
+/*
+@Time : 2019-11-07 14:55
+@Author : zr
+*/
+package middleware
+
+import (
+	"github.com/gin-gonic/gin"
+	"net/http"
+	"video_course/errors"
+	"video_course/global"
+)
+
+type ResponseBase struct {
+	Code int
+	Memo string
+}
+
+func ErrorResponse() gin.HandlerFunc {
+	return func(c *gin.Context) {
+
+		defer func() {
+			if len(c.Errors) > 0 {
+				stdErr := errors.FromError(c.Errors[0].Err)
+				var resp interface{}
+
+				resp1 := &ResponseBase{
+					Code: int(stdErr.Code),
+					Memo: errors.ErrorCode(stdErr.Code).ShowMsg(),
+				}
+				resp = resp1
+				if global.Project.Debug {
+					var resp2 struct {
+						ResponseBase
+						DebugMsg string
+					}
+					resp2.ResponseBase = *resp1
+					resp2.DebugMsg = stdErr.Error()
+					resp = resp2
+				}
+				c.JSON(http.StatusOK, resp)
+			}
+
+		}()
+
+		c.Next()
+	}
+}

+ 36 - 0
middleware/session.go

@@ -0,0 +1,36 @@
+/*
+@Time : 2019-08-22 14:33
+@Author : zr
+*/
+package middleware
+
+import (
+	"github.com/ZR233/session/serr"
+	"github.com/gin-gonic/gin"
+	"video_course/lib/session"
+	"video_course/model"
+)
+
+func Session() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		token := c.PostForm("token")
+		if token == "" {
+			token = c.Param("token")
+		}
+
+		if token != "" {
+			sm := session.GetSessionManager()
+			sess, err := sm.FindByToken(token)
+			if err != nil {
+				if err != serr.TokenNotFound {
+					panic(err)
+				}
+			} else {
+				sess_ := model.NewSession(sess)
+				c.Set("session", sess_)
+			}
+		}
+
+		c.Next()
+	}
+}

+ 32 - 0
model/session.go

@@ -0,0 +1,32 @@
+/*
+@Time : 2019-07-12 16:24
+@Author : zr
+*/
+package model
+
+import (
+	model2 "github.com/ZR233/session/model"
+	"strconv"
+	"time"
+)
+
+type Session struct {
+	Token    string
+	UserId   int
+	Channel  string
+	ExpireAt time.Time
+}
+
+func NewSession(s *model2.Session) *Session {
+	userId, err := strconv.Atoi(s.UserId)
+	if err != nil {
+		panic(err)
+	}
+	s_ := &Session{
+		s.Token,
+		userId,
+		s.Channel,
+		s.ExpireAt,
+	}
+	return s_
+}

+ 9 - 0
model/user.go

@@ -0,0 +1,9 @@
+package model
+
+import "time"
+
+type User struct {
+	Id       int
+	Name     string
+	CreateAt time.Time
+}

+ 73 - 0
repository/postgres/init.go

@@ -0,0 +1,73 @@
+package postgres
+
+import (
+	"context"
+	e "errors"
+	"fmt"
+	"github.com/jackc/pgconn"
+	"github.com/jackc/pgx/v4"
+	"github.com/jackc/pgx/v4/pgxpool"
+	"github.com/sirupsen/logrus"
+	"video_course/errors"
+	"video_course/global"
+)
+
+var writeDB *pgxpool.Pool
+
+func Init() {
+	logrus.Info("初始化数据库")
+
+	dbCfg, err := global.Config.GetPostgreSQL()
+	if err != nil {
+		panic(err)
+	}
+	writeCfg := dbCfg.Write
+
+	connStr := fmt.Sprintf("host=%s port=%d user=%s dbname=%s password=%s sslmode=disable TimeZone=Asia/Shanghai",
+		writeCfg.Host, writeCfg.Port, writeCfg.User, global.Project.DBName, writeCfg.Password)
+	writeDB, err = pgxpool.Connect(context.Background(), connStr)
+	if err != nil {
+		logrus.Panicf("连接数据库失败:%v\n", err)
+		panic(err)
+	}
+}
+
+type base struct {
+	c context.Context
+}
+
+func (b base) ctx() context.Context {
+	if b.c == nil {
+		b.c = context.Background()
+	}
+	return b.c
+}
+
+func (b base) writeDB() *pgxpool.Pool {
+	return writeDB
+}
+
+func panicError(err error) {
+	if err != nil {
+		err = errors.NewFromError(err, errors.CodeDATABASE)
+		panic(err)
+	}
+}
+func panicExec(tag pgconn.CommandTag, err error) {
+	if err != nil {
+		if e.Is(err, pgx.ErrNoRows) {
+			err = errors.NewFromError(err, errors.CodeNoRecord)
+		} else {
+			err = errors.NewFromError(err, errors.CodeDATABASE)
+		}
+		panic(err)
+	}
+}
+func isRecordNotFound(err error) bool {
+	if e.Is(err, pgx.ErrNoRows) {
+		return true
+	} else {
+		panicError(err)
+		return false
+	}
+}

+ 17 - 0
repository/postgres/init_test.go

@@ -0,0 +1,17 @@
+package postgres
+
+import (
+	"testing"
+	"video_course/global"
+	"video_course/logger"
+)
+
+func testInit() {
+	logger.Init()
+	global.Init()
+	Init()
+}
+
+func TestInit(t *testing.T) {
+	testInit()
+}

+ 92 - 0
repository/postgres/test.go

@@ -0,0 +1,92 @@
+package postgres
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/jackc/pgx/v4"
+)
+
+type Test struct {
+	base
+}
+
+func (t Test) UserAdd(name string) {
+	stCode := -999
+	sql := `select fn_user_add2($1,$2);`
+	_, err := t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{name, stCode}, []interface{}{&stCode}, func(pgx.QueryFuncRow) error {
+		fmt.Printf("%v", stCode)
+		return nil
+	})
+	if err != nil {
+		fmt.Printf("QueryFunc error: %v", err)
+	}
+
+}
+
+type UserListInfo struct {
+	Id   int
+	Name string
+}
+
+func (t Test) UserList1() (rs []interface{}, err error) {
+	//var id int32
+	//var name string
+	//var ct time.Time
+	var one interface{}
+	var rs_ struct {
+		Rs []interface{}
+	}
+	//var a interface{}
+
+	sql := `select id,name from func_userlist_query();`
+	_, err = t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{}, []interface{}{&one}, func(rows pgx.QueryFuncRow) error {
+
+		rs_.Rs = append(rs_.Rs, one)
+		return nil
+	})
+	if err != nil {
+		fmt.Printf("QueryFunc error: %v", err)
+	}
+
+	data, err := json.Marshal(rs_)
+	println(string(data))
+	return
+}
+func (t Test) UserList2() (rs []interface{}, err error) {
+	//var id int32
+	//var name string
+	//var ct time.Time
+	usone := UserListInfo{}
+
+	sql := `select id,name from func_userlist_query();`
+	_, err = t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{}, []interface{}{&usone.Id, &usone.Name}, func(pgx.QueryFuncRow) error {
+
+		fmt.Printf("%v\n", usone)
+		rs = append(rs, usone)
+
+		return nil
+	})
+	if err != nil {
+		fmt.Printf("QueryFunc error: %v", err)
+	}
+	return
+}
+func (t Test) UserList() (rs []interface{}, err error) {
+	var id int
+	var name string
+	//var ct time.Time
+	//usone := UserListInfo{}
+
+	sql := `select id,name from func_userlist_query();`
+	_, err = t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{}, []interface{}{&id, &name}, func(pgx.QueryFuncRow) error {
+		usone := UserListInfo{id, name}
+		fmt.Printf("%v\n", usone)
+		rs = append(rs, usone)
+
+		return nil
+	})
+	if err != nil {
+		fmt.Printf("QueryFunc error: %v", err)
+	}
+	return
+}

+ 51 - 0
repository/postgres/user.go

@@ -0,0 +1,51 @@
+package postgres
+
+import (
+	"video_course/model"
+)
+
+type User struct {
+	base
+}
+
+func (u User) Create(user *model.User) {
+
+	sql := `insert into t_user (id, name, create_at) VALUES 
+($1, $2, $3)`
+
+	panicExec(u.writeDB().Exec(u.ctx(), sql,
+		user.Id, user.Name, user.CreateAt))
+}
+
+func (u User) ById(userId int) (user *model.User) {
+	user = &model.User{}
+
+	sql := `select id, name, create_at from t_user 
+    where id = $1 `
+
+	panicError(
+		u.writeDB().
+			QueryRow(u.ctx(), sql, userId).
+			Scan(&user.Id, &user.Name, &user.CreateAt))
+
+	return
+}
+
+func (u User) All() (users []*model.User) {
+
+	sql := `select id, name, create_at from t_user`
+
+	rows, err := u.writeDB().
+		Query(u.ctx(), sql)
+	panicError(err)
+	defer rows.Close()
+
+	for rows.Next() {
+		user := &model.User{}
+		err = rows.Scan(&user.Id, &user.Name, &user.CreateAt)
+		panicError(err)
+		users = append(users, user)
+	}
+
+	return
+}

+ 30 - 0
repository/postgres/user_test.go

@@ -0,0 +1,30 @@
+package postgres
+
+import (
+	"testing"
+	"time"
+	"video_course/model"
+)
+
+func TestUser_Create(t *testing.T) {
+	testInit()
+
+	User{}.Create(&model.User{
+		Id: 2, Name: "test", CreateAt: time.Now(),
+	})
+}
+
+func TestUser_ById(t *testing.T) {
+	testInit()
+
+	u := User{}.ById(1)
+	u = User{}.ById(2)
+
+	println(u)
+}
+
+func TestUser_All(t *testing.T) {
+	testInit()
+	l := User{}.All()
+	println(len(l))
+}

+ 25 - 0
service/base.go

@@ -0,0 +1,25 @@
+/**
+ * @ File:
+ * @ Date: 2021/1/25 10:06
+ * @ Author: JYQ
+ * @ Description:
+ */
+package service
+
+import "strings"
+
+type base struct {
+	restFulApiBase []string
+	restFulApi     []string
+	userId         int
+}
+
+func newBase(ApiBaseUrl string) (b *base) {
+	b = &base{}
+	if ApiBaseUrl == "" {
+		return
+	}
+
+	b.restFulApiBase = strings.Split(ApiBaseUrl, "/")
+	return
+}

+ 20 - 0
service/test.go

@@ -0,0 +1,20 @@
+package service
+
+import (
+	db "video_course/repository/postgres"
+)
+
+type Test struct {
+	base
+}
+
+func (t Test) UserAdd(name string) (err error) {
+
+	db.Test{}.UserAdd(name)
+	return
+}
+func (t Test) UserListQuery() (rs []interface{}, err error) {
+
+	rs, err = db.Test{}.UserList()
+	return
+}

+ 41 - 0
service/user.go

@@ -0,0 +1,41 @@
+/**
+ * @ File:
+ * @ Date: 2021/1/25 10:07
+ * @ Author: JYQ
+ * @ Description:
+ */
+package service
+
+type User struct {
+	base
+}
+
+//会员用户列表查询带分页
+func (u User) ShopUserListQuery(
+	sess string,
+	phone string,
+	name string,
+	pageIndex int,
+	tableMax int) (rs string, pageCount int64, err error) {
+	//offset := utils.PageIndex2RowOffset(pageIndex, tableMax)
+	//// todo 做session校验
+	//
+	//dao := u.getUserDao()
+	//userrs, allCount, err := dao.ShopUserListQuery(phone, name, vipType, user.ShopId, expDay, tableMax, offset)
+	//if err != nil {
+	//	return
+	//}
+	//
+	//pageCount = utils.CountPage(allCount, tableMax)
+
+	return
+}
+
+//会员用户基本信息查询
+func (u User) ShopUserSimpleQuery(sess string, classId *int) (rs string, err error) {
+	// todo 做session校验
+	//user := u.getUser(sess)
+	//dao := u.getUserDao()
+	//rs, err = dao.ShopUserSimpleQuery(classId, user.ShopId)
+	return
+}

+ 55 - 0
update_api_app.ps1

@@ -0,0 +1,55 @@
+Write-Output $addHosts
+$module = "video_course"
+
+
+$dockerImage ="docker.beswell.com:5050/loallout/$module"
+$cmd = "docker pull ${dockerImage}:latest"
+
+Invoke-Expression $cmd
+
+$cName = "loallout_hr_$module"
+
+$cmd = "docker stop $cName"
+try {
+    Invoke-Expression $cmd
+}
+catch {
+}
+$cmd = "docker rm $cName"
+try {
+    Invoke-Expression $cmd
+}
+catch {
+}
+
+if ($IsWindows) {
+    $configPath = $PSScriptRoot
+    $consulAddr = "host.docker.internal:8500"
+    $hostsPath = "C:\WINDOWS\system32\drivers\etc\hosts"
+    $timeZone =" "
+}
+if ($IsLinux){
+    $configPath = "/etc/bsw/loallout/$module"
+    $consulAddr = "172.17.0.1:8500"
+    $hostsPath = "/etc/hosts"
+    $timeZone = " -v /etc/localtime:/etc/localtime "
+}
+
+$hosts = Get-Content $hostsPath | Where-Object { $true -ne [string]::IsNullOrWhiteSpace($_) }
+$addHosts = ""
+foreach ($item in $hosts) {
+
+    if (!($item -match ".*#.*")) {
+        $array = $item.Split("`t", [StringSplitOptions]::RemoveEmptyEntries)
+        $ip = $array[0]
+        $hostArray = $array[1..$array.Length]
+        
+        foreach ($h in $hostArray){
+            $addHosts = $addHosts + " --add-host ${h}:$ip "
+        }
+    }
+}
+
+$cmd = "docker run -d -p 50051:58080 -P --name $cName $addHosts -v /etc/video_course:/conf $timeZone -e CONSUL_ADDR=$consulAddr -e DEBUG=TRUE --restart=always ${dockerImage}:latest"
+Write-Output "exec cmd: $cmd"
+Invoke-Expression $cmd

+ 28 - 0
utils/page.go

@@ -0,0 +1,28 @@
+/*
+@Time : 2019-07-10 10:20
+@Author : zr
+*/
+package utils
+
+func CountPage(totalCount int64, onePageCount int) int64 {
+	if onePageCount == 0 {
+		return 0
+	}
+	page := totalCount / int64(onePageCount)
+	remain := totalCount % int64(onePageCount)
+	if remain > 0 {
+		page = page + 1
+	}
+
+	return page
+}
+
+func PageIndex2RowOffset(pageIndex int, onePageCount int) int {
+	if onePageCount == 0 {
+		return 0
+	}
+	pageIndex = pageIndex - 1
+	offset := pageIndex * onePageCount
+
+	return offset
+}

+ 34 - 0
utils/string.go

@@ -0,0 +1,34 @@
+/**
+ * @ File:
+ * @ Date: 2020/12/11 10:14
+ * @ Author: JYQ
+ * @ Description:
+ */
+package utils
+
+//import (
+//	"video_course/errors"
+//	"strconv"
+//	"strings"
+//	"time"
+//)
+
+// 分隔字符串
+//func StringSplit(str string, sep string) (newTime time.Time, err error) {
+//
+//	var idArr []string
+//	if str != "" {
+//		idArr = strings.Split(str, sep)
+//		for _, valueStr := range idArr {
+//			_, err_ := strconv.Atoi(valueStr)
+//			if err_ != nil {
+//				err = errors.ErrCommalistCode
+//				return
+//			}
+//		}
+//	} else {
+//		err = errors.ErrStrIsNIl
+//		return
+//	}
+//	return
+//}

+ 126 - 0
utils/time.go

@@ -0,0 +1,126 @@
+/*
+@Time : 2019-07-08 11:12
+@Author : zr
+*/
+package utils
+
+import (
+	"math"
+	"math/rand"
+	"time"
+	"video_course/errors"
+)
+
+func TimeFormatter() string {
+	return "2006-01-02 15:04:05"
+}
+func TimeFormatterDate() string {
+	return "2006-01-02"
+}
+
+func TimeStdQueryBegin(stdTimeStr string) (newTime time.Time, err error) {
+	if stdTimeStr == "" {
+		return time.Parse(TimeFormatter(), "2000-01-01 00:00:00")
+	}
+
+	newTime, err = time.Parse(TimeFormatter(), stdTimeStr)
+	if err != nil {
+		return newTime, err
+	}
+	newTimeStr := newTime.Format("2006-01-02") + " 00:00:00"
+
+	return time.Parse(TimeFormatter(), newTimeStr)
+}
+func TimeStdQueryEnd(stdTimeStr string) (newTime time.Time, err error) {
+	if stdTimeStr == "" {
+		newTime = time.Now()
+	} else {
+		newTime, err = time.Parse(TimeFormatter(), stdTimeStr)
+		if err != nil {
+			return newTime, err
+		}
+	}
+	newTimeStr := newTime.Format("2006-01-02") + " 23:59:59"
+	return time.Parse(TimeFormatter(), newTimeStr)
+}
+
+func TimeDayBegin(day time.Time) time.Time {
+	dayBeginStr := day.Format("2006-01-02") + " 00:00:00"
+	dayBegin, _ := time.Parse(TimeFormatter(), dayBeginStr)
+	return dayBegin
+}
+func TimeTodayBegin() time.Time {
+	timeNow := time.Now()
+	dayBeginStr := timeNow.Format("2006-01-02") + " 00:00:00"
+	dayBegin, _ := time.Parse(TimeFormatter(), dayBeginStr)
+	return dayBegin
+}
+
+func TimeDayEnd(day time.Time) time.Time {
+	dayStr := day.Format("2006-01-02") + " 23:59:59"
+	day, _ = time.Parse(TimeFormatter(), dayStr)
+	return day
+}
+func RandomInt(n int) int {
+	min := int(math.Pow(10, float64(n-1)))
+	max := min*9 - 1
+
+	rand1 := rand.New(rand.NewSource(time.Now().UnixNano()))
+	code := rand1.Intn(max) + min
+	return code
+}
+
+func GetAgeByBirthday(b time.Time) (age int) {
+	//b, err := time.Parse(TimeFormatter(), birthday)
+	//if err != nil {
+	//	return 0, err
+	//}
+	year := b.Year()
+	month := int(b.Month())
+	day := b.Day()
+
+	nowYear := time.Now().Year()
+	nowMonth := int(time.Now().Month())
+	nowDay := time.Now().Day()
+
+	if nowYear < year {
+		panic(errors.ErrBirthday)
+	}
+	age = nowYear - year
+	if month > nowMonth { // 当生日月份>当前月份的时候,年龄-1
+		age = age - 1
+	}
+	if month == nowMonth && day > nowDay {
+		age = age - 1 // 当生日月份与当前月份相等的时候,如果生日日期大于当天日期,则生日未到,年龄-1
+	}
+
+	return
+}
+
+func GetStaticHrByAge(age int) (staticHr int) {
+	switch age {
+	case 2:
+		staticHr = 80
+	case 3:
+		staticHr = 80
+	case 4:
+		staticHr = 80
+	case 5:
+		staticHr = 75
+	case 6:
+		staticHr = 75
+	case 7:
+		staticHr = 70
+	case 8:
+		staticHr = 70
+	case 9:
+		staticHr = 70
+	default:
+		if age >= 10 {
+			staticHr = 60
+		} else {
+			panic(errors.ErrStaticHr)
+		}
+	}
+	return
+}