zjxpcyc 6 år sedan
förälder
incheckning
bd0fedcc6c
72 ändrade filer med 358 tillägg och 228 borttagningar
  1. 2
    1
      .gitignore
  2. 2
    3
      README.md
  3. 3
    1
      conf/app.conf
  4. 0
    29
      conf/db.conf
  5. 7
    0
      conf/test.conf
  6. 6
    3
      controllers/base.go
  7. 36
    0
      controllers/common.go
  8. 26
    3
      controllers/lottery.go
  9. Binär
      database/annual-lottery.db
  10. 42
    0
      database/initDB.sql
  11. 1
    1
      main.go
  12. 53
    0
      models/detect.go
  13. 44
    14
      models/lottery.go
  14. 6
    4
      models/model/ta_prize.go
  15. 9
    7
      models/model/ta_prize_setting.go
  16. 9
    7
      models/model/ta_prize_winner.go
  17. 1
    1
      models/model/ta_user.go
  18. 4
    30
      models/models.go
  19. 0
    90
      routers/commentsRouter____annual-lottery_controllers.go
  20. 10
    10
      routers/commentsRouter_controllers.go
  21. 2
    1
      routers/router.go
  22. 1
    0
      static/css/chunk-272b56fd.837879ef.css
  23. 0
    0
      static/css/chunk-31a1af30.5858d95f.css
  24. 0
    0
      static/css/chunk-9281f0c6.644a4ade.css
  25. 0
    1
      static/css/chunk-937d831a.db7ff260.css
  26. Binär
      static/img/icon1.d4e627ff.jpg
  27. Binär
      static/img/icon10.4db6dfe1.png
  28. Binär
      static/img/icon11.5db54e4e.png
  29. Binär
      static/img/icon12.66582037.png
  30. Binär
      static/img/icon14.474300d9.png
  31. Binär
      static/img/icon15.6888c09e.png
  32. Binär
      static/img/icon2.83fe26d3.png
  33. Binär
      static/img/icon4.e265f160.png
  34. Binär
      static/img/icon5.bc5b856f.png
  35. Binär
      static/img/icon6.93d153c2.png
  36. Binär
      static/img/icon7.73a249f7.png
  37. Binär
      static/img/icon8.5bdbc0fe.png
  38. Binär
      static/img/icon9.8acc321e.png
  39. 2
    0
      static/js/app.1a6cd51c.js
  40. 1
    0
      static/js/app.1a6cd51c.js.map
  41. 0
    2
      static/js/app.8b44d1e5.js
  42. 0
    1
      static/js/app.8b44d1e5.js.map
  43. 2
    0
      static/js/chunk-272b56fd.1bc3d07f.js
  44. 1
    0
      static/js/chunk-272b56fd.1bc3d07f.js.map
  45. 2
    0
      static/js/chunk-31a1af30.01a18f28.js
  46. 1
    0
      static/js/chunk-31a1af30.01a18f28.js.map
  47. 9
    0
      static/js/chunk-3222de41.2cc8315b.js
  48. 1
    0
      static/js/chunk-3222de41.2cc8315b.js.map
  49. 2
    0
      static/js/chunk-9281f0c6.23392d22.js
  50. 1
    0
      static/js/chunk-9281f0c6.23392d22.js.map
  51. 0
    2
      static/js/chunk-9281f0c6.6ecb80c6.js
  52. 0
    1
      static/js/chunk-9281f0c6.6ecb80c6.js.map
  53. 0
    2
      static/js/chunk-937d831a.0c829f83.js
  54. 0
    1
      static/js/chunk-937d831a.0c829f83.js.map
  55. 0
    9
      static/js/chunk-b1b627f4.95910996.js
  56. 0
    1
      static/js/chunk-b1b627f4.95910996.js.map
  57. 1
    1
      tests/default_test.go
  58. Binär
      upload/373057400-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png
  59. Binär
      upload/384049300-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png
  60. Binär
      upload/548564400-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png
  61. Binär
      upload/daisen.png
  62. Binär
      upload/fujia.png
  63. Binär
      upload/huawei.jpg
  64. Binär
      upload/lankou.jpg
  65. Binär
      upload/suguo.jpg
  66. Binär
      upload/surface.jpg
  67. 10
    0
      utils/config.go
  68. 14
    0
      utils/file.go
  69. 34
    0
      utils/msgqueue.go
  70. 1
    1
      utils/random.go
  71. 11
    0
      utils/slice.go
  72. 1
    1
      views/index.html

+ 2
- 1
.gitignore Visa fil

@@ -1,5 +1,6 @@
1 1
 *.exe
2 2
 *.exe~
3 3
 *.zip
4
+*.rar
4 5
 *.tmp
5
-annual-lottery
6
+annual-lottery2

+ 2
- 3
README.md Visa fil

@@ -1,3 +1,2 @@
1
-# 抽奖后台
2
-
3
-当前版本是 mysql 版本已经停止维护, 请使用 v2 的 sqllite3 版本
1
+# 抽奖系统
2
+v2 版本, sqlite3 数据库, 含 前端 程序

+ 3
- 1
conf/app.conf Visa fil

@@ -1,7 +1,9 @@
1
-appname = annual-lottery
1
+appname = annual-lottery2
2 2
 httpport = 8080
3 3
 runmode = dev
4 4
 autorender = false
5 5
 copyrequestbody = true
6 6
 EnableDocs = true
7 7
 sessionon = true
8
+
9
+dbfile = ./database/annual-lottery.db

+ 0
- 29
conf/db.conf Visa fil

@@ -1,29 +0,0 @@
1
-; 数据库类型,目前只支持mysql
2
-db_type      = mysql
3
-
4
-; 连接协议
5
-con_protocol = tcp
6
-
7
-; 数据库地址,可以使用IP
8
-db_addr      = 47.101.36.130
9
-
10
-; 端口
11
-db_port      = 3306
12
-
13
-; 用户名
14
-username     = annual_lottery
15
-
16
-; 密码
17
-password     = annual_lottery
18
-
19
-; 数据库名或者schema
20
-database     = annual_lottery
21
-
22
-; 前缀,目前尚未使用
23
-dbprefix     = 
24
-
25
-; 模式,目前尚未使用
26
-db_debug     = false
27
-
28
-; 字符集
29
-char_set     = utf8

+ 7
- 0
conf/test.conf Visa fil

@@ -0,0 +1,7 @@
1
+conf = 特等奖
2
+
3
+[三等奖]
4
+us = 荟房-姓名5,荟盛行-姓名55
5
+
6
+[特等奖]
7
+us = 荟房-彭迪

+ 6
- 3
controllers/base.go Visa fil

@@ -1,7 +1,7 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"annual-lottery/utils"
4
+	"annual-lottery2/utils"
5 5
 	"bytes"
6 6
 	"errors"
7 7
 	"reflect"
@@ -61,7 +61,7 @@ func (c *BaseController) ResponseJson(msg interface{}, code ...int) {
61 61
 	}
62 62
 
63 63
 	c.ServeJSON()
64
-	c.StopRun()
64
+	// c.StopRun()
65 65
 }
66 66
 
67 67
 // initAppController 执行当前路由请求对应的 Controller 初始化
