Commit 5bd8aa9046b8c69094be9a787f50745b1b4a6517

Authored by aarongao
1 parent 8a882f01
Exists in v1.2 and in 2 other branches master, v1.1

V1.0

.gitignore
1 1 main
  2 +main2
2 3 tiles
3 4 Upload
4 5 Console
... ...
API/Operator.go
... ... @@ -89,8 +89,8 @@ func UpdateOperator(c *gin.Context) {
89 89 var _auth []string
90 90 json.Unmarshal([]byte(c.PostForm("Auth")), &_auth)
91 91  
92   - objID, err := primitive.ObjectIDFromHex(c.PostForm("id"))
93   - if err == nil {
  92 + objID, errForObjectID := primitive.ObjectIDFromHex(c.PostForm("id"))
  93 + if errForObjectID == nil {
94 94  
95 95 _, err = DB.CMember.UpdateOne(tools.GetContext(),
96 96 bson.M{"_id": objID},
... ... @@ -98,35 +98,31 @@ func UpdateOperator(c *gin.Context) {
98 98 "Auth": _auth,
99 99 "Username": c.PostForm("Username"),
100 100 "Password": c.PostForm("Password"),
101   - "Remarks": c.PostForm("Remarks"),
  101 + "Remarks": c.PostForm("Remarks"),
102 102 }},
103 103 )
104 104 } else {
105 105  
106 106 objectID := primitive.NewObjectID()
107 107 User := &DB.SMember{
108   - &objectID,
109   - "operator",
110   - c.PostForm("ScenicId"),
111   - c.PostForm("Username"),
112   - c.PostForm("Password"),
113   - "",
114   - "",
115   - "",
116   - "",
117   - "",
118   - "",
119   - &DB.SDevice{},
120   - _auth,
121   - c.PostForm("Remarks"),
  108 + Id: &objectID,
  109 + UserType: "operator",
  110 + ScenicId: c.PostForm("ScenicId"),
  111 + Username: c.PostForm("Username"),
  112 + Password: c.PostForm("Password"),
  113 + Auth: _auth,
  114 + Remarks: c.PostForm("Remarks"),
122 115 }
123 116  
124   - // 生成token
125   - var dd time.Duration
126   - dd, err = time.ParseDuration("20m")
127   - User.Token, _ = JWT.CreateToken(User, time.Now().Add(dd).Unix())
  117 + _, err := DB.CMember.InsertOne(tools.GetContext(), User)
  118 + if err != nil {
128 119  
129   - DB.CMember.InsertOne(tools.GetContext(), User)
  120 + c.JSON(200, tools.ResponseError{
  121 + 1,
  122 + "用户名重复",
  123 + })
  124 + return
  125 + }
130 126  
131 127 }
132 128  
... ...
API/User.go
... ... @@ -2,6 +2,7 @@ package Api
2 2  
3 3 import (
4 4 "github.com/aarongao/tools"
  5 + "github.com/davecgh/go-spew/spew"
5 6 "github.com/gin-gonic/gin"
6 7 "go.mongodb.org/mongo-driver/bson"
7 8 "go.mongodb.org/mongo-driver/bson/primitive"
... ... @@ -65,18 +66,10 @@ func LoginUser(c *gin.Context) {
65 66 var auth = []string{"用户管理", "通知管理"}
66 67 objectID := primitive.NewObjectID()
67 68 User = &DB.SMember{
68   - &objectID,
69   - "visitor",
70   - "",
71   - "",
72   - "",
73   - "",
74   - "",
75   - c.PostForm("Mobile"),
76   - "",
77   - "",
78   - "",
79   - &DB.SDevice{
  69 + Id: &objectID,
  70 + UserType: "visitor",
  71 + Mobile: c.PostForm("Mobile"),
  72 + Device: &DB.SDevice{
80 73 c.Request.Header.Get("DeviceId"),
81 74 c.Request.Header.Get("Mac"),
82 75 c.Request.Header.Get("UDID"),
... ... @@ -86,10 +79,18 @@ func LoginUser(c *gin.Context) {
86 79 c.Request.Header.Get("AppVersion"),
87 80 c.Request.Header.Get("DeviceToken"),
88 81 },
89   - auth,
90   - "",
  82 + Auth: auth,
  83 + }
  84 + _, err := DB.CMember.InsertOne(tools.GetContext(), User)
  85 + if err != nil {
  86 +
  87 + spew.Dump(err)
  88 + c.JSON(200, tools.ResponseError{
  89 + 1,
  90 + "登陆失败(数据创建错误)",
  91 + })
  92 + return
91 93 }
92   - DB.CMember.InsertOne(tools.GetContext(), User)
93 94 }
94 95  
95 96 } else {
... ...
Config/config.go
... ... @@ -9,6 +9,7 @@ type Config struct {
9 9 RedisPath string
10 10 Env string
11 11 TokenSecret string
  12 + ServerPort string
12 13 }
13 14  
14 15 var Info = Config{}
... ...
Config/config.json
... ... @@ -6,5 +6,6 @@
6 6 "dbPassword": "leyoutu123456",
7 7 "redisPath": "127.0.0.1:6379",
8 8 "Env": "DEV",
9   - "tokenSecret": "token.secret"
  9 + "tokenSecret": "token.secret",
  10 + "ServerPort": ":8080"
10 11 }
... ...
DB/db.go
... ... @@ -150,18 +150,18 @@ type SInvestigation struct {
150 150 type SMember struct {
151 151 Id *primitive.ObjectID `bson:"_id" json:"Id" valid:"required"`
152 152 UserType string `bson:"UserType" json:"UserType"` // "root" or "operator" or "visitor"
153   - ScenicId string `bson:"ScenicId" json:"ScenicId"`
154   - Username string `bson:"Username" json:"Username"`
155   - Password string `bson:"Password" json:"Password"`
156   - Birthday string `bson:"Birthday" json:"Birthday"`
157   - FullName string `bson:"FullName" json:"FullName"`
158   - Mobile string `bson:"Mobile" json:"Mobile"`
159   - Openid string `bson:"Openid" json:"Openid"`
160   - Token string `bson:"Token" json:"Token"`
161   - Sex string `bson:"Sex" json:"Sex"`
162   - Device *SDevice `bson:"Device" json:"Device"` //设备信息
163   - Auth []string `bson:"Auth" json:"Auth"` //权限信息
164   - Remarks string `bson:"Remarks" json:"Remarks"` //说明
  153 + ScenicId string `bson:"ScenicId,omitempty" json:"ScenicId,omitempty"`
  154 + Username string `bson:"Username,omitempty" json:"Username,omitempty"`
  155 + Password string `bson:"Password,omitempty" json:"Password,omitempty"`
  156 + Birthday string `bson:"Birthday,omitempty" json:"Birthday"`
  157 + FullName string `bson:"FullName,omitempty" json:"FullName"`
  158 + Mobile string `bson:"Mobile,omitempty" json:"Mobile"`
  159 + Openid string `bson:"Openid,omitempty" json:"Openid"`
  160 + Token string `bson:"Token,omitempty" json:"Token,omitempty"`
  161 + Sex string `bson:"Sex,omitempty" json:"Sex"`
  162 + Device *SDevice `bson:"Device,omitempty" json:"Device"` //设备信息
  163 + Auth []string `bson:"Auth,omitempty" json:"Auth"` //权限信息
  164 + Remarks string `bson:"Remarks,omitempty" json:"Remarks"` //说明
165 165 }
166 166  
167 167 type STag struct {
... ...
Lib/DelayMessage/delaymessage.go
... ... @@ -78,19 +78,19 @@ func (dm *DelayMessage) AddTaskForAppMessage(delayTime string, deviceToken strin
78 78 iDelayTIme := i64Time - nowTimeU
79 79  
80 80 if i64Time <= nowTimeU {
81   - return errors.New("delayTime error...")
  81 + return errors.New("设定时间小于当前时间")
82 82 }
83 83 if deviceToken == "" {
84   - return errors.New("deviceToken error...")
  84 + return errors.New("缺少设备ID号")
85 85 }
86 86 if title == "" {
87   - return errors.New("title error...")
  87 + return errors.New("缺少标题")
88 88 }
89 89 if content == "" {
90   - return errors.New("content error...")
  90 + return errors.New("缺少内容")
91 91 }
92 92 if userid == "" {
93   - return errors.New("userid error...")
  93 + return errors.New("缺少用户ID")
94 94 }
95 95  
96 96 objectID := primitive.NewObjectID()
... ...
Version.md 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +## 版本号:v1.1
  2 +
  3 +##### 生产环境地址:http://leyoutu.st-i.com.cn/api/v1.1/
  4 +
  5 +##### 测试环境地址:http://leyoutu.sti-uat.com/api/v1.1/
  6 +
  7 +##### 变更说明:
  8 +
  9 +1. /UserInfo接口增加权限验证(需要携带Token),游客和操作员看到的信息内容不一样
  10 +2.
  11 +
  12 +##### 开发&发布流程:
  13 +
  14 +1. 提交代码到git(v1.1分支)
  15 +2. 编译为内测版本至TestFlight,并附带升级明细
  16 +3. 合并master分支
  17 +4. 修改正式接口地址并编译为公测版本至TestFlight
  18 +5. 发布至商店
0 19 \ No newline at end of file
... ...
main.go
... ... @@ -21,7 +21,7 @@ import (
21 21  
22 22 // @APIVersion 1.0.0
23 23 // @APITitle 乐游图后端接口文档
24   -// @BasePath 正式 leyoutu.st-i.com.cn; 测试 letu.api.imagchina.com
  24 +// @BasePath 正式 leyoutu.st-i.com.cn; 测试 leyoutu.sti-uat.com
25 25 var Gin *gin.Engine
26 26  
27 27 func main() {
... ... @@ -195,7 +195,7 @@ func main() {
195 195 spew.Dump(err)
196 196 }
197 197  
198   - Gin.Run(":8080")
  198 + Gin.Run(Config.Info.ServerPort)
199 199 }
200 200  
201 201 func InitController(method string, uri string, handFunc func(c *gin.Context), auth *DB.SModel) {
... ...