Commit ab97447a authored by shajiaiming's avatar shajiaiming

Merge branch 'develop' into feature/live

parents 951860aa 2db9a8dd
......@@ -2,7 +2,6 @@ package models
import (
"bwallet/pkg/setting"
"fmt"
"github.com/jinzhu/gorm"
)
......@@ -65,7 +64,6 @@ func GetRecord(id int) (*LiveTitleRecord, error) {
func GetLiveTitleRecord(pageNum, pageSize int, maps interface{}) ([]*LiveTitleRecord, error) {
var live []*LiveTitleRecord
fmt.Println(maps)
err := db.Debug().Where(maps).Preload("LiveInfo").Order("create_time desc").Offset(pageNum).Limit(pageSize).Find(&live).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
......
......@@ -2,6 +2,7 @@ package models
import (
"bwallet/pkg/setting"
"fmt"
"github.com/jinzhu/gorm"
"time"
)
......@@ -77,8 +78,15 @@ func GetManagerTotal(maps interface{}) (int, error) {
func GetManagers(pageNum, pageSize int, maps interface{}) ([]*Manager, error) {
var manager []*Manager
err := db.Where(maps).Order("uid desc").Offset(pageNum).Limit(pageSize).Find(&manager).Error
var uid int32
for key, val := range maps.(map[string]interface{}) {
if ("uid" == key) {
uid = val.(int32)
delete(maps.(map[string]interface{}),"uid")
}
}
fmt.Println(maps)
err := db.Debug().Where(maps).Where("uid <> ?", uid).Order("uid desc").Offset(pageNum).Limit(pageSize).Find(&manager).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
......
......@@ -3,6 +3,7 @@ package models
import (
"bwallet/pkg/setting"
"bwallet/pkg/util"
"time"
)
type OperationLog struct {
......@@ -16,6 +17,7 @@ type OperationLog struct {
Operation string `json:"operation"`
Business string `json:"business"`
Table string `json:"table"`
CreateTime string `json:"create_time"`
}
type OperationLogs struct {
......@@ -26,6 +28,7 @@ type OperationLogs struct {
Operation string `json:"operation"`
Business string `json:"business"`
Table string `json:"table"`
CreateTime string `json:"create_time"`
}
func (a OperationLog) TableName() string {
......@@ -61,6 +64,7 @@ func AddOperationLog(data map[string]interface{}) error {
Operation: data["operation"].(string),
Business: data["business"].(string),
Table: data["table"].(string),
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
}
if err := db.Create(&operationLog).Error; err != nil {
......
......@@ -133,6 +133,7 @@ var (
ErrDeleteUser = &Errno{Code: 20105, Message: "The user delete error."}
ErrExistUser = &Errno{Code: 20106, Message: "The user already exists."}
ErrDeleteSelf = &Errno{Code: 20105, Message: "The user can not delete yourself."}
ErrUpdateSelf = &Errno{Code: 20105, Message: "The user can not modify yourself."}
ErrPasswordIncorrect = &Errno{Code: 20107, Message: "The password was incorrect."}
ErrUserAuthIncorrect = &Errno{Code: 40001, Message: "The user auth was incorrect."}
ErrUserTokenIncorrect = &Errno{Code: 40001, Message: "The user token was incorrect."}
......
......@@ -2,7 +2,6 @@ package gredis
import (
"bwallet/pkg/util"
"fmt"
"github.com/gomodule/redigo/redis"
"time"
)
......@@ -27,7 +26,6 @@ func NewRedisCache(db int, host string, defaultExpiration time.Duration) Cache {
Dial: func() (redis.Conn, error) {
conn, err := redis.Dial("tcp", host, redis.DialDatabase(db))
if err != nil {
fmt.Println(err)
return nil, err
}
return conn, nil
......
......@@ -7,7 +7,6 @@ import (
"bwallet/pkg/util"
"bwallet/service/manager_service"
"bwallet/validate_service"
"fmt"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
......@@ -43,7 +42,6 @@ func AddManager(c *gin.Context) {
manager_service.UserName = manager.UserName
count, err := manager_service.Count()
if count > 0 || err != nil {
fmt.Println(count, err)
handler.SendResponse(c, errno.ErrExistUser, nil)
return
}
......@@ -93,6 +91,7 @@ func GetManagers(c *gin.Context) {
manager_service := manager_service.Manager{
UserName: username,
Status: status,
Uid: int32(user.UserInfo.Uid),
PlatformId: platform_id,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
......@@ -151,6 +150,10 @@ func EditManager(c *gin.Context) {
var platform_id int32
platform_id = int32(user.UserInfo.PlatformId)
if user.UserInfo.Group == manager.Group {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
return
}
if "admin" == group && platform_id != manager.PlatformId {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
......@@ -165,7 +168,7 @@ func EditManager(c *gin.Context) {
manager_service.Status = manager_params.Status
err = manager_service.Edit()
if err != nil {
handler.SendResponse(c, errno.ErrDeleteUser, nil)
handler.SendResponse(c, errno.ErrUpdateSelf, nil)
return
}
......@@ -205,7 +208,7 @@ func DeleteManager(c *gin.Context) {
var platform_id int32
platform_id = int32(user.UserInfo.PlatformId)
if "administrator" == manager.Group {
if user.UserInfo.Group == manager.Group {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
return
}
......@@ -215,6 +218,11 @@ func DeleteManager(c *gin.Context) {
return
}
if "administrator" == manager.Group {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
return
}
err = manager_service.Delete()
if err != nil {
handler.SendResponse(c, errno.ErrDeleteUser, nil)
......
......@@ -59,7 +59,6 @@ func (a *Article) Get() (*models.Article, error) {
condition.Add("sign", sign)
req.URL.RawQuery = condition.Encode()
//fmt.Println(req.URL.String())
r, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
......
......@@ -3,6 +3,7 @@ package operation_log_service
import (
"bwallet/models"
"bwallet/pkg/util"
"strings"
)
type OperationLog struct {
......@@ -56,6 +57,9 @@ func (ol *OperationLog) GetAll() ([]*models.OperationLogs, error) {
op.Operation = value.Operation
op.Business = value.Business
op.Table = value.Table
op.CreateTime = strings.Replace(value.CreateTime,"+08:00", "", -1)
op.CreateTime = strings.Replace(op.CreateTime,"T", " ", -1)
operationLogs = append(operationLogs, op)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment