Commit 8a882f01f6c1402b11033de14239d3089714d0cb

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

1.0

.idea/inspectionProfiles/Project_Default.xml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<component name="InspectionProjectProfileManager">
  2 + <profile version="1.0">
  3 + <option name="myName" value="Project Default" />
  4 + <inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
  5 + </profile>
  6 +</component>
0 7 \ No newline at end of file
... ...
.idea/jsLinters/jshint.xml 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="JSHintConfiguration" version="2.10.2" use-config-file="true" use-custom-config-file="true" custom-config-file-path="$PROJECT_DIR$/Console/html/bootstrap/grunt/.jshintrc">
  4 + <option bitwise="true" />
  5 + <option browser="true" />
  6 + <option curly="true" />
  7 + <option eqeqeq="true" />
  8 + <option forin="true" />
  9 + <option maxerr="50" />
  10 + <option noarg="true" />
  11 + <option noempty="true" />
  12 + <option nonew="true" />
  13 + <option strict="true" />
  14 + <option undef="true" />
  15 + </component>
  16 +</project>
0 17 \ No newline at end of file
... ...
.idea/letu.iml 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<module type="WEB_MODULE" version="4">
  3 + <component name="NewModuleRootManager">
  4 + <content url="file://$MODULE_DIR$" />
  5 + <orderEntry type="inheritedJdk" />
  6 + <orderEntry type="sourceFolder" forTests="false" />
  7 + </component>
  8 +</module>
0 9 \ No newline at end of file
... ...
.idea/misc.xml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="JavaScriptSettings">
  4 + <option name="languageLevel" value="ES6" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
.idea/modules.xml 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/.idea/letu.iml" filepath="$PROJECT_DIR$/.idea/letu.iml" />
  6 + </modules>
  7 + </component>
  8 +</project>
0 9 \ No newline at end of file
... ...
.idea/vcs.xml 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
.idea/workspace.xml 0 → 100644
... ... @@ -0,0 +1,128 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ChangeListManager">
  4 + <list default="true" id="4fc60b58-eb6b-4763-99c5-b2201813bdc2" name="Default Changelist" comment="">
  5 + <change beforePath="$PROJECT_DIR$/API/Complaint.go" beforeDir="false" afterPath="$PROJECT_DIR$/API/Complaint.go" afterDir="false" />
  6 + <change beforePath="$PROJECT_DIR$/API/DealyMessage.go" beforeDir="false" afterPath="$PROJECT_DIR$/API/DealyMessage.go" afterDir="false" />
  7 + <change beforePath="$PROJECT_DIR$/API/Investigation.go" beforeDir="false" afterPath="$PROJECT_DIR$/API/Investigation.go" afterDir="false" />
  8 + <change beforePath="$PROJECT_DIR$/API/UserLog.go" beforeDir="false" afterPath="$PROJECT_DIR$/API/UserLog.go" afterDir="false" />
  9 + <change beforePath="$PROJECT_DIR$/Bin/Monitor.go" beforeDir="false" afterPath="$PROJECT_DIR$/Bin/Monitor.go" afterDir="false" />
  10 + <change beforePath="$PROJECT_DIR$/Config/config.go" beforeDir="false" afterPath="$PROJECT_DIR$/Config/config.go" afterDir="false" />
  11 + <change beforePath="$PROJECT_DIR$/Config/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/Config/config.json" afterDir="false" />
  12 + <change beforePath="$PROJECT_DIR$/Lib/DelayMessage/delaymessage.go" beforeDir="false" afterPath="$PROJECT_DIR$/Lib/DelayMessage/delaymessage.go" afterDir="false" />
  13 + <change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
  14 + <change beforePath="$PROJECT_DIR$/main2.go" beforeDir="false" />
  15 + </list>
  16 + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
  17 + <option name="SHOW_DIALOG" value="false" />
  18 + <option name="HIGHLIGHT_CONFLICTS" value="true" />
  19 + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
  20 + <option name="LAST_RESOLUTION" value="IGNORE" />
  21 + </component>
  22 + <component name="FileEditorManager">
  23 + <leaf />
  24 + </component>
  25 + <component name="GOROOT" path="/usr/local/go" />
  26 + <component name="Git.Settings">
  27 + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  28 + </component>
  29 + <component name="ProjectConfigurationFiles">
  30 + <option name="files">
  31 + <list>
  32 + <option value="$PROJECT_DIR$/.idea/letu.iml" />
  33 + <option value="$PROJECT_DIR$/.idea/misc.xml" />
  34 + <option value="$PROJECT_DIR$/.idea/modules.xml" />
  35 + <option value="$PROJECT_DIR$/.idea/vcs.xml" />
  36 + <option value="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
  37 + <option value="$PROJECT_DIR$/.idea/jsLinters/jshint.xml" />
  38 + </list>
  39 + </option>
  40 + </component>
  41 + <component name="ProjectFrameBounds">
  42 + <option name="x" value="315" />
  43 + <option name="y" value="73" />
  44 + <option name="width" value="1454" />
  45 + <option name="height" value="1010" />
  46 + </component>
  47 + <component name="ProjectView">
  48 + <navigator proportions="" version="1">
  49 + <foldersAlwaysOnTop value="true" />
  50 + </navigator>
  51 + <panes>
  52 + <pane id="ProjectPane">
  53 + <subPane>
  54 + <expand>
  55 + <path>
  56 + <item name="letu" type="b2602c69:ProjectViewProjectNode" />
  57 + <item name="letu" type="462c0819:PsiDirectoryNode" />
  58 + </path>
  59 + <path>
  60 + <item name="letu" type="b2602c69:ProjectViewProjectNode" />
  61 + <item name="letu" type="462c0819:PsiDirectoryNode" />
  62 + <item name="DB" type="462c0819:PsiDirectoryNode" />
  63 + </path>
  64 + </expand>
  65 + <select />
  66 + </subPane>
  67 + </pane>
  68 + <pane id="Scope" />
  69 + </panes>
  70 + </component>
  71 + <component name="PropertiesComponent">
  72 + <property name="WebServerToolWindowFactoryState" value="false" />
  73 + <property name="go.gopath.indexing.explicitly.defined" value="true" />
  74 + <property name="go.import.settings.migrated" value="true" />
  75 + <property name="go.sdk.automatically.set" value="true" />
  76 + <property name="last_opened_file_path" value="$PROJECT_DIR$" />
  77 + <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
  78 + <property name="nodejs_npm_path_reset_for_default_project" value="true" />
  79 + </component>
  80 + <component name="RunDashboard">
  81 + <option name="ruleStates">
  82 + <list>
  83 + <RuleState>
  84 + <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
  85 + </RuleState>
  86 + <RuleState>
  87 + <option name="name" value="StatusDashboardGroupingRule" />
  88 + </RuleState>
  89 + </list>
  90 + </option>
  91 + </component>
  92 + <component name="ToolWindowManager">
  93 + <frame x="315" y="73" width="1454" height="1010" extended-state="0" />
  94 + <layout>
  95 + <window_info id="Favorites" side_tool="true" />
  96 + <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
  97 + <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
  98 + <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
  99 + <window_info anchor="bottom" id="Database Changes" />
  100 + <window_info anchor="bottom" id="Version Control" />
  101 + <window_info anchor="bottom" id="Terminal" />
  102 + <window_info anchor="bottom" id="Event Log" side_tool="true" />
  103 + <window_info anchor="bottom" id="Message" order="0" />
  104 + <window_info anchor="bottom" id="Find" order="1" />
  105 + <window_info anchor="bottom" id="Run" order="2" />
  106 + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
  107 + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
  108 + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
  109 + <window_info anchor="bottom" id="TODO" order="6" />
  110 + <window_info anchor="right" id="Database" />
  111 + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
  112 + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
  113 + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
  114 + </layout>
  115 + </component>
  116 + <component name="TypeScriptGeneratedFilesManager">
  117 + <option name="version" value="1" />
  118 + </component>
  119 + <component name="editorHistoryManager">
  120 + <entry file="file://$PROJECT_DIR$/DB/db.go">
  121 + <provider selected="true" editor-type-id="text-editor">
  122 + <state relative-caret-position="270">
  123 + <caret line="22" column="41" lean-forward="true" selection-start-line="22" selection-start-column="41" selection-end-line="22" selection-end-column="41" />
  124 + </state>
  125 + </provider>
  126 + </entry>
  127 + </component>
  128 +</project>
