@@ -2,6 +2,7 @@ package apis
2
2
3
3
import (
4
4
"github.com/gin-gonic/gin/binding"
5
+ "github.com/go-admin-team/go-admin-core/sdk/config"
5
6
"go-admin/app/admin/models"
6
7
"net/http"
7
8
@@ -30,7 +31,7 @@ type SysUser struct {
30
31
// @Security Bearer
31
32
func (e SysUser ) GetPage (c * gin.Context ) {
32
33
s := service.SysUser {}
33
- req := dto.SysUserGetPageReq {}
34
+ req := dto.SysUserGetPageReq {}
34
35
err := e .MakeContext (c ).
35
36
MakeOrm ().
36
37
Bind (& req ).
@@ -67,7 +68,7 @@ func (e SysUser) GetPage(c *gin.Context) {
67
68
// @Security Bearer
68
69
func (e SysUser ) Get (c * gin.Context ) {
69
70
s := service.SysUser {}
70
- req := dto.SysUserById {}
71
+ req := dto.SysUserById {}
71
72
err := e .MakeContext (c ).
72
73
MakeOrm ().
73
74
Bind (& req , nil ).
@@ -101,7 +102,7 @@ func (e SysUser) Get(c *gin.Context) {
101
102
// @Security Bearer
102
103
func (e SysUser ) Insert (c * gin.Context ) {
103
104
s := service.SysUser {}
104
- req := dto.SysUserInsertReq {}
105
+ req := dto.SysUserInsertReq {}
105
106
err := e .MakeContext (c ).
106
107
MakeOrm ().
107
108
Bind (& req , binding .JSON ).
@@ -136,7 +137,7 @@ func (e SysUser) Insert(c *gin.Context) {
136
137
// @Security Bearer
137
138
func (e SysUser ) Update (c * gin.Context ) {
138
139
s := service.SysUser {}
139
- req := dto.SysUserUpdateReq {}
140
+ req := dto.SysUserUpdateReq {}
140
141
err := e .MakeContext (c ).
141
142
MakeOrm ().
142
143
Bind (& req ).
@@ -171,7 +172,7 @@ func (e SysUser) Update(c *gin.Context) {
171
172
// @Security Bearer
172
173
func (e SysUser ) Delete (c * gin.Context ) {
173
174
s := service.SysUser {}
174
- req := dto.SysUserById {}
175
+ req := dto.SysUserById {}
175
176
err := e .MakeContext (c ).
176
177
MakeOrm ().
177
178
Bind (& req , binding .JSON ).
@@ -208,7 +209,7 @@ func (e SysUser) Delete(c *gin.Context) {
208
209
// @Security Bearer
209
210
func (e SysUser ) InsetAvatar (c * gin.Context ) {
210
211
s := service.SysUser {}
211
- req := dto.UpdateSysUserAvatarReq {}
212
+ req := dto.UpdateSysUserAvatarReq {}
212
213
err := e .MakeContext (c ).
213
214
MakeOrm ().
214
215
MakeService (& s .Service ).
@@ -257,7 +258,7 @@ func (e SysUser) InsetAvatar(c *gin.Context) {
257
258
// @Security Bearer
258
259
func (e SysUser ) UpdateStatus (c * gin.Context ) {
259
260
s := service.SysUser {}
260
- req := dto.UpdateSysUserStatusReq {}
261
+ req := dto.UpdateSysUserStatusReq {}
261
262
err := e .MakeContext (c ).
262
263
MakeOrm ().
263
264
Bind (& req , binding .JSON , nil ).
@@ -294,7 +295,7 @@ func (e SysUser) UpdateStatus(c *gin.Context) {
294
295
// @Security Bearer
295
296
func (e SysUser ) ResetPwd (c * gin.Context ) {
296
297
s := service.SysUser {}
297
- req := dto.ResetSysUserPwdReq {}
298
+ req := dto.ResetSysUserPwdReq {}
298
299
err := e .MakeContext (c ).
299
300
MakeOrm ().
300
301
Bind (& req , binding .JSON ).
@@ -311,16 +312,23 @@ func (e SysUser) ResetPwd(c *gin.Context) {
311
312
//数据权限检查
312
313
p := actions .GetPermissionFromContext (c )
313
314
315
+ if req .UserId == 1 && config .ApplicationConfig .Mode == "demo" {
316
+ req .Password = "123456"
317
+ }
314
318
err = s .ResetPwd (& req , p )
315
319
if err != nil {
316
320
e .Logger .Error (err )
317
321
return
318
322
}
319
- e .OK (req .GetId (), "更新成功" )
323
+ if req .UserId == 1 && config .ApplicationConfig .Mode == "demo" {
324
+ e .OK (req .GetId (), "admin:现在使用的预览环境,休想改掉我!否则会影响其他朋友体验的哦!可以创建其他用户体验该功能!" )
325
+ } else {
326
+ e .OK (req .GetId (), "更新成功" )
327
+ }
320
328
}
321
329
322
330
// UpdatePwd
323
- // @Summary 重置密码
331
+ // @Summary 修改密码
324
332
// @Description 获取JSON
325
333
// @Tags 用户
326
334
// @Accept application/json
@@ -331,7 +339,7 @@ func (e SysUser) ResetPwd(c *gin.Context) {
331
339
// @Security Bearer
332
340
func (e SysUser ) UpdatePwd (c * gin.Context ) {
333
341
s := service.SysUser {}
334
- req := dto.PassWord {}
342
+ req := dto.PassWord {}
335
343
err := e .MakeContext (c ).
336
344
MakeOrm ().
337
345
Bind (& req ).
@@ -345,14 +353,20 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
345
353
346
354
// 数据权限检查
347
355
p := actions .GetPermissionFromContext (c )
348
-
356
+ if user .GetUserId (c ) == 1 && config .ApplicationConfig .Mode == "demo" {
357
+ req .NewPassword = "123456"
358
+ }
349
359
err = s .UpdatePwd (user .GetUserId (c ), req .OldPassword , req .NewPassword , p )
350
360
if err != nil {
351
361
e .Logger .Error (err )
352
362
e .Error (http .StatusForbidden , err , "密码修改失败" )
353
363
return
354
364
}
355
- e .OK (nil , "密码修改成功" )
365
+ if user .GetUserId (c ) == 1 && config .ApplicationConfig .Mode == "demo" {
366
+ e .OK (nil , "admin:现在使用的预览环境,休想改掉我!否则会影响其他朋友体验的哦!可以创建其他用户体验该功能!" )
367
+ } else {
368
+ e .OK (nil , "密码修改成功" )
369
+ }
356
370
}
357
371
358
372
// GetProfile
@@ -364,7 +378,7 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
364
378
// @Security Bearer
365
379
func (e SysUser ) GetProfile (c * gin.Context ) {
366
380
s := service.SysUser {}
367
- req := dto.SysUserById {}
381
+ req := dto.SysUserById {}
368
382
err := e .MakeContext (c ).
369
383
MakeOrm ().
370
384
MakeService (& s .Service ).
@@ -401,7 +415,7 @@ func (e SysUser) GetProfile(c *gin.Context) {
401
415
// @Router /api/v1/getinfo [get]
402
416
// @Security Bearer
403
417
func (e SysUser ) GetInfo (c * gin.Context ) {
404
- req := dto.SysUserById {}
418
+ req := dto.SysUserById {}
405
419
s := service.SysUser {}
406
420
r := service.SysRole {}
407
421
err := e .MakeContext (c ).
@@ -450,4 +464,4 @@ func (e SysUser) GetInfo(c *gin.Context) {
450
464
mp ["name" ] = sysUser .NickName
451
465
mp ["code" ] = 200
452
466
e .OK (mp , "" )
453
- }
467
+ }
0 commit comments