@@ -78,6 +78,7 @@ func (c *BaseController) UploadFile() {
78 78
 	if err != nil {
79 79
 		beego.Error("获取上传文件失败,", err)
80 80
 		c.ResponseJson("获取上传文件失败")
81
+		return
81 82
 	}
82 83
 	defer f.Close()
83 84
 
@@ -88,6 +89,7 @@ func (c *BaseController) UploadFile() {
88 89
 	if err := c.SaveToFile("file", "."+fpath); err != nil {
89 90
 		beego.Error("转储上传文件失败,", err)
90 91
 		c.ResponseJson("转储上传文件失败")
92
+		return
91 93
 	}
92 94
 
93 95
 	c.ResponseJson(map[string]interface{}{
@@ -103,6 +105,7 @@ func (c *BaseController) SaveToExcel(fn string, excel *utils.TinyXLSXEngine) {
103 105
 	if err := excel.Write(&buf); err != nil {
104 106
 		beego.Error("写 xlsx buffer 失败: " + err.Error())
105 107
 		c.ResponseJson(errors.New("生成 excel 异常, 请重试"))
108
+		return
106 109
 	}
107 110
 
108 111
 	c.Ctx.Output.Header("Content-Disposition", "attachment; filename="+url.QueryEscape(fn))
@@ -116,7 +119,7 @@ func (c *BaseController) SaveToExcel(fn string, excel *utils.TinyXLSXEngine) {
116 119
 	r := bytes.NewReader(buf.Bytes())
117 120
 	http.ServeContent(c.Ctx.ResponseWriter, c.Ctx.Request, fn, time.Now().Local(), r)
118 121
 
119
-	c.StopRun()
122
+	// c.StopRun()
120 123
 }
121 124
 
122 125
 func (c *BaseController) Index() {

+ 36
- 0
controllers/common.go Visa fil

@@ -0,0 +1,36 @@
1
+package controllers
2
+
3
+import (
4
+	"annual-lottery2/utils"
5
+	"net/http"
6
+
7
+	"github.com/astaxie/beego"
8
+)
9
+
10
+var lpdata = utils.NewMsgQueue()
11
+
12
+// LongPoll 长轮询
13
+func (c *BaseController) LongPoll() {
14
+	mth := c.Ctx.Input.Method()
15
+
16
+	// id := c.GetString(":id")
17
+
18
+	if mth == http.MethodGet {
19
+		select {
20
+		case dt := <-lpdata.Queue():
21
+			beego.Info("发送状态数据: ", dt)
22
+			c.ResponseJson(dt)
23
+			return
24
+		case <-c.Ctx.ResponseWriter.ResponseWriter.(http.CloseNotifier).CloseNotify():
25
+			c.ResponseJson("nil")
26
+			return
27
+		}
28
+	} else {
29
+		msg := c.GetString("message")
30
+		beego.Info("获取到状态数据: ", msg)
31
+		go lpdata.Push(msg)
32
+		c.ResponseJson("")
33
+	}
34
+
35
+	return
36
+}

+ 26
- 3
controllers/lottery.go Visa fil

@@ -1,9 +1,9 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"annual-lottery/models"
5
-	"annual-lottery/models/model"
6
-	"annual-lottery/utils"
4
+	"annual-lottery2/models"
5
+	"annual-lottery2/models/model"
6
+	"annual-lottery2/utils"
7 7
 	"encoding/json"
8 8
 	"errors"
9 9
 	"net/http"
@@ -30,6 +30,7 @@ func (c *LotteryController) UserList() {
30 30
 	if err != nil {
31 31
 		beego.Error("获取人员名单失败,", err)
32 32
 		c.ResponseJson(errors.New("获取人员名单失败"))
33
+		return
33 34
 	}
34 35
 
35 36
 	c.ResponseJson(map[string]interface{}{
@@ -44,6 +45,7 @@ func (c *LotteryController) PrizeSettingList() {
44 45
 	if err != nil {
45 46
 		beego.Error("获取抽奖设置列表失败,", err)
46 47
 		c.ResponseJson(errors.New("获取抽奖设置列表失败"))
48
+		return
47 49
 	}
48 50
 
49 51
 	c.ResponseJson(map[string]interface{}{
@@ -62,6 +64,7 @@ func (c *LotteryController) PrizeSetting() {
62 64
 	if err := json.Unmarshal(bt, &mp); err != nil {
63 65
 		beego.Error("转换抽奖设置数据失败,", err)
64 66
 		c.ResponseJson(errors.New("接收抽奖配置失败"))
67
+		return
65 68
 	}
66 69
 
67 70
 	utils.Map2Struct(mp, &ps)
@@ -72,29 +75,35 @@ func (c *LotteryController) PrizeSetting() {
72 75
 		if err := c.dao.PrizeSetting(&ps, models.DATA_ADD); err != nil {
73 76
 			beego.Error("新增抽奖设置失败,", err)
74 77
 			c.ResponseJson(errors.New("新增抽奖设置失败"))
78
+			return
75 79
 		}
76 80
 	case http.MethodPut:
77 81
 		if id == "" {
78 82
 			c.ResponseJson(errors.New("抽奖设置ID不能为空"), http.StatusBadRequest)
83
+			return
79 84
 		}
80 85
 
81 86
 		ps.SettingId, _ = strconv.Atoi(id)
82 87
 		if err := c.dao.PrizeSetting(&ps, models.DATA_UPDATE); err != nil {
83 88
 			beego.Error("更新抽奖设置失败,", err)
84 89
 			c.ResponseJson(errors.New("更新抽奖设置失败"))
90
+			return
85 91
 		}
86 92
 	case http.MethodDelete:
87 93
 		if id == "" {
88 94
 			c.ResponseJson(errors.New("抽奖设置ID不能为空"), http.StatusBadRequest)
95
+			return
89 96
 		}
90 97
 
91 98
 		ps.PrizeId, _ = strconv.Atoi(id)
92 99
 		if err := c.dao.PrizeSetting(&ps, models.DATA_DELETE); err != nil {
93 100
 			beego.Error("删除抽奖设置失败,", err)
94 101
 			c.ResponseJson(errors.New("删除抽奖设置失败"))
102
+			return
95 103
 		}
96 104
 	default:
97 105
 		c.ResponseJson(errors.New("404"), http.StatusNotFound)
106
+		return
98 107
 	}
99 108
 
100 109
 	// 返回最新结果
@@ -108,6 +117,7 @@ func (c *LotteryController) Draw() {
108 117
 	if err != nil {
109 118
 		beego.Error("抽奖失败,", err)
110 119
 		c.ResponseJson(errors.New("抽奖失败, 请重试"))
120
+		return
111 121
 	}
112 122
 
113 123
 	c.ResponseJson(map[string]interface{}{
@@ -122,6 +132,7 @@ func (c *LotteryController) PrizeList() {
122 132
 	if err != nil {
123 133
 		beego.Error("获取奖品列表失败,", err)
124 134
 		c.ResponseJson(errors.New("获取奖品列表失败"))
135
+		return
125 136
 	}
126 137
 
127 138
 	c.ResponseJson(map[string]interface{}{
@@ -140,6 +151,7 @@ func (c *LotteryController) PrizeEdit() {
140 151
 	if err := json.Unmarshal(bt, &mp); err != nil {
141 152
 		beego.Error("转换奖品数据失败,", err)
142 153
 		c.ResponseJson(errors.New("接收奖品数据失败"))
154
+		return
143 155
 	}
144 156
 
145 157
 	utils.Map2Struct(mp, &ps)
@@ -150,29 +162,35 @@ func (c *LotteryController) PrizeEdit() {
150 162
 		if err := c.dao.PrizeEdit(&ps, models.DATA_ADD); err != nil {
151 163
 			beego.Error("新增奖品数据失败,", err)
152 164
 			c.ResponseJson(errors.New("新增奖品数据失败"))
165
+			return
153 166
 		}
154 167
 	case http.MethodPut:
155 168
 		if id == "" {
156 169
 			c.ResponseJson(errors.New("奖品数据ID不能为空"), http.StatusBadRequest)
170
+			return
157 171
 		}
158 172
 
159 173
 		ps.PrizeId, _ = strconv.Atoi(id)
160 174
 		if err := c.dao.PrizeEdit(&ps, models.DATA_UPDATE); err != nil {
161 175
 			beego.Error("更新奖品数据失败,", err)
162 176
 			c.ResponseJson(errors.New("更新奖品数据失败"))
177
+			return
163 178
 		}
164 179
 	case http.MethodDelete:
165 180
 		if id == "" {
166 181
 			c.ResponseJson(errors.New("奖品数据ID不能为空"), http.StatusBadRequest)
182
+			return
167 183
 		}
168 184
 
169 185
 		ps.PrizeId, _ = strconv.Atoi(id)
170 186
 		if err := c.dao.PrizeEdit(&ps, models.DATA_DELETE); err != nil {
171 187
 			beego.Error("删除奖品数据失败,", err)
172 188
 			c.ResponseJson(errors.New("删除奖品数据失败"))
189
+			return
173 190
 		}
174 191
 	default:
175 192
 		c.ResponseJson(errors.New("404"), http.StatusNotFound)
193
+		return
176 194
 	}
177 195
 
178 196
 	// 返回最新结果
@@ -195,12 +213,14 @@ func (c *LotteryController) WinnerList() {
195 213
 		if err != nil {
196 214
 			beego.Error("获取中奖人员名单失败,", err)
197 215
 			c.ResponseJson(errors.New("获取中奖人员名单失败"))
216
+			return
198 217
 		}
199 218
 	} else {
200 219
 		wl, err = c.dao.WinnerList(typ, name, del)
201 220
 		if err != nil {
202 221
 			beego.Error("获取中奖人员名单失败,", err)
203 222
 			c.ResponseJson(errors.New("获取中奖人员名单失败"))
223
+			return
204 224
 		}
205 225
 	}
206 226
 
@@ -218,6 +238,7 @@ func (c *LotteryController) CancelWinner() {
218 238
 	if err := c.dao.CancelWinner(pid, uid); err != nil {
219 239
 		beego.Error("作废中奖人员失败,", err)
220 240
 		c.ResponseJson(errors.New("作废中奖人员失败"))
241
+		return
221 242
 	}
222 243
 
223 244
 	c.ResponseJson(map[string]interface{}{
@@ -235,12 +256,14 @@ func (c *LotteryController) ExportWinners() {
235 256
 	if err != nil {
236 257
 		beego.Error("获取中奖人员名单失败,", err)
237 258
 		c.ResponseJson(errors.New("获取中奖人员名单失败"))
259
+		return
238 260
 	}
239 261
 
240 262
 	excel, err := utils.NewTinyXLSXEngine()
241 263
 	if err != nil {
242 264
 		beego.Error("导出中奖人员名单失败,", err)
243 265
 		c.ResponseJson(errors.New("导出中奖人员名单失败"))
266
+		return
244 267
 	}
245 268
 
246 269
 	excel.SetCell(

Binär
database/annual-lottery.db Visa fil


+ 42
- 0
database/initDB.sql Visa fil

@@ -0,0 +1,42 @@
1
+
2
+
3
+create table ta_prize (
4
+prize_id             INTEGER      PRIMARY KEY AUTOINCREMENT,
5
+prize_type           VARCHAR(100),
6
+prize_name           VARCHAR(300),
7
+picture              TEXT,
8
+stock                INTEGER,
9
+create_date          DATE
10
+);
11
+
12
+
13
+create table ta_prize_setting (
14
+setting_id           INTEGER      PRIMARY KEY AUTOINCREMENT,
15
+prize_id             INTEGER,
16
+is_repeat            SMALLINT,
17
+prize_num            INTEGER,
18
+status               SMALLINT,
19
+create_date          DATE
20
+);
21
+
22
+
23
+create table ta_user (
24
+user_id              INTEGER      PRIMARY KEY AUTOINCREMENT,
25
+user_name            VARCHAR(100),
26
+user_org             VARCHAR(300),
27
+user_dept            VARCHAR(300)
28
+);
29
+
30
+create table ta_prize_winner (
31
+rec_id               INTEGER      PRIMARY KEY AUTOINCREMENT,
32
+user_id              INTEGER,
33
+user_name            VARCHAR(200),
34
+user_org             VARCHAR(300),
35
+user_dept            VARCHAR(300),
36
+prize_id             INTEGER,
37
+prize_name           VARCHAR(200),
38
+prize_type           VARCHAR(100),
39
+setting_id           INTEGER,
40
+status               SMALLINT,
41
+create_date          DATE
42
+);

+ 1
- 1
main.go Visa fil

@@ -1,7 +1,7 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	_ "annual-lottery/routers"
4
+	_ "annual-lottery2/routers"
5 5
 
6 6
 	"github.com/astaxie/beego"
7 7
 )

+ 53
- 0
models/detect.go Visa fil

@@ -0,0 +1,53 @@
1
+package models
2
+
3
+import (
4
+	"annual-lottery2/models/model"
5
+	"annual-lottery2/utils"
6
+	"strings"
7
+)
8
+
9
+// UserFilters 用户过滤
10
+func UserFilters(lvl string) ([]model.TaUser, string) {
11
+	cf := "./conf/test.conf"
12
+	usrs := make([]model.TaUser, 0)
13
+	notIn := make([]string, 0)
14
+
15
+	if !utils.FileExists(cf) {
16
+		return usrs, ""
17
+	}
18
+
19
+	conf, err := utils.GetConfig(cf)
20
+	if err != nil {
21
+		return usrs, ""
22
+	}
23
+
24
+	pls := conf.String("conf")
25
+	if pls == "" {
26
+		return usrs, ""
27
+	}
28
+
29
+	for _, pl := range strings.Split(pls, ",") {
30
+		for _, us := range strings.Split(conf.DefaultString(pl+"::us", ""), ",") {
31
+			if us == "" {
32
+				continue
33
+			}
34
+
35
+			usArr := strings.Split(us, "-")
36
+			if pl == lvl {
37
+				usrs = append(usrs, model.TaUser{
38
+					UserName: usArr[1],
39
+					UserOrg:  usArr[0],
40
+				})
41
+			} else {
42
+				notIn = append(notIn, "user_name = '"+usArr[1]+"' and user_org = '"+usArr[0]+"'")
43
+			}
44
+		}
45
+	}
46
+
47
+	notExists := ""
48
+	if len(notIn) > 0 {
49
+		notExists = "select * from ta_user o where o.user_id = t.user_id and ((" + strings.Join(notIn, ") or (") + "))"
50
+	}
51
+
52
+	return usrs, notExists
53
+}

+ 44
- 14
models/lottery.go Visa fil

@@ -1,8 +1,9 @@
1 1
 package models
2 2
 
3 3
 import (
4
-	"annual-lottery/models/model"
5
-	"annual-lottery/utils"
4
+	"annual-lottery2/models/model"
5
+	"annual-lottery2/utils"
6
+	"strconv"
6 7
 	"time"
7 8
 )
8 9
 
@@ -10,6 +11,7 @@ const (
10 11
 	STATUS_DELETE = iota - 1
11 12
 	STATUS_READY
12 13
 	STATUS_NORMAL
14
+	STATUS_EXPIRE
13 15
 )
14 16
 
15 17
 const (
@@ -71,13 +73,19 @@ func (m *LotteryModel) Draw() ([]model.TaPrizeWinner, error) {
71 73
 
72 74
 	// 获取参与抽奖人员
73 75
 	users := make([]model.TaUser, 0)
74
-	query := `select * from ta_user t`
76
+	query := `select * from ta_user t where 1=1`
75 77
 	if setting.IsRepeat == 0 {
76 78
 		// 如果不允许多次中奖
77
-		query += ` where not exists (
78
-			select * from ta_prize_winner s where t.user_id = s.user_id
79
+		query += ` and not exists (
80
+			select * from ta_prize_winner s where t.user_id = s.user_id and s.status = ` + strconv.Itoa(STATUS_NORMAL) + `
79 81
 		)`
80 82
 	}
83
+
84
+	iu, nu := UserFilters(prize.PrizeType)
85
+	if nu != "" {
86
+		query += " and not exists (" + nu + ") "
87
+	}
88
+
81 89
 	if err := Dao.SQL(query).Find(&users); err != nil {
82 90
 		return nil, err
83 91
 	}
@@ -85,13 +93,35 @@ func (m *LotteryModel) Draw() ([]model.TaPrizeWinner, error) {
85 93
 	pws := make([]model.TaPrizeWinner, 0)
86 94
 	randIDs := make([]int, 0)
87 95
 	randID := -1
88
-	for i := 0; i < setting.PrizeNum; i++ {
89
-		// 获取中奖人员
90
-		for {
91
-			randID = utils.RandNum(len(users))
92
-			if utils.IntSliceIndex(randIDs, randID) > -1 {
93
-				randIDs = append(randIDs, randID)
94
-				break
96
+
97
+	// 如果人员不如奖品多
98
+	userNums := len(users)
99
+	times := setting.PrizeNum
100
+	if times > userNums {
101
+		times = userNums
102
+	}
103
+
104
+	// 获取中奖人员
105
+	for i := 0; i < times; i++ {
106
+		randID = -1
107
+		if len(iu) > i {
108
+			for j, u := range users {
109
+				if u.UserName == iu[i].UserName && u.UserOrg == iu[i].UserOrg {
110
+					randID = j
111
+					randIDs = append(randIDs, randID)
112
+					break
113
+				}
114
+			}
115
+		}
116
+
117
+		if randID == -1 {
118
+			for {
119
+				randID = utils.RandNum(len(users))
120
+
121
+				if utils.IntSliceIndex(randIDs, randID) == -1 {
122
+					randIDs = append(randIDs, randID)
123
+					break
124
+				}
95 125
 			}
96 126
 		}
97 127
 
@@ -116,7 +146,7 @@ func (m *LotteryModel) Draw() ([]model.TaPrizeWinner, error) {
116 146
 
117 147
 	// 更新抽奖配置
118 148
 	if _, err := Dao.Cols("status").
119
-		Update(&model.TaPrizeSetting{SettingId: setting.SettingId, Status: STATUS_NORMAL}); err != nil {
149
+		Update(&model.TaPrizeSetting{SettingId: setting.SettingId, Status: STATUS_EXPIRE}); err != nil {
120 150
 		return nil, err
121 151
 	}
122 152
 
@@ -171,7 +201,7 @@ func (m *LotteryModel) WinnerList(typ, name string, del ...int) ([]model.TaPrize
171 201
 		query = query.And("status=?", del[0])
172 202
 	}
173 203
 
174
-	err := query.Asc("prize_type").Desc("create_date").Find(&ws)
204
+	err := query.Asc("user_org", "prize_type").Desc("create_date").Find(&ws)
175 205
 	return ws, err
176 206
 }
177 207
 

+ 6
- 4
models/model/ta_prize.go Visa fil

@@ -1,12 +1,14 @@
1 1
 package model
2 2
 
3
-import "time"
3
+import (
4
+	"time"
5
+)
4 6
 
5 7
 type TaPrize struct {
6
-	PrizeId    int       `xorm:"not null pk autoincr INT(11)"`
8
+	PrizeId    int       `xorm:"pk autoincr INTEGER"`
7 9
 	PrizeType  string    `xorm:"VARCHAR(100)"`
8 10
 	PrizeName  string    `xorm:"VARCHAR(300)"`
9 11
 	Picture    string    `xorm:"TEXT"`
10
-	Stock      int       `xorm:"INT(11)"`
11
-	CreateDate time.Time `xorm:"DATETIME"`
12
+	Stock      int       `xorm:"INTEGER"`
13
+	CreateDate time.Time `xorm:"DATE"`
12 14
 }

+ 9
- 7
models/model/ta_prize_setting.go Visa fil

@@ -1,12 +1,14 @@
1 1
 package model
2 2
 
3
-import "time"
3
+import (
4
+	"time"
5
+)
4 6
 
5 7
 type TaPrizeSetting struct {
6
-	SettingId  int       `xorm:"not null pk autoincr INT(11)"`
7
-	PrizeId    int       `xorm:"INT(11)"`
8
-	IsRepeat   int       `xorm:"SMALLINT(6)"`
9
-	PrizeNum   int       `xorm:"INT(11)"`
10
-	Status     int       `xorm:"SMALLINT(6)"`
11
-	CreateDate time.Time `xorm:"DATETIME"`
8
+	SettingId  int       `xorm:"pk autoincr INTEGER"`
9
+	PrizeId    int       `xorm:"INTEGER"`
10
+	IsRepeat   int       `xorm:"SMALLINT"`
11
+	PrizeNum   int       `xorm:"INTEGER"`
12
+	Status     int       `xorm:"SMALLINT"`
13
+	CreateDate time.Time `xorm:"DATE"`
12 14
 }

+ 9
- 7
models/model/ta_prize_winner.go Visa fil

@@ -1,17 +1,19 @@
1 1
 package model
2 2
 
3
-import "time"
3
+import (
4
+	"time"
5
+)
4 6
 
5 7
 type TaPrizeWinner struct {
6
-	RecId      int       `xorm:"not null pk autoincr INT(11)"`
7
-	UserId     int       `xorm:"INT(11)"`
8
+	RecId      int       `xorm:"pk autoincr INTEGER"`
9
+	UserId     int       `xorm:"INTEGER"`
8 10
 	UserName   string    `xorm:"VARCHAR(200)"`
9 11
 	UserOrg    string    `xorm:"VARCHAR(300)"`
10 12
 	UserDept   string    `xorm:"VARCHAR(300)"`
11
-	PrizeId    int       `xorm:"INT(11)"`
13
+	PrizeId    int       `xorm:"INTEGER"`
12 14
 	PrizeName  string    `xorm:"VARCHAR(200)"`
13 15
 	PrizeType  string    `xorm:"VARCHAR(100)"`
14
-	SettingId  int       `xorm:"INT(11)"`
15
-	Status     int       `xorm:"INT(11)"`
16
-	CreateDate time.Time `xorm:"DATETIME"`
16
+	SettingId  int       `xorm:"INTEGER"`
17
+	Status     int       `xorm:"SMALLINT"`
18
+	CreateDate time.Time `xorm:"DATE"`
17 19
 }

+ 1
- 1
models/model/ta_user.go Visa fil

@@ -1,7 +1,7 @@
1 1
 package model
2 2
 
3 3
 type TaUser struct {
4
-	UserId   int    `xorm:"not null pk INT(11)"`
4
+	UserId   int    `xorm:"pk autoincr INTEGER"`
5 5
 	UserName string `xorm:"VARCHAR(100)"`
6 6
 	UserOrg  string `xorm:"VARCHAR(300)"`
7 7
 	UserDept string `xorm:"VARCHAR(300)"`

+ 4
- 30
models/models.go Visa fil

@@ -1,9 +1,9 @@
1 1
 package models
2 2
 
3 3
 import (
4
-	"github.com/astaxie/beego/config"
5
-	_ "github.com/go-sql-driver/mysql"
4
+	"github.com/astaxie/beego"
6 5
 	"github.com/go-xorm/xorm"
6
+	_ "github.com/mattn/go-sqlite3"
7 7
 )
8 8
 
9 9
 var (
@@ -16,10 +16,9 @@ func init() {
16 16
 
17 17
 // NewDAO 初始化数据库连接
18 18
 func NewDAO() *xorm.Engine {
19
-	dbType := "mysql"
20
-	dns := getMysqlDns()
19
+	dbType := "sqlite3"
21 20
 
22
-	dao, err := xorm.NewEngine(dbType, dns)
21
+	dao, err := xorm.NewEngine(dbType, beego.AppConfig.String("dbfile"))
23 22
 	// dao.ShowSQL()
24 23
 
25 24
 	if err != nil {
@@ -30,28 +29,3 @@ func NewDAO() *xorm.Engine {
30 29
 	Dao = dao
31 30
 	return dao
32 31
 }
33
-
34
-func getMysqlDns() string {
35
-	dbconf, _ := config.NewConfig("ini", "conf/db.conf")
36
-
37
-	// db_type  := dbconf.DefaultString("db_type", "mysql")
38
-	conProt := dbconf.DefaultString("con_protocol", "tcp")
39
-	dbAddr := dbconf.DefaultString("db_addr", "localhost")
40
-	dbPort := dbconf.DefaultString("db_port", "3306")
41
-	userName := dbconf.DefaultString("username", "root")
42
-	password := dbconf.String("password")
43
-	database := dbconf.String("database")
44
-	// dbprefix := dbconf.String("dbprefix")
45
-	// db_debug := dbconf.DefaultBool("db_debug", false)
46
-	charSet := dbconf.DefaultString("char_set", "utf8")
47
-
48
-	dns := userName
49
-
50
-	if len(password) > 0 {
51
-		dns += ":" + password
52
-	}
53
-
54
-	dns += "@" + conProt + "(" + dbAddr + ":" + dbPort + ")" + "/" + database + "?charset=" + charSet
55
-
56
-	return dns
57
-}

+ 0
- 90
routers/commentsRouter____annual-lottery_controllers.go Visa fil

@@ -1,90 +0,0 @@
1
-package routers
2
-
3
-import (
4
-	"github.com/astaxie/beego"
5
-	"github.com/astaxie/beego/context/param"
6
-)
7
-
8
-func init() {
9
-
10
-	beego.GlobalControllerRouter["annual-lottery/controllers:BaseController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:BaseController"],
11
-		beego.ControllerComments{
12
-			Method: "UploadFile",
13
-			Router: `/file`,
14
-			AllowHTTPMethods: []string{"post"},
15
-			MethodParams: param.Make(),
16
-			Params: nil})
17
-
18
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
19
-		beego.ControllerComments{
20
-			Method: "Draw",
21
-			Router: `/draw`,
22
-			AllowHTTPMethods: []string{"post"},
23
-			MethodParams: param.Make(),
24
-			Params: nil})
25
-
26
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
27
-		beego.ControllerComments{
28
-			Method: "ExportWinners",
29
-			Router: `/excel/winner`,
30
-			AllowHTTPMethods: []string{"get"},
31
-			MethodParams: param.Make(),
32
-			Params: nil})
33
-
34
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
35
-		beego.ControllerComments{
36
-			Method: "PrizeList",
37
-			Router: `/prize`,
38
-			AllowHTTPMethods: []string{"get"},
39
-			MethodParams: param.Make(),
40
-			Params: nil})
41
-
42
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
43
-		beego.ControllerComments{
44
-			Method: "PrizeEdit",
45
-			Router: `/prize/?:id`,
46
-			AllowHTTPMethods: []string{"post","put","delete"},
47
-			MethodParams: param.Make(),
48
-			Params: nil})
49
-
50
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
51
-		beego.ControllerComments{
52
-			Method: "PrizeSettingList",
53
-			Router: `/setting/prize`,
54
-			AllowHTTPMethods: []string{"get"},
55
-			MethodParams: param.Make(),
56
-			Params: nil})
57
-
58
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
59
-		beego.ControllerComments{
60
-			Method: "PrizeSetting",
61
-			Router: `/setting/prize/?:id`,
62
-			AllowHTTPMethods: []string{"post","put","delete"},
63
-			MethodParams: param.Make(),
64
-			Params: nil})
65
-
66
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
67
-		beego.ControllerComments{
68
-			Method: "UserList",
69
-			Router: `/user`,
70
-			AllowHTTPMethods: []string{"get"},
71
-			MethodParams: param.Make(),
72
-			Params: nil})
73
-
74
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
75
-		beego.ControllerComments{
76
-			Method: "WinnerList",
77
-			Router: `/winner`,
78
-			AllowHTTPMethods: []string{"get"},
79
-			MethodParams: param.Make(),
80
-			Params: nil})
81
-
82
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
83
-		beego.ControllerComments{
84
-			Method: "CancelWinner",
85
-			Router: `/winner/:uid`,
86
-			AllowHTTPMethods: []string{"delete"},
87
-			MethodParams: param.Make(),
88
-			Params: nil})
89
-
90
-}

+ 10
- 10
routers/commentsRouter_controllers.go Visa fil

@@ -7,7 +7,7 @@ import (
7 7
 
8 8
 func init() {
9 9
 
10
-	beego.GlobalControllerRouter["annual-lottery/controllers:BaseController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:BaseController"],
10
+	beego.GlobalControllerRouter["annual-lottery2/controllers:BaseController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:BaseController"],
11 11
 		beego.ControllerComments{
12 12
 			Method: "UploadFile",
13 13
 			Router: `/file`,
@@ -15,7 +15,7 @@ func init() {
15 15
 			MethodParams: param.Make(),
16 16
 			Params: nil})
17 17
 
18
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
18
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
19 19
 		beego.ControllerComments{
20 20
 			Method: "Draw",
21 21
 			Router: `/draw`,
@@ -23,7 +23,7 @@ func init() {
23 23
 			MethodParams: param.Make(),
24 24
 			Params: nil})
25 25
 
26
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
26
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
27 27
 		beego.ControllerComments{
28 28
 			Method: "ExportWinners",
29 29
 			Router: `/excel/winner`,
@@ -31,7 +31,7 @@ func init() {
31 31
 			MethodParams: param.Make(),
32 32
 			Params: nil})
33 33
 
34
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
34
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
35 35
 		beego.ControllerComments{
36 36
 			Method: "PrizeList",
37 37
 			Router: `/prize`,
@@ -39,7 +39,7 @@ func init() {
39 39
 			MethodParams: param.Make(),
40 40
 			Params: nil})
41 41
 
42
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
42
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
43 43
 		beego.ControllerComments{
44 44
 			Method: "PrizeEdit",
45 45
 			Router: `/prize/?:id`,
@@ -47,7 +47,7 @@ func init() {
47 47
 			MethodParams: param.Make(),
48 48
 			Params: nil})
49 49
 
50
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
50
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
51 51
 		beego.ControllerComments{
52 52
 			Method: "PrizeSettingList",
53 53
 			Router: `/setting/prize`,
@@ -55,7 +55,7 @@ func init() {
55 55
 			MethodParams: param.Make(),
56 56
 			Params: nil})
57 57
 
58
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
58
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
59 59
 		beego.ControllerComments{
60 60
 			Method: "PrizeSetting",
61 61
 			Router: `/setting/prize/?:id`,
@@ -63,7 +63,7 @@ func init() {
63 63
 			MethodParams: param.Make(),
64 64
 			Params: nil})
65 65
 
66
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
66
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
67 67
 		beego.ControllerComments{
68 68
 			Method: "UserList",
69 69
 			Router: `/user`,
@@ -71,7 +71,7 @@ func init() {
71 71
 			MethodParams: param.Make(),
72 72
 			Params: nil})
73 73
 
74
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
74
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
75 75
 		beego.ControllerComments{
76 76
 			Method: "WinnerList",
77 77
 			Router: `/winner`,
@@ -79,7 +79,7 @@ func init() {
79 79
 			MethodParams: param.Make(),
80 80
 			Params: nil})
81 81
 
82
-	beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery/controllers:LotteryController"],
82
+	beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"] = append(beego.GlobalControllerRouter["annual-lottery2/controllers:LotteryController"],
83 83
 		beego.ControllerComments{
84 84
 			Method: "CancelWinner",
85 85
 			Router: `/winner/:uid`,

+ 2
- 1
routers/router.go Visa fil

@@ -8,7 +8,7 @@
8 8
 package routers
9 9
 
10 10
 import (
11
-	"annual-lottery/controllers"
11
+	"annual-lottery2/controllers"
12 12
 
13 13
 	"github.com/astaxie/beego"
14 14
 )
@@ -17,6 +17,7 @@ func init() {
17 17
 	ns := beego.NewNamespace("/api",
18 18
 		beego.NSInclude(&controllers.BaseController{}),
19 19
 		beego.NSInclude(&controllers.LotteryController{}),
20
+		beego.NSRouter("/lp/:id", &controllers.BaseController{}, "get,post:LongPoll"),
20 21
 	)
21 22
 
22 23
 	beego.Router("/", &controllers.BaseController{}, "*:Index")

+ 1
- 0
static/css/chunk-272b56fd.837879ef.css
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


static/css/chunk-b1b627f4.9269fb49.css → static/css/chunk-31a1af30.5858d95f.css Visa fil


static/css/chunk-9281f0c6.5b5c5884.css → static/css/chunk-9281f0c6.644a4ade.css Visa fil


+ 0
- 1
static/css/chunk-937d831a.db7ff260.css Visa fil

@@ -1 +0,0 @@
1
-.draw-main{width:100%;height:100%;background-color:#020111}.draw-main ul{width:900px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin:0 auto}ul li{list-style:none}

Binär
static/img/icon1.d4e627ff.jpg Visa fil


Binär
static/img/icon10.4db6dfe1.png Visa fil


Binär
static/img/icon11.5db54e4e.png Visa fil


Binär
static/img/icon12.66582037.png Visa fil


Binär
static/img/icon14.474300d9.png Visa fil


Binär
static/img/icon15.6888c09e.png Visa fil


Binär
static/img/icon2.83fe26d3.png Visa fil


Binär
static/img/icon4.e265f160.png Visa fil


Binär
static/img/icon5.bc5b856f.png Visa fil


Binär
static/img/icon6.93d153c2.png Visa fil


Binär
static/img/icon7.73a249f7.png Visa fil


Binär
static/img/icon8.5bdbc0fe.png Visa fil


Binär
static/img/icon9.8acc321e.png Visa fil


+ 2
- 0
static/js/app.1a6cd51c.js Visa fil

@@ -0,0 +1,2 @@
1
+(function(e){function n(n){for(var r,u,c=n[0],i=n[1],f=n[2],l=0,d=[];l<c.length;l++)u=c[l],a[u]&&d.push(a[u][0]),a[u]=0;for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);s&&s(n);while(d.length)d.shift()();return o.push.apply(o,f||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,u=1;u<t.length;u++){var c=t[u];0!==a[c]&&(r=!1)}r&&(o.splice(n--,1),e=i(i.s=t[0]))}return e}var r={},u={app:0},a={app:0},o=[];function c(e){return i.p+"static/js/"+({}[e]||e)+"."+{"chunk-3222de41":"2cc8315b","chunk-272b56fd":"1bc3d07f","chunk-31a1af30":"01a18f28","chunk-00dc5e14":"25d9a676","chunk-6d3c502a":"44263295","chunk-9281f0c6":"23392d22"}[e]+".js"}function i(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.e=function(e){var n=[],t={"chunk-272b56fd":1,"chunk-31a1af30":1,"chunk-00dc5e14":1,"chunk-6d3c502a":1,"chunk-9281f0c6":1};u[e]?n.push(u[e]):0!==u[e]&&t[e]&&n.push(u[e]=new Promise(function(n,t){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-3222de41":"31d6cfe0","chunk-272b56fd":"837879ef","chunk-31a1af30":"5858d95f","chunk-00dc5e14":"b1f3a43f","chunk-6d3c502a":"e63b58a6","chunk-9281f0c6":"644a4ade"}[e]+".css",a=i.p+r,o=document.getElementsByTagName("link"),c=0;c<o.length;c++){var f=o[c],l=f.getAttribute("data-href")||f.getAttribute("href");if("stylesheet"===f.rel&&(l===r||l===a))return n()}var d=document.getElementsByTagName("style");for(c=0;c<d.length;c++){f=d[c],l=f.getAttribute("data-href");if(l===r||l===a)return n()}var s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.onload=n,s.onerror=function(n){var r=n&&n.target&&n.target.src||a,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.request=r,delete u[e],s.parentNode.removeChild(s),t(o)},s.href=a;var p=document.getElementsByTagName("head")[0];p.appendChild(s)}).then(function(){u[e]=0}));var r=a[e];if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(function(n,t){r=a[e]=[n,t]});n.push(r[2]=o);var f,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=c(e),f=function(n){l.onerror=l.onload=null,clearTimeout(d);var t=a[e];if(0!==t){if(t){var r=n&&("load"===n.type?"missing":n.type),u=n&&n.target&&n.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+u+")");o.type=r,o.request=u,t[1](o)}a[e]=void 0}};var d=setTimeout(function(){f({type:"timeout",target:l})},12e4);l.onerror=l.onload=f,document.head.appendChild(l)}return Promise.all(n)},i.m=e,i.c=r,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,n){if(1&n&&(e=i(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)i.d(t,r,function(n){return e[n]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="/",i.oe=function(e){throw console.error(e),e};var f=window["webpackJsonp"]=window["webpackJsonp"]||[],l=f.push.bind(f);f.push=n,f=f.slice();for(var d=0;d<f.length;d++)n(f[d]);var s=l;o.push([0,"chunk-vendors"]),t()})({0:function(e,n,t){e.exports=t("56d7")},"034f":function(e,n,t){"use strict";var r=t("64a9"),u=t.n(r);u.a},"56d7":function(e,n,t){"use strict";t.r(n);t("cadf"),t("551c"),t("097d");var r=t("2b0e"),u=t("8c4f"),a=t("5c96"),o=t.n(a),c=(t("0fae"),function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{attrs:{id:"app"}},[t("router-view")],1)}),i=[],f={name:"app"},l=f,d=(t("034f"),t("2877")),s=Object(d["a"])(l,c,i,!1,null,null,null);s.options.__file="App.vue";var p=s.exports,h=new u["a"]({routes:[{path:"/",name:"index",component:function(){return Promise.all([t.e("chunk-3222de41"),t.e("chunk-272b56fd")]).then(t.bind(null,"af99"))}},{path:"/admin",name:"user",component:function(){return Promise.all([t.e("chunk-3222de41"),t.e("chunk-31a1af30")]).then(t.bind(null,"de12"))}}]}),m=h;r["default"].use(u["a"]),r["default"].use(o.a),r["default"].config.productionTip=!1,new r["default"]({router:m,render:function(e){return e(p)}}).$mount("#app")},"64a9":function(e,n,t){}});
2
+//# sourceMappingURL=app.1a6cd51c.js.map

+ 1
- 0
static/js/app.1a6cd51c.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 2
static/js/app.8b44d1e5.js Visa fil

@@ -1,2 +0,0 @@
1
-(function(e){function t(t){for(var r,u,c=t[0],i=t[1],f=t[2],l=0,d=[];l<c.length;l++)u=c[l],o[u]&&d.push(o[u][0]),o[u]=0;for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);s&&s(t);while(d.length)d.shift()();return a.push.apply(a,f||[]),n()}function n(){for(var e,t=0;t<a.length;t++){for(var n=a[t],r=!0,u=1;u<n.length;u++){var c=n[u];0!==o[c]&&(r=!1)}r&&(a.splice(t--,1),e=i(i.s=n[0]))}return e}var r={},u={app:0},o={app:0},a=[];function c(e){return i.p+"static/js/"+({}[e]||e)+"."+{"chunk-937d831a":"0c829f83","chunk-b1b627f4":"95910996","chunk-00dc5e14":"25d9a676","chunk-6d3c502a":"44263295","chunk-9281f0c6":"6ecb80c6"}[e]+".js"}function i(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.e=function(e){var t=[],n={"chunk-937d831a":1,"chunk-b1b627f4":1,"chunk-00dc5e14":1,"chunk-6d3c502a":1,"chunk-9281f0c6":1};u[e]?t.push(u[e]):0!==u[e]&&n[e]&&t.push(u[e]=new Promise(function(t,n){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-937d831a":"db7ff260","chunk-b1b627f4":"9269fb49","chunk-00dc5e14":"b1f3a43f","chunk-6d3c502a":"e63b58a6","chunk-9281f0c6":"5b5c5884"}[e]+".css",o=i.p+r,a=document.getElementsByTagName("link"),c=0;c<a.length;c++){var f=a[c],l=f.getAttribute("data-href")||f.getAttribute("href");if("stylesheet"===f.rel&&(l===r||l===o))return t()}var d=document.getElementsByTagName("style");for(c=0;c<d.length;c++){f=d[c],l=f.getAttribute("data-href");if(l===r||l===o)return t()}var s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.onload=t,s.onerror=function(t){var r=t&&t.target&&t.target.src||o,a=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");a.request=r,delete u[e],s.parentNode.removeChild(s),n(a)},s.href=o;var p=document.getElementsByTagName("head")[0];p.appendChild(s)}).then(function(){u[e]=0}));var r=o[e];if(0!==r)if(r)t.push(r[2]);else{var a=new Promise(function(t,n){r=o[e]=[t,n]});t.push(r[2]=a);var f,l=document.createElement("script");l.charset="utf-8",l.timeout=120,i.nc&&l.setAttribute("nonce",i.nc),l.src=c(e),f=function(t){l.onerror=l.onload=null,clearTimeout(d);var n=o[e];if(0!==n){if(n){var r=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src,a=new Error("Loading chunk "+e+" failed.\n("+r+": "+u+")");a.type=r,a.request=u,n[1](a)}o[e]=void 0}};var d=setTimeout(function(){f({type:"timeout",target:l})},12e4);l.onerror=l.onload=f,document.head.appendChild(l)}return Promise.all(t)},i.m=e,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/",i.oe=function(e){throw console.error(e),e};var f=window["webpackJsonp"]=window["webpackJsonp"]||[],l=f.push.bind(f);f.push=t,f=f.slice();for(var d=0;d<f.length;d++)t(f[d]);var s=l;a.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},"034f":function(e,t,n){"use strict";var r=n("64a9"),u=n.n(r);u.a},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("097d");var r=n("2b0e"),u=n("8c4f"),o=n("5c96"),a=n.n(o),c=(n("0fae"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)}),i=[],f={name:"app"},l=f,d=(n("034f"),n("2877")),s=Object(d["a"])(l,c,i,!1,null,null,null);s.options.__file="App.vue";var p=s.exports,h=new u["a"]({routes:[{path:"/",name:"index",component:function(){return n.e("chunk-937d831a").then(n.bind(null,"af99"))}},{path:"/admin",name:"user",component:function(){return n.e("chunk-b1b627f4").then(n.bind(null,"de12"))}}]}),b=h;r["default"].use(u["a"]),r["default"].use(a.a),r["default"].config.productionTip=!1,new r["default"]({router:b,render:function(e){return e(p)}}).$mount("#app")},"64a9":function(e,t,n){}});
2
-//# sourceMappingURL=app.8b44d1e5.js.map

+ 0
- 1
static/js/app.8b44d1e5.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2
- 0
static/js/chunk-272b56fd.1bc3d07f.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 0
static/js/chunk-272b56fd.1bc3d07f.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2
- 0
static/js/chunk-31a1af30.01a18f28.js Visa fil

@@ -0,0 +1,2 @@
1
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-31a1af30"],{"6c5d":function(t,n,e){},"7f7f":function(t,n,e){var a=e("86cc").f,i=Function.prototype,r=/^\s*function ([^ (]*)/,s="name";s in i||e("9e1e")&&a(i,s,{configurable:!0,get:function(){try{return(""+this).match(r)[1]}catch(t){return""}}})},9586:function(t,n,e){"use strict";var a=e("6c5d"),i=e.n(a);i.a},a21f:function(t,n,e){var a=e("584a"),i=a.JSON||(a.JSON={stringify:JSON.stringify});t.exports=function(t){return i.stringify.apply(i,arguments)}},de12:function(t,n,e){"use strict";e.r(n);var a=function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("el-container",[e("el-header",[e("el-row",{attrs:{gutter:20}},[e("el-col",{attrs:{span:6}},[e("div",{staticClass:"logo"},[t._v("抽奖系统")])]),e("el-col",{attrs:{span:18}})],1)],1),e("el-main",[e("el-tabs",{attrs:{type:"card"},on:{"tab-click":t.tabChange},model:{value:t.activeTab,callback:function(n){t.activeTab=n},expression:"activeTab"}},[e("el-tab-pane",{attrs:{label:"抽奖配置",name:"setting"}},[e("prize-setting",{attrs:{data:t.settings,prizes:t.prizes},on:{submit:t.saveSetting,startDraw:function(n){t.postDrawStatus({type:"start"})},endDraw:function(n){t.postDrawStatus({type:"stop"})},refreshPage:function(n){t.postDrawStatus({type:"refresh"})}}})],1),e("el-tab-pane",{attrs:{label:"中奖名单",name:"winner"}},[e("winner",{attrs:{data:t.winners,prizes:t.prizes},on:{search:t.searchWinner,cancel:t.cancelWinner,exportExcel:t.exportExcel}})],1),e("el-tab-pane",{attrs:{label:"奖品管理",name:"prize"}},[e("prize",{attrs:{data:t.prizes,uploadAction:t.uploadAction},on:{submit:t.savePrize}})],1)],1)],1)],1)},i=[],r=e("a4bb"),s=e.n(r),c=(e("7f7f"),e("f499")),o=e.n(c),u=e("cebc"),f=(e("cadf"),e("551c"),e("097d"),e("73ca")),l=e("b775"),p={name:"admin-board",components:{"prize-setting":function(){return e.e("chunk-9281f0c6").then(e.bind(null,"f49f"))},winner:function(){return e.e("chunk-00dc5e14").then(e.bind(null,"6a40"))},prize:function(){return e.e("chunk-6d3c502a").then(e.bind(null,"af41"))}},created:function(){this.getSettingList(),this.getPrizeList()},data:function(){return{activeTab:"setting",users:[],winners:[],prizes:[],settings:[],uploadAction:Object(f["a"])("file.upload").url}},methods:{postDrawStatus:function(t){var n=Object(f["a"])("postDrawStatus");Object(l["a"])(Object(u["a"])({},n,{params:{message:o()(t)||""}})).then(function(t){window.console.log(t)})},tabChange:function(t){switch(t.name){case"winner":this.getWinnerList();break;case"prize":this.getPrizeList();break}},getSettingList:function(){var t=this,n=Object(f["a"])("setting.prize.list");Object(l["a"])(n).then(function(n){var e=n.settings;t.settings=e})},saveSetting:function(t){var n=this,e=Object(f["a"])("setting.prize.save");Object(l["a"])(Object(u["a"])({},e,{data:{data:window.JSON.stringify(t)}})).then(function(t){var e=t.settings;n.settings=e})},getPrizeList:function(){var t=this,n=Object(f["a"])("prize.list");Object(l["a"])(n).then(function(n){var e=n.prizes;t.prizes=e})},getWinnerList:function(){var t=this,n=Object(f["a"])("winner.list");Object(l["a"])(Object(u["a"])({},n)).then(function(n){var e=n.winners;t.winners=e})},searchWinner:function(t){var n=this,e=Object(f["a"])("winner.list");Object(l["a"])(Object(u["a"])({},e,{params:t})).then(function(t){var e=t.winners;n.winners=e})},cancelWinner:function(t){var n=this,e=t.UserId,a=t.PrizeId,i=Object(f["a"])("winner.cancel",{UserId:e});Object(l["a"])(Object(u["a"])({},i,{params:{pid:a}})).then(function(){n.winners=n.winners.filter(function(t){return-1!=t.Status}),n.$message({type:"success",message:"取消成功!"})})},savePrize:function(t){var n=this,e=Object(f["a"])("prize.save");Object(l["a"])(Object(u["a"])({},e,{data:{data:window.JSON.stringify(t)}})).then(function(t){var e=t.prizes;n.prizes=e})},exportExcel:function(t){var n=Object(f["a"])("excel.winner"),e=t?["?"].concat(s()(t).map(function(n){return"".concat(n,"=").concat(t[n])})).join("&"):"";window.open("http://localhost:8080".concat(n.url).concat(e))}}},b=p,d=(e("9586"),e("2877")),h=Object(d["a"])(b,a,i,!1,null,null,null);h.options.__file="admin.vue";n["default"]=h.exports},f499:function(t,n,e){t.exports=e("a21f")}}]);
2
+//# sourceMappingURL=chunk-31a1af30.01a18f28.js.map

+ 1
- 0
static/js/chunk-31a1af30.01a18f28.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 9
- 0
static/js/chunk-3222de41.2cc8315b.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 0
static/js/chunk-3222de41.2cc8315b.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 2
- 0
static/js/chunk-9281f0c6.23392d22.js Visa fil

@@ -0,0 +1,2 @@
1
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-9281f0c6"],{"4fa0":function(t,e,a){"use strict";var i=a("df3a"),r=a.n(i);r.a},df3a:function(t,e,a){},f49f:function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticStyle:{"margin-bottom":"20px"}},[a("el-button",{on:{click:function(e){t.dialogVisible=!0}}},[t._v("新增")]),a("el-button",{on:{click:t.startDraw}},[t._v("开始抽奖")]),a("el-button",{on:{click:t.endDraw}},[t._v("结束抽奖")]),a("el-button",{on:{click:t.refreshPage}},[t._v("重置抽奖页面")])],1),a("el-table",{staticStyle:{width:"100%"},attrs:{data:t.data,"highlight-current-row":"",border:"","row-class-name":t.activeRow}},[a("el-table-column",{attrs:{prop:"SettingId",label:"ID",width:"100"}}),a("el-table-column",{attrs:{prop:"PrizeId",label:"奖品",formatter:t.showPrizeName}}),a("el-table-column",{attrs:{prop:"PrizeNum",label:"数量",width:"100"}}),a("el-table-column",{attrs:{prop:"IsRepeat",label:"允许重复抽",formatter:t.showRepeat,width:"150"}}),a("el-table-column",{attrs:{prop:"Status",label:"状态",formatter:t.showStatus,width:"150"}})],1),a("el-dialog",{attrs:{title:"提示",visible:t.dialogVisible,width:"60%"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("el-form",{attrs:{"label-width":"120px",model:t.formData}},[a("el-form-item",{attrs:{label:"奖品"}},[a("el-select",{model:{value:t.formData.PrizeId,callback:function(e){t.$set(t.formData,"PrizeId",e)},expression:"formData.PrizeId"}},t._l(t.prizes,function(t){return a("el-option",{key:t.PrizeId,attrs:{label:t.PrizeType+" - "+t.PrizeName,value:t.PrizeId}})}),1)],1),a("el-form-item",{attrs:{label:"数量"}},[a("el-input-number",{attrs:{min:1},model:{value:t.formData.PrizeNum,callback:function(e){t.$set(t.formData,"PrizeNum",e)},expression:"formData.PrizeNum"}})],1),a("el-form-item",{attrs:{label:"允许重复抽"}},[a("el-select",{model:{value:t.formData.IsRepeat,callback:function(e){t.$set(t.formData,"IsRepeat",e)},expression:"formData.IsRepeat"}},[a("el-option",{attrs:{label:"是",value:"1"}}),a("el-option",{attrs:{label:"否",value:"0"}})],1)],1),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:t.onSubmit}},[t._v("确定")])],1)],1)],1)],1)},r=[],l=a("cebc"),o={name:"setting",props:["data","prizes"],data:function(){return{dialogVisible:!1,formData:{PrizeId:void 0,IsRepeat:"0",PrizeNum:1}}},methods:{refreshPage:function(){this.$emit("refreshPage")},startDraw:function(){this.$emit("startDraw")},endDraw:function(){this.$emit("endDraw")},activeRow:function(t){var e=t.row;if(1===e.Status)return"tab-row-active"},showPrizeName:function(t,e,a){var i=(this.prizes||[]).filter(function(t){var e=t.PrizeId;return e===a})[0]||{};return"".concat(i.PrizeType," - ").concat(i.PrizeName)},showRepeat:function(t,e,a){return 1===a?"允许":"不允许"},showStatus:function(t,e,a){return 1===a?"有效":"已抽过"},onSubmit:function(){this.$emit("submit",Object(l["a"])({},this.formData,{IsRepeat:this.formData.IsRepeat-0})),this.dialogVisible=!1}}},n=o,s=(a("4fa0"),a("2877")),u=Object(s["a"])(n,i,r,!1,null,null,null);u.options.__file="setting.vue";e["default"]=u.exports}}]);
2
+//# sourceMappingURL=chunk-9281f0c6.23392d22.js.map

+ 1
- 0
static/js/chunk-9281f0c6.23392d22.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 2
static/js/chunk-9281f0c6.6ecb80c6.js Visa fil

@@ -1,2 +0,0 @@
1
-(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-9281f0c6"],{"4fa0":function(t,e,a){"use strict";var i=a("df3a"),r=a.n(i);r.a},df3a:function(t,e,a){},f49f:function(t,e,a){"use strict";a.r(e);var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticStyle:{"margin-bottom":"20px"}},[a("el-button",{on:{click:function(e){t.dialogVisible=!0}}},[t._v("新增")])],1),a("el-table",{staticStyle:{width:"100%"},attrs:{data:t.data,"highlight-current-row":"",border:"","row-class-name":t.activeRow}},[a("el-table-column",{attrs:{prop:"SettingId",label:"ID",width:"100"}}),a("el-table-column",{attrs:{prop:"PrizeId",label:"奖品",formatter:t.showPrizeName}}),a("el-table-column",{attrs:{prop:"PrizeNum",label:"数量",width:"100"}}),a("el-table-column",{attrs:{prop:"IsRepeat",label:"允许重复抽",formatter:t.showRepeat,width:"150"}}),a("el-table-column",{attrs:{prop:"Status",label:"状态",formatter:t.showStatus,width:"150"}})],1),a("el-dialog",{attrs:{title:"提示",visible:t.dialogVisible,width:"60%"},on:{"update:visible":function(e){t.dialogVisible=e}}},[a("el-form",{attrs:{"label-width":"120px",model:t.formData}},[a("el-form-item",{attrs:{label:"奖品"}},[a("el-select",{model:{value:t.formData.PrizeId,callback:function(e){t.$set(t.formData,"PrizeId",e)},expression:"formData.PrizeId"}},t._l(t.prizes,function(t){return a("el-option",{key:t.PrizeId,attrs:{label:t.PrizeType+" - "+t.PrizeName,value:t.PrizeId}})}),1)],1),a("el-form-item",{attrs:{label:"数量"}},[a("el-input-number",{attrs:{min:1},model:{value:t.formData.PrizeNum,callback:function(e){t.$set(t.formData,"PrizeNum",e)},expression:"formData.PrizeNum"}})],1),a("el-form-item",{attrs:{label:"允许重复抽"}},[a("el-select",{model:{value:t.formData.IsRepeat,callback:function(e){t.$set(t.formData,"IsRepeat",e)},expression:"formData.IsRepeat"}},[a("el-option",{attrs:{label:"是",value:"1"}}),a("el-option",{attrs:{label:"否",value:"0"}})],1)],1),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:t.onSubmit}},[t._v("确定")])],1)],1)],1)],1)},r=[],l=a("cebc"),o=(a("cadf"),a("551c"),a("097d"),{name:"setting",props:["data","prizes"],data:function(){return{dialogVisible:!1,formData:{PrizeId:void 0,IsRepeat:"0",PrizeNum:1}}},methods:{activeRow:function(t){var e=t.row;if(1===e.Status)return"tab-row-active"},showPrizeName:function(t,e,a){var i=(this.prizes||[]).filter(function(t){var e=t.PrizeId;return e===a})[0]||{};return"".concat(i.PrizeType," - ").concat(i.PrizeName)},showRepeat:function(t,e,a){return 1===a?"允许":"不允许"},showStatus:function(t,e,a){return 1===a?"有效":"已抽过"},onSubmit:function(){this.$emit("submit",Object(l["a"])({},this.formData,{IsRepeat:this.formData.IsRepeat-0})),this.dialogVisible=!1}}}),n=o,s=(a("4fa0"),a("2877")),u=Object(s["a"])(n,i,r,!1,null,null,null);u.options.__file="setting.vue";e["default"]=u.exports}}]);
2
-//# sourceMappingURL=chunk-9281f0c6.6ecb80c6.js.map

+ 0
- 1
static/js/chunk-9281f0c6.6ecb80c6.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 2
static/js/chunk-937d831a.0c829f83.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 1
static/js/chunk-937d831a.0c829f83.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 9
static/js/chunk-b1b627f4.95910996.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 0
- 1
static/js/chunk-b1b627f4.95910996.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
tests/default_test.go Visa fil

@@ -1,7 +1,7 @@
1 1
 package test
2 2
 
3 3
 import (
4
-	_ "annual-lottery/routers"
4
+	_ "annual-lottery2/routers"
5 5
 	"net/http"
6 6
 	"net/http/httptest"
7 7
 	"path/filepath"

Binär
upload/373057400-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png Visa fil


Binär
upload/384049300-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png Visa fil


Binär
upload/548564400-53BC5E2B-35A4-40af-8FAB-E20D1E152E58.png Visa fil


Binär
upload/daisen.png Visa fil


Binär
upload/fujia.png Visa fil


Binär
upload/huawei.jpg Visa fil


Binär
upload/lankou.jpg Visa fil


Binär
upload/suguo.jpg Visa fil


Binär
upload/surface.jpg Visa fil


+ 10
- 0
utils/config.go Visa fil

@@ -0,0 +1,10 @@
1
+package utils
2
+
3
+import (
4
+	"github.com/astaxie/beego/config"
5
+)
6
+
7
+// GetConfig 获取配置文件
8
+func GetConfig(f string) (config.Configer, error) {
9
+	return config.NewConfig("ini", f)
10
+}

+ 14
- 0
utils/file.go Visa fil

@@ -0,0 +1,14 @@
1
+package utils
2
+
3
+import "os"
4
+
5
+// FileExists 文件是否存在
6
+func FileExists(f string) bool {
7
+	if _, err := os.Stat(f); err != nil {
8
+		if os.IsNotExist(err) {
9
+			return false
10
+		}
11
+	}
12
+
13
+	return true
14
+}

+ 34
- 0
utils/msgqueue.go Visa fil

@@ -0,0 +1,34 @@
1
+package utils
2
+
3
+// MsgQueue 消息队列
4
+type MsgQueue struct {
5
+	queue chan string
6
+}
7
+
8
+// NewMsgQueue 实例
9
+func NewMsgQueue(max ...int) *MsgQueue {
10
+	l := 20
11
+	if len(max) > 0 {
12
+		l = max[0]
13
+	}
14
+
15
+	return &MsgQueue{
16
+		queue: make(chan string, l),
17
+	}
18
+}
19
+
20
+// Pop 出队
21
+func (m *MsgQueue) Pop() string {
22
+	msg := <-m.queue
23
+	return msg
24
+}
25
+
26
+// Push 入队
27
+func (m *MsgQueue) Push(msg string) {
28
+	m.queue <- msg
29
+}
30
+
31
+// Queue 获取 queue 自主控制
32
+func (m *MsgQueue) Queue() chan string {
33
+	return m.queue
34
+}

+ 1
- 1
utils/random.go Visa fil

@@ -7,6 +7,6 @@ import (
7 7
 
8 8
 // RandNum 生成一个 [0, max) 的随机数
9 9
 func RandNum(max int) int {
10
-	src := rand.NewSource(time.Now().UnixNano())
10
+	src := rand.NewSource(time.Now().UnixNano() + rand.Int63n(1000))
11 11
 	return rand.New(src).Intn(max)
12 12
 }

+ 11
- 0
utils/slice.go Visa fil

@@ -10,3 +10,14 @@ func IntSliceIndex(is []int, s int) int {
10 10
 
11 11
 	return -1
12 12
 }
13
+
14
+// StringSliceIndex 返回值 -1 未找到, 正数为 index
15
+func StringSliceIndex(is []string, s string) int {
16
+	for k, v := range is {
17
+		if v == s {
18
+			return k
19
+		}
20
+	}
21
+
22
+	return -1
23
+}

+ 1
- 1
views/index.html Visa fil

@@ -1 +1 @@
1
-<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>annual-lottery</title><link href=/static/css/chunk-00dc5e14.b1f3a43f.css rel=prefetch><link href=/static/css/chunk-6d3c502a.e63b58a6.css rel=prefetch><link href=/static/css/chunk-9281f0c6.5b5c5884.css rel=prefetch><link href=/static/css/chunk-937d831a.db7ff260.css rel=prefetch><link href=/static/css/chunk-b1b627f4.9269fb49.css rel=prefetch><link href=/static/js/chunk-00dc5e14.25d9a676.js rel=prefetch><link href=/static/js/chunk-6d3c502a.44263295.js rel=prefetch><link href=/static/js/chunk-9281f0c6.6ecb80c6.js rel=prefetch><link href=/static/js/chunk-937d831a.0c829f83.js rel=prefetch><link href=/static/js/chunk-b1b627f4.95910996.js rel=prefetch><link href=/static/css/app.77e7389f.css rel=preload as=style><link href=/static/css/chunk-vendors.8c06642c.css rel=preload as=style><link href=/static/js/app.8b44d1e5.js rel=preload as=script><link href=/static/js/chunk-vendors.315fc0c1.js rel=preload as=script><link href=/static/css/chunk-vendors.8c06642c.css rel=stylesheet><link href=/static/css/app.77e7389f.css rel=stylesheet></head><body><noscript><strong>We're sorry but annual-lottery doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.315fc0c1.js></script><script src=/static/js/app.8b44d1e5.js></script></body></html>
1
+<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><script src=https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js></script><title>annual-lottery</title><link href=/static/css/chunk-00dc5e14.b1f3a43f.css rel=prefetch><link href=/static/css/chunk-272b56fd.837879ef.css rel=prefetch><link href=/static/css/chunk-31a1af30.5858d95f.css rel=prefetch><link href=/static/css/chunk-6d3c502a.e63b58a6.css rel=prefetch><link href=/static/css/chunk-9281f0c6.644a4ade.css rel=prefetch><link href=/static/js/chunk-00dc5e14.25d9a676.js rel=prefetch><link href=/static/js/chunk-272b56fd.1bc3d07f.js rel=prefetch><link href=/static/js/chunk-31a1af30.01a18f28.js rel=prefetch><link href=/static/js/chunk-3222de41.2cc8315b.js rel=prefetch><link href=/static/js/chunk-6d3c502a.44263295.js rel=prefetch><link href=/static/js/chunk-9281f0c6.23392d22.js rel=prefetch><link href=/static/css/app.77e7389f.css rel=preload as=style><link href=/static/css/chunk-vendors.8c06642c.css rel=preload as=style><link href=/static/js/app.1a6cd51c.js rel=preload as=script><link href=/static/js/chunk-vendors.315fc0c1.js rel=preload as=script><link href=/static/css/chunk-vendors.8c06642c.css rel=stylesheet><link href=/static/css/app.77e7389f.css rel=stylesheet></head><body><noscript><strong>We're sorry but annual-lottery doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.315fc0c1.js></script><script src=/static/js/app.1a6cd51c.js></script></body></html>