0 129 \ No newline at end of file
... ...
API/Complaint.go
... ... @@ -59,7 +59,6 @@ func CreateComplaint(c *gin.Context) {
59 59 "验证码不正确",
60 60 })
61 61 return
62   -
63 62 }
64 63  
65 64 var images []string
... ... @@ -74,7 +73,7 @@ func CreateComplaint(c *gin.Context) {
74 73 c.PostForm("Sex"),
75 74 c.PostForm("Content"),
76 75 images,
77   - "",
  76 + "未处理",
78 77 time.Now().Unix(),
79 78 })
80 79  
... ... @@ -124,7 +123,7 @@ func AllComplaint(c *gin.Context) {
124 123 0,
125 124 total,
126 125 currPage,
127   - int(math.Ceil(float64(total) / float64(limit))),
  126 + int64(math.Ceil(float64(total) / float64(limit))),
128 127 limit,
129 128 aComplaint,
130 129 })
... ...
API/DealyMessage.go
... ... @@ -2,11 +2,13 @@ package Api
2 2  
3 3 import (
4 4 "github.com/aarongao/tools"
  5 + "github.com/aliyun/alibaba-cloud-sdk-go/services/push"
5 6 "github.com/gin-gonic/gin"
6 7 "go.mongodb.org/mongo-driver/bson"
7 8 "go.mongodb.org/mongo-driver/bson/primitive"
  9 + "letu/Config"
  10 + "letu/DB"
8 11 "letu/Lib/DelayMessage"
9   - "letu/Lib/Token"
10 12 )
11 13  
12 14 // @Title 查询用户的定时提醒
... ... @@ -15,26 +17,19 @@ import (
15 17 // @Produce json
16 18 // @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户id"
17 19 // @Param Token wgergejfwe string true "用户token"
18   -// @Success 200 {object} tools.ResponseSeccess "DelayTime=执行时间;Type=类型(0请求url地址1发送app通知);Fail失败次数;Title=通知标题;Content=通知内容;UDID=设备id"
  20 +// @Success 200 {object} tools.ResponseSeccess "DelayTime=执行时间;Type=类型(0请求url地址1发送app通知);Fail失败次数;Title=通知标题;Content=通知内容;DeviceToken=设备id"
19 21 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
20 22 // @Router /DealyMessage/Info? [get]
21 23 func DealyMessageInfo(c *gin.Context) {
22 24 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
23 25 c.Header("Access-Control-Allow-Credentials", "true")
24 26  
25   - _, err := primitive.ObjectIDFromHex(c.Query("UserId"))
26   - if c.Query("Token") == "" || err != nil {
27   - c.JSON(200, tools.ResponseError{
28   - 1,
29   - "Token或者用户id不正确",
30   - })
31   - return
32   - }
33   -
34   - if Token.GetToken(c.Query("UserId")) != c.Query("Token") {
  27 + _user, _ := c.Get("UserInfo")
  28 + user := _user.(*DB.SMember)
  29 + if c.Query("UserId") != user.Id.Hex() {
35 30 c.JSON(200, tools.ResponseError{
36 31 401,
37   - "token过期",
  32 + "没有权限",
38 33 })
39 34 return
40 35 }
... ... @@ -46,7 +41,7 @@ func DealyMessageInfo(c *gin.Context) {
46 41 for cur.Next(tools.GetContext()) {
47 42 var e DelayMessage.Message
48 43 cur.Decode(&e)
49   - aDelayMessage = append(aDelayMessage,e)
  44 + aDelayMessage = append(aDelayMessage, e)
50 45 }
51 46 }
52 47  
... ... @@ -65,7 +60,7 @@ func DealyMessageInfo(c *gin.Context) {
65 60 // @Produce json
66 61 // @Param UserId 5dfb03070a9ac17ac7a82054 string true "用户id"
67 62 // @Param Token wgergejfwe string true "用户token"
68   -// @Param UDID 5dfb03070a9ac17ac7a82054 string true "设备id"
  63 +// @Param DeviceToken 5dfb03070a9ac17ac7a82054 string true "设备id"
69 64 // @Param Title 表演时间提醒 string true "标题"
70 65 // @Param Content 5分钟后有表演 string true "内容"
71 66 // @Param DelayTime 1579066863 string true "到达这个时间戳就执行"
... ... @@ -76,24 +71,27 @@ func CreateDealyMessage(c *gin.Context) {
76 71 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
77 72 c.Header("Access-Control-Allow-Credentials", "true")
78 73  
79   - _,err := primitive.ObjectIDFromHex(c.PostForm("UserId"))
80   - if c.PostForm("Token") == "" || err != nil {
  74 +
  75 + _user, _ := c.Get("UserInfo")
  76 + userToken := _user.(*DB.SMember)
  77 + if c.PostForm("UserId") != userToken.Id.Hex(){
81 78 c.JSON(200, tools.ResponseError{
82   - 1,
83   - "Token或者用户id不正确",
  79 + 401,
  80 + "没有权限",
84 81 })
85 82 return
86 83 }
87 84  
88   - if Token.GetToken(c.PostForm("UserId")) != c.PostForm("Token") {
  85 + _, err := primitive.ObjectIDFromHex(c.PostForm("UserId"))
  86 + if err != nil {
89 87 c.JSON(200, tools.ResponseError{
90   - 401,
91   - "token过期",
  88 + 1,
  89 + "id不正确",
92 90 })
93 91 return
94 92 }
95 93  
96   - err = DelayMessage.GlobalDM.AddTaskForAppMessage(c.PostForm("DelayTime"), c.PostForm("UDID"), c.PostForm("Title"), c.PostForm("Content"), c.PostForm("UserId"))
  94 + err = DelayMessage.GlobalDM.AddTaskForAppMessage(c.PostForm("DelayTime"), c.PostForm("DeviceToken"), c.PostForm("Title"), c.PostForm("Content"), c.PostForm("UserId"))
97 95  
98 96 if err == nil {
99 97  
... ... @@ -125,20 +123,21 @@ func RemoveDealyMessage(c *gin.Context) {
125 123 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
126 124 c.Header("Access-Control-Allow-Credentials", "true")
127 125  
128   -
129   - _,err := primitive.ObjectIDFromHex(c.PostForm("UserId"))
130   - if c.PostForm("Token") == "" || err != nil {
  126 + _user, _ := c.Get("UserInfo")
  127 + userToken := _user.(*DB.SMember)
  128 + if c.PostForm("UserId") != userToken.Id.Hex(){
131 129 c.JSON(200, tools.ResponseError{
132   - 1,
133   - "Token或者用户id不正确",
  130 + 401,
  131 + "没有权限",
134 132 })
135 133 return
136 134 }
137 135  
138   - if Token.GetToken(c.PostForm("UserId")) != c.PostForm("Token") {
  136 + _, err := primitive.ObjectIDFromHex(c.PostForm("UserId"))
  137 + if err != nil {
139 138 c.JSON(200, tools.ResponseError{
140   - 401,
141   - "token过期",
  139 + 1,
  140 + "用户id不正确",
142 141 })
143 142 return
144 143 }
... ... @@ -151,3 +150,34 @@ func RemoveDealyMessage(c *gin.Context) {
151 150 })
152 151  
153 152 }
  153 +
  154 +
  155 +func PushNoticeToiOS(c *gin.Context) {
  156 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  157 + c.Header("Access-Control-Allow-Credentials", "true")
  158 +
  159 + // 推送app消息
  160 + client, err := push.NewClientWithAccessKey("cn-hangzhou", "LTAI4FdQeNMQXRU6u5J3EFQc", "PwvyF5rRNBWLDya41WrCpvENevYZGi")
  161 +
  162 + request := push.CreatePushNoticeToiOSRequest()
  163 + request.ApnsEnv = Config.Info.Env
  164 + request.AppKey = "28332889"
  165 + request.Scheme = "https"
  166 + request.Target = "DEVICE"
  167 + request.TargetValue = "30076ed6fdb740e49d882433931bc34a"
  168 + request.Title = c.Query("title")
  169 + request.Body = c.Query("body")
  170 +
  171 + response, err := client.PushNoticeToiOS(request)
  172 + if err != nil {
  173 + c.JSON(200, tools.ResponseError{
  174 + 1,
  175 + err.Error(),
  176 + })
  177 + return
  178 + }
  179 + c.JSON(200, tools.ResponseSeccess{
  180 + 0,
  181 + response,
  182 + })
  183 +}
154 184 \ No newline at end of file
... ...
API/Icon.go
... ... @@ -7,6 +7,7 @@ import (
7 7 "go.mongodb.org/mongo-driver/bson/primitive"
8 8 "go.mongodb.org/mongo-driver/mongo/options"
9 9 "letu/DB"
  10 + "letu/Lib/Auth"
10 11 )
11 12  
12 13 // @Title 返回图标基础信息
... ... @@ -45,6 +46,8 @@ func IconInfo(c *gin.Context) {
45 46 // @Accept json
46 47 // @Produce json
47 48 // @Param id 5dfb03070a9ac17ac7a82054 string true "图标id"
  49 +// @Param ScenicId 5e0d504e24e03431008b4567 string true "景区id"
  50 +// @Param Token wgergejfwe string true "用户token"
48 51 // @Success 200 {object} tools.ResponseSeccess "Name名称:Picture图片地址:id图标id:ScenicId景区id"
49 52 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
50 53 // @Router /Icon/Update? [post]
... ... @@ -52,11 +55,13 @@ func UpdateIcon(c *gin.Context) {
52 55 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
53 56 c.Header("Access-Control-Allow-Credentials", "true")
54 57  
55   - ScenicId := c.PostForm("ScenicId")
56   - if ScenicId == "" || ScenicId == "undefined" {
  58 + _user, _ := c.Get("UserInfo")
  59 + user := _user.(*DB.SMember)
  60 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  61 + if err != nil {
57 62 c.JSON(200, tools.ResponseError{
58   - 1,
59   - "缺少ScenicId(景区id)",
  63 + 401,
  64 + "没有权限",
60 65 })
61 66 return
62 67 }
... ... @@ -74,7 +79,7 @@ func UpdateIcon(c *gin.Context) {
74 79 bson.M{"$set": bson.M{
75 80 "Name": c.PostForm("Name"),
76 81 "Picture": c.PostForm("Picture"),
77   - "ScenicId": ScenicId,
  82 + "ScenicId": c.PostForm("ScenicId"),
78 83 }}, &options.FindOneAndUpdateOptions{
79 84 Upsert: &upsert,
80 85 },
... ... @@ -99,13 +104,9 @@ func AllIcons(c *gin.Context) {
99 104 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
100 105 c.Header("Access-Control-Allow-Credentials", "true")
101 106  
102   - ScenicId := c.Query("ScenicId")
103   - if ScenicId == "" || ScenicId == "undefined" {
104   - c.JSON(200, tools.ResponseError{
105   - 1,
106   - "缺少ScenicId(景区id)",
107   - })
108   - return
  107 + var ScenicId string
  108 + if ScenicId = c.Query("ScenicId"); ScenicId == "" {
  109 + ScenicId = "5e0d504e24e03431008b4567" // 乐岛
109 110 }
110 111  
111 112 var SIcons = []DB.SIcons{}
... ... @@ -115,11 +116,10 @@ func AllIcons(c *gin.Context) {
115 116 for cur.Next(tools.GetContext()) {
116 117 var e DB.SIcons
117 118 cur.Decode(&e)
118   - SIcons = append(SIcons,e)
  119 + SIcons = append(SIcons, e)
119 120 }
120 121 }
121 122  
122   -
123 123 c.JSON(200, tools.ResponseSeccess{
124 124 0,
125 125 SIcons,
... ...
API/Investigation.go
... ... @@ -80,7 +80,7 @@ func AllInvestigation(c *gin.Context) {
80 80 0,
81 81 total,
82 82 currPage,
83   - int(math.Ceil(float64(total) / float64(limit))),
  83 + int64(math.Ceil(float64(total) / float64(limit))),
84 84 limit,
85 85 aInvestigation,
86 86 })
... ...
API/Item.go
... ... @@ -8,6 +8,7 @@ import (
8 8 "go.mongodb.org/mongo-driver/bson/primitive"
9 9 "go.mongodb.org/mongo-driver/mongo/options"
10 10 "letu/DB"
  11 + "letu/Lib/Auth"
11 12 "strconv"
12 13 "time"
13 14 )
... ... @@ -33,8 +34,8 @@ func ItemInfo(c *gin.Context) {
33 34 }
34 35  
35 36 var SItem DB.SItem
36   - objID,_ := primitive.ObjectIDFromHex(c.Query("id"))
37   - DB.CItem.FindOne(tools.GetContext(),bson.M{"_id": objID}).Decode(&SItem)
  37 + objID, _ := primitive.ObjectIDFromHex(c.Query("id"))
  38 + DB.CItem.FindOne(tools.GetContext(), bson.M{"_id": objID}).Decode(&SItem)
38 39  
39 40 c.JSON(200, tools.ResponseSeccess{
40 41 0,
... ... @@ -47,6 +48,7 @@ func ItemInfo(c *gin.Context) {
47 48 // @Description 设备管理 - 查询所有游玩项目
48 49 // @Accept json
49 50 // @Produce json
  51 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
50 52 // @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运"
51 53 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
52 54 // @Router /AllItems? [get]
... ... @@ -54,14 +56,19 @@ func AllItems(c *gin.Context) {
54 56 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
55 57 c.Header("Access-Control-Allow-Credentials", "true")
56 58  
  59 + var ScenicId string
  60 + if ScenicId = c.Query("ScenicId");ScenicId == ""{
  61 + ScenicId = "5e0d504e24e03431008b4567" // 乐岛
  62 + }
  63 +
57 64 var aItems = []DB.SItem{}
58   - cur, err := DB.CItem.Find(tools.GetContext(), bson.M{})
  65 + cur, err := DB.CItem.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId})
59 66 defer cur.Close(tools.GetContext())
60 67 if err == nil {
61 68 for cur.Next(tools.GetContext()) {
62 69 var e DB.SItem
63 70 cur.Decode(&e)
64   - aItems = append(aItems,e)
  71 + aItems = append(aItems, e)
65 72 }
66 73 }
67 74  
... ... @@ -73,6 +80,9 @@ func AllItems(c *gin.Context) {
73 80 // @Description 设备管理 - 更新设施
74 81 // @Accept json
75 82 // @Produce json
  83 +// @Param id 5dfb03070a9ac17ac7a82054 string true "设备id"
  84 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
  85 +// @Param Token wgergejfwe string true "用户token"
76 86 // @Success 200 {object} tools.ResponseSeccess "Tags所属标签,标签有分类;LimitHeight限高;PlayDuration游玩时长;SceneTime场次时间;Picture照片;Voice音频;AverageConsumption平均消费;Menu菜单, OpenHours开放时间: LocationDescription位置描述; Reminder温馨提示; State运行状态0=正常1=停运"
77 87 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
78 88 // @Router /UpdateItem? [post]
... ... @@ -80,6 +90,17 @@ func UpdateItem(c *gin.Context) {
80 90 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
81 91 c.Header("Access-Control-Allow-Credentials", "true")
82 92  
  93 + _user, _ := c.Get("UserInfo")
  94 + user := _user.(*DB.SMember)
  95 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  96 + if err != nil {
  97 + c.JSON(200, tools.ResponseError{
  98 + 401,
  99 + "没有权限",
  100 + })
  101 + return
  102 + }
  103 +
83 104 var Location DB.SLocation
84 105 json.Unmarshal([]byte(c.PostForm("Location")), &Location)
85 106  
... ... @@ -93,7 +114,7 @@ func UpdateItem(c *gin.Context) {
93 114 if pid := c.PostForm("id"); pid == "null" {
94 115 id = primitive.NewObjectID()
95 116 } else {
96   - id,_ = primitive.ObjectIDFromHex(pid)
  117 + id, _ = primitive.ObjectIDFromHex(pid)
97 118 }
98 119  
99 120 poststate, _ := strconv.Atoi(c.PostForm("State"))
... ... @@ -104,6 +125,7 @@ func UpdateItem(c *gin.Context) {
104 125 bson.M{"$set": bson.M{
105 126 "Name": c.PostForm("Name"),
106 127 "SubName": c.PostForm("SubName"),
  128 + "ScenicId": c.PostForm("ScenicId"),
107 129 "Location": Location,
108 130 "Icon": c.PostForm("Icon"),
109 131 "LimitHeight": c.PostForm("LimitHeight"),
... ... @@ -124,24 +146,21 @@ func UpdateItem(c *gin.Context) {
124 146 },
125 147 )
126 148  
127   -
128   -
129 149 // 更新等待时间
130 150 allteim := DB.Redis.Get("AllItemTime")
131   - jsond,_ := json.Marshal(allteim)
  151 + jsond, _ := json.Marshal(allteim)
132 152  
133 153 var ItemTime map[string]string
134 154 json.Unmarshal([]byte(jsond), &ItemTime)
135 155  
136   - if poststate == 1{
  156 + if poststate == 1 {
137 157 ItemTime[c.PostForm("id")] = "--"
138 158 }
139   - if poststate == 0{
  159 + if poststate == 0 {
140 160 ItemTime[c.PostForm("id")] = "0"
141 161 }
142 162 DB.Redis.Set("AllItemTime", ItemTime, time.Second*60*60*24*30)
143 163  
144   -
145 164 c.JSON(200, tools.ResponseSeccess{
146 165 0,
147 166 "ok",
... ... @@ -158,6 +177,8 @@ type ItemTime struct {
158 177 // @Description 设备管理 - 更新等待时间
159 178 // @Accept json
160 179 // @Produce json
  180 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
  181 +// @Param Token wgergejfwe string true "用户token"
161 182 // @Param item [{"id":"5df864740a9ac17ac7a7feb8","time":"20"},{"id":"5df8660924e03417008b4567","time":"33"}] string true "设备列表"
162 183 // @Success 200 {object} tools.ResponseSeccess "{errcode: 0, result: "ok"}"
163 184 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
... ... @@ -166,6 +187,17 @@ func UpdateItemTime(c *gin.Context) {
166 187 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
167 188 c.Header("Access-Control-Allow-Credentials", "true")
168 189  
  190 + _user, _ := c.Get("UserInfo")
  191 + user := _user.(*DB.SMember)
  192 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  193 + if err != nil {
  194 + c.JSON(200, tools.ResponseError{
  195 + 401,
  196 + "没有权限",
  197 + })
  198 + return
  199 + }
  200 +
169 201 var ItemTime []ItemTime
170 202 json.Unmarshal([]byte(c.PostForm("items")), &ItemTime)
171 203  
... ... @@ -174,7 +206,7 @@ func UpdateItemTime(c *gin.Context) {
174 206 RedisData[v.Id] = v.Time
175 207 }
176 208  
177   - DB.Redis.Set("AllItemTime", RedisData, time.Second*60*60*24*30)
  209 + DB.Redis.Set("AllItemTime_"+c.PostForm("ScenicId"), RedisData, time.Second*60*60*24*30)
178 210 c.JSON(200, tools.ResponseSeccess{
179 211 0,
180 212 "ok",
... ... @@ -185,6 +217,7 @@ func UpdateItemTime(c *gin.Context) {
185 217 // @Description 设备管理 - 获得所有设备的等待时间
186 218 // @Accept json
187 219 // @Produce json
  220 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
188 221 // @Success 200 {object} tools.ResponseSeccess "{5df864740a9ac17ac7a7feb8: '20',.....}"
189 222 // @Failure 500 {object} tools.ResponseError "{}"
190 223 // @Router /AllItemTime? [get]
... ... @@ -192,25 +225,16 @@ func AllItemTime(c *gin.Context) {
192 225 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
193 226 c.Header("Access-Control-Allow-Credentials", "true")
194 227  
  228 + var ScenicId string
  229 + if ScenicId = c.Query("ScenicId");ScenicId == ""{
  230 + ScenicId = "5e0d504e24e03431008b4567" // 乐岛
  231 + }
195 232  
196   - //Device := DB.SDevice{
197   - // c.Request.Header.Get("DeviceId"),
198   - // c.Request.Header.Get("Mac"),
199   - // c.Request.Header.Get("UDID"),
200   - // c.Request.Header.Get("SystemVersion"),
201   - // c.Request.Header.Get("SystemModel"),
202   - // c.Request.Header.Get("AppVersion"),
203   - // c.Request.Header.Get("AppVersion"),
204   - // c.Request.Header.Get("DeviceToken"),
205   - //}
206   - //spew.Dump(Device)
207   -
208   -
209   - allteim := DB.Redis.Get("AllItemTime")
  233 + allteim := DB.Redis.Get("AllItemTime_" + ScenicId)
210 234 if allteim != nil {
211 235 c.JSON(200, allteim)
212 236 } else {
213 237 c.String(200, "{}")
214 238 }
215 239  
216   -}
217 240 \ No newline at end of file
  241 +}
... ...
API/Line.go
... ... @@ -8,6 +8,7 @@ import (
8 8 "go.mongodb.org/mongo-driver/bson/primitive"
9 9 "go.mongodb.org/mongo-driver/mongo/options"
10 10 "letu/DB"
  11 + "letu/Lib/Auth"
11 12 )
12 13  
13 14 // @Title 查询线路信息
... ... @@ -52,14 +53,19 @@ func AllLine(c *gin.Context) {
52 53 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
53 54 c.Header("Access-Control-Allow-Credentials", "true")
54 55  
  56 + var ScenicId string
  57 + if ScenicId = c.Query("ScenicId");ScenicId == ""{
  58 + ScenicId = "5e0d504e24e03431008b4567" // 乐岛
  59 + }
  60 +
55 61 var aLine []DB.SLine
56   - cur, err := DB.CLine.Find(tools.GetContext(), bson.M{})
  62 + cur, err := DB.CLine.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId})
57 63 defer cur.Close(tools.GetContext())
58 64 if err == nil {
59 65 for cur.Next(tools.GetContext()) {
60 66 var e DB.SLine
61 67 cur.Decode(&e)
62   - aLine = append(aLine,e)
  68 + aLine = append(aLine, e)
63 69 }
64 70 }
65 71  
... ... @@ -71,13 +77,29 @@ func AllLine(c *gin.Context) {
71 77 // @Description 更新线路
72 78 // @Accept json
73 79 // @Produce json
  80 +// @Param id 5dfb03070a9ac17ac7a82054 string true "线路id"
  81 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
  82 +// @Param Token wgergejfwe string true "用户token"
74 83 // @Success 200 {object} tools.ResponseSeccess ""
75 84 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
76 85 // @Router /UpdateLine? [post]
77 86 func UpdateLine(c *gin.Context) {
  87 +
78 88 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
79 89 c.Header("Access-Control-Allow-Credentials", "true")
80 90  
  91 + _user, _ := c.Get("UserInfo")
  92 + user := _user.(*DB.SMember)
  93 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  94 + if err != nil {
  95 + c.JSON(200, tools.ResponseError{
  96 + 401,
  97 + "没有权限",
  98 + })
  99 + return
  100 + }
  101 +
  102 +
81 103 var Location []DB.SLocation
82 104 json.Unmarshal([]byte(c.PostForm("Location")), &Location)
83 105  
... ... @@ -88,7 +110,7 @@ func UpdateLine(c *gin.Context) {
88 110 if pid := c.PostForm("id"); pid == "null" {
89 111 id = primitive.NewObjectID()
90 112 } else {
91   - id,_ = primitive.ObjectIDFromHex(pid)
  113 + id, _ = primitive.ObjectIDFromHex(pid)
92 114 }
93 115  
94 116 upsert := true
... ...
API/Operator.go 0 → 100644
... ... @@ -0,0 +1,188 @@
  1 +package Api
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "github.com/aarongao/tools"
  6 + "github.com/gin-gonic/gin"
  7 + "go.mongodb.org/mongo-driver/bson"
  8 + "go.mongodb.org/mongo-driver/bson/primitive"
  9 + "letu/DB"
  10 + "letu/Lib/Auth"
  11 + "letu/Lib/JWT"
  12 + "time"
  13 +)
  14 +
  15 +// @Title 登录
  16 +// @Description 操作员管理 - 操作员登录
  17 +// @Accept json
  18 +// @Produce json
  19 +// @Param Username aaron string true "用户名"
  20 +// @Param Password 123 string true "密码"
  21 +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间"
  22 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  23 +// @Router /LoginOperator? [post]
  24 +func LoginOperator(c *gin.Context) {
  25 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  26 + c.Header("Access-Control-Allow-Credentials", "true")
  27 +
  28 + selected := bson.M{}
  29 + var User *DB.SMember
  30 + if c.PostForm("Username") != "" && c.PostForm("Password") != "" {
  31 + selected["Username"] = c.PostForm("Username")
  32 + selected["Password"] = c.PostForm("Password")
  33 + DB.CMember.FindOne(tools.GetContext(), selected).Decode(&User)
  34 +
  35 + if User == nil {
  36 + c.JSON(200, tools.ResponseError{
  37 + 1,
  38 + "用户不存在",
  39 + })
  40 + return
  41 + }
  42 +
  43 + } else {
  44 + c.JSON(200, tools.ResponseError{
  45 + 1,
  46 + "不能为空",
  47 + })
  48 + return
  49 + }
  50 +
  51 + // 生成token
  52 + dd, _ := time.ParseDuration("8760h")
  53 + User.Token, _ = JWT.CreateToken(User, time.Now().Add(dd).Unix())
  54 + c.JSON(200, tools.ResponseSeccess{
  55 + 0,
  56 + User,
  57 + })
  58 +
  59 +}
  60 +
  61 +// @Title 操作员管理
  62 +// @Description 操作员管理 - 修改用户信息
  63 +// @Accept json
  64 +// @Produce json
  65 +// @Param id aaron string true "用户id""
  66 +// @Param ScenicId 5e0d504e24e03431008b4567 string true "景区id"
  67 +// @Param Token wgergejfwe string true "用户token"
  68 +// @Param Username aarongao string true "用户名"
  69 +// @Param Remarks 18616619599 string true "备注"
  70 +// @Param Password 12345 string true "密码"
  71 +// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}"
  72 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  73 +// @Router /UpdateOperator? [post]
  74 +func UpdateOperator(c *gin.Context) {
  75 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  76 + c.Header("Access-Control-Allow-Credentials", "true")
  77 +
  78 + _user, _ := c.Get("UserInfo")
  79 + user := _user.(*DB.SMember)
  80 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  81 + if err != nil {
  82 + c.JSON(200, tools.ResponseError{
  83 + 401,
  84 + "没有权限",
  85 + })
  86 + return
  87 + }
  88 +
  89 + var _auth []string
  90 + json.Unmarshal([]byte(c.PostForm("Auth")), &_auth)
  91 +
  92 + objID, err := primitive.ObjectIDFromHex(c.PostForm("id"))
  93 + if err == nil {
  94 +
  95 + _, err = DB.CMember.UpdateOne(tools.GetContext(),
  96 + bson.M{"_id": objID},
  97 + bson.M{"$set": bson.M{
  98 + "Auth": _auth,
  99 + "Username": c.PostForm("Username"),
  100 + "Password": c.PostForm("Password"),
  101 + "Remarks": c.PostForm("Remarks"),
  102 + }},
  103 + )
  104 + } else {
  105 +
  106 + objectID := primitive.NewObjectID()
  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"),
  122 + }
  123 +
  124 + // 生成token
  125 + var dd time.Duration
  126 + dd, err = time.ParseDuration("20m")
  127 + User.Token, _ = JWT.CreateToken(User, time.Now().Add(dd).Unix())
  128 +
  129 + DB.CMember.InsertOne(tools.GetContext(), User)
  130 +
  131 + }
  132 +
  133 + if err == nil {
  134 + c.JSON(200, tools.ResponseSeccess{
  135 + 0,
  136 + "ok",
  137 + })
  138 + } else {
  139 + c.JSON(200, tools.ResponseError{
  140 + 1,
  141 + err.Error(),
  142 + })
  143 + }
  144 +
  145 +}
  146 +
  147 +// @Title 操作员管理
  148 +// @Description 操作员管理 - 所有操作员
  149 +// @Accept json
  150 +// @Produce json
  151 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
  152 +// @Param Token 5dfb03070a9ac17ac7a82054 string true "用户token"
  153 +// @Success 200 {object} tools.ResponseSeccess ""
  154 +// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
  155 +// @Router /AllOperator? [get]
  156 +func AllOperator(c *gin.Context) {
  157 + c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
  158 + c.Header("Access-Control-Allow-Credentials", "true")
  159 + _user, _ := c.Get("UserInfo")
  160 + user := _user.(*DB.SMember)
  161 + err := Auth.CheckScenicAuth(c.Query("ScenicId"), user)
  162 + if err != nil {
  163 + c.JSON(200, tools.ResponseError{
  164 + 401,
  165 + "没有权限",
  166 + })
  167 + return
  168 + }
  169 +
  170 + var aMember []*DB.SMember
  171 + cur, err := DB.CMember.Find(tools.GetContext(), bson.M{"ScenicId": c.Query("ScenicId"), "UserType": "operator"})
  172 + defer cur.Close(tools.GetContext())
  173 + if err == nil {
  174 + for cur.Next(tools.GetContext()) {
  175 + var e *DB.SMember
  176 + cur.Decode(&e)
  177 + aMember = append(aMember, e)
  178 + }
  179 + }
  180 +
  181 + if aMember == nil {
  182 + aMember = []*DB.SMember{}
  183 + }
  184 + c.JSON(200, tools.ResponseSeccess{
  185 + 0,
  186 + aMember,
  187 + })
  188 +}
... ...
API/Scenic.go
... ... @@ -8,6 +8,7 @@ import (
8 8 "go.mongodb.org/mongo-driver/bson/primitive"
9 9 "go.mongodb.org/mongo-driver/mongo/options"
10 10 "letu/DB"
  11 + "letu/Lib/Auth"
11 12 )
12 13  
13 14 // @Title 返回景区基础信息
... ... @@ -46,6 +47,7 @@ func ScenicInfo(c *gin.Context) {
46 47 // @Accept json
47 48 // @Produce json
48 49 // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id"
  50 +// @Param Token wgergejfwe string true "用户token"
49 51 // @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片);InvestigationUrl问券调查的url;RangeLocation景区范围(多个坐标点)"
50 52 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
51 53 // @Router /UpdateScenic? [post]
... ... @@ -53,6 +55,18 @@ func UpdateScenic(c *gin.Context) {
53 55 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
54 56 c.Header("Access-Control-Allow-Credentials", "true")
55 57  
  58 + _user, _ := c.Get("UserInfo")
  59 + user := _user.(*DB.SMember)
  60 + err := Auth.CheckScenicAuth(c.PostForm("id"), user)
  61 + if err != nil {
  62 + c.JSON(200, tools.ResponseError{
  63 + 401,
  64 + "没有权限",
  65 + })
  66 + return
  67 + }
  68 +
  69 +
56 70 var Location DB.SLocation
57 71 json.Unmarshal([]byte(c.PostForm("Location")), &Location)
58 72  
... ...
API/Shop.go
... ... @@ -8,6 +8,7 @@ import (
8 8 "go.mongodb.org/mongo-driver/bson/primitive"
9 9 "go.mongodb.org/mongo-driver/mongo/options"
10 10 "letu/DB"
  11 + "letu/Lib/Auth"
11 12 )
12 13  
13 14 // @Title 查询商品信息
... ... @@ -45,6 +46,7 @@ func CommodityInfo(c *gin.Context) {
45 46 // @Description 查询所有商品
46 47 // @Accept json
47 48 // @Produce json
  49 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
48 50 // @Success 200 {object} tools.ResponseSeccess "Price=价格;ShopName=店铺名称;KvPhoto用于列表页的图片;TopPhoto详情页最上面的轮播图;Images详情页下面的产品详细图"
49 51 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
50 52 // @Router /AllCommodity? [get]
... ... @@ -52,14 +54,19 @@ func AllCommodity(c *gin.Context) {
52 54 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
53 55 c.Header("Access-Control-Allow-Credentials", "true")
54 56  
  57 + var ScenicId string
  58 + if ScenicId = c.Query("ScenicId");ScenicId == ""{
  59 + ScenicId = "5e0d504e24e03431008b4567" // 乐岛
  60 + }
  61 +
55 62 var aCommoditys []DB.SCommodity
56   - cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{})
  63 + cur, err := DB.CCommodity.Find(tools.GetContext(), bson.M{"ScenicId": ScenicId})
57 64 defer cur.Close(tools.GetContext())
58 65 if err == nil {
59 66 for cur.Next(tools.GetContext()) {
60 67 var e DB.SCommodity
61 68 cur.Decode(&e)
62   - aCommoditys = append(aCommoditys,e)
  69 + aCommoditys = append(aCommoditys, e)
63 70 }
64 71 }
65 72  
... ... @@ -71,6 +78,8 @@ func AllCommodity(c *gin.Context) {
71 78 // @Description 更新商品
72 79 // @Accept json
73 80 // @Produce json
  81 +// @Param ScenicId 5dfb03070a9ac17ac7a82054 string true "景区id"
  82 +// @Param Token wgergejfwe string true "用户token"
74 83 // @Success 200 {object} tools.ResponseSeccess ""
75 84 // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}"
76 85 // @Router /UpdateCommodity? [post]
... ... @@ -78,6 +87,17 @@ func UpdateCommodity(c *gin.Context) {
78 87 c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))
79 88 c.Header("Access-Control-Allow-Credentials", "true")
80 89  
  90 + _user, _ := c.Get("UserInfo")
  91 + user := _user.(*DB.SMember)
  92 + err := Auth.CheckScenicAuth(c.PostForm("ScenicId"), user)
  93 + if err != nil {
  94 + c.JSON(200, tools.ResponseError{
  95 + 401,
  96 + "没有权限",
  97 + })
  98 + return
  99 + }
  100 +
81 101 var Picture []string
82 102 json.Unmarshal([]byte(c.PostForm("Images")), &Picture)
83 103  
... ... @@ -87,12 +107,11 @@ func UpdateCommodity(c *gin.Context) {
87 107 //var Location DB.SLocation
88