游戏商户后台添加分组的页面逻辑

This commit is contained in:
kongyuebin 2021-05-17 22:15:59 +08:00
parent 8bd7067c2f
commit f7a7eb737d
12 changed files with 380 additions and 44 deletions

View File

@ -0,0 +1,53 @@
package controllers
import (
"legend/controllers/base"
"legend/service"
)
type GroupController struct {
base.BasicController
}
func (c *GroupController) AddGroup() {
groupName := c.GetString("groupName")
se := new(service.GroupService)
resp := se.GroupAdd(groupName)
c.Data["json"] = resp
_ = c.ServeJSON()
}
func (c *GroupController) ListGroup() {
page, _ := c.GetInt("page")
limit, _ := c.GetInt("limit")
se := new(service.GroupService)
list := se.GroupList(page, limit)
c.Data["json"] = list
_ = c.ServeJSON()
}
func (c *GroupController) DeleteGroup() {
uid := c.GetString("uid")
se := new(service.GroupService)
resp := se.GroupDelete(uid)
c.Data["json"] = resp
_ = c.ServeJSON()
}
func (c *GroupController) EditGroup() {
uid := c.GetString("uid")
groupName := c.GetString("groupName")
se := new(service.GroupService)
resp := se.GroupEdit(uid, groupName)
c.Data["json"] = resp
_ = c.ServeJSON()
}

View File

@ -6,5 +6,6 @@ require github.com/beego/beego/v2 v2.0.1
require (
github.com/go-sql-driver/mysql v1.5.0
github.com/rs/xid v1.3.0
github.com/smartystreets/goconvey v1.6.4
)

View File

@ -33,9 +33,11 @@ github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:sr
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
@ -71,10 +73,12 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
@ -82,6 +86,7 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
@ -90,9 +95,12 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@ -103,6 +111,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -118,6 +127,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
@ -136,6 +146,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
@ -143,13 +155,16 @@ github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKz
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
@ -252,6 +267,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

View File

@ -1,30 +0,0 @@
package legend
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
)
type Group struct {
Id int `orm:"pk;column(id)"`
GroupName string
Uid string
UpdateTime string
CreateTime string
}
const GROUP = "legend_group"
func (c *Group) TableName() string {
return GROUP
}
func InsertGroup(group *Group) bool {
o := orm.NewOrm()
if _, err := o.Insert(group); err != nil {
logs.Error("insert group err", err)
return false
}
return true
}

View File

@ -0,0 +1,91 @@
package legend
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
)
type Group struct {
Id int `orm:"pk;column(id)"`
GroupName string
Uid string
UpdateTime string
CreateTime string
}
const GROUP = "legend_group"
func (c *Group) TableName() string {
return GROUP
}
func InsertGroup(group *Group) bool {
o := orm.NewOrm()
if _, err := o.Insert(group); err != nil {
logs.Error("insert group err", err)
return false
}
return true
}
func GetGroupAllCont() int {
o := orm.NewOrm()
count, err := o.QueryTable(GROUP).Limit(-1).Count()
if err != nil {
logs.Error(" get group all count err: ", err)
}
return int(count)
}
func GetGroupList(offset, limit int) []Group {
o := orm.NewOrm()
var groups []Group
if _, err := o.QueryTable(GROUP).Limit(limit, offset).OrderBy("-create_time").All(&groups); err != nil {
logs.Error("get scale template list err : ", err)
}
return groups
}
func GetGroupByName(name string) *Group {
o := orm.NewOrm()
group := new(Group)
if _, err := o.QueryTable(GROUP).Filter("group_name", name).Limit(1).All(group); err != nil {
logs.Error(" get group by name err", err)
}
return group
}
func GetGroupByUid(uid string) *Group {
o := orm.NewOrm()
group := new(Group)
if _, err := o.QueryTable(GROUP).Filter("uid", uid).Limit(1).All(group); err != nil {
logs.Error("get group by uid err: ", err)
}
return group
}
func DeleteGroupByUid(uid string) bool {
o := orm.NewOrm()
if _, err := o.QueryTable(GROUP).Filter("uid", uid).Delete(); err != nil {
logs.Error("delete group by uid err: ", err)
return false
}
return true
}
func UpdateGroup(group *Group) bool {
o := orm.NewOrm()
if _, err := o.Update(group); err != nil {
logs.Error("update group err", err)
return false
}
return true
}

View File

@ -0,0 +1,6 @@
package response
type BaseResp struct {
Code int
Msg string
}

View File

@ -0,0 +1,10 @@
package response
import "legend/models/legend"
type GroupListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Count int `json:"count"`
Data []legend.Group `json:"data"`
}

View File

@ -0,0 +1,24 @@
package response
import "legend/models/legend"
type AddTemplateResp struct {
Code int
Msg string
}
type TemplateListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Count int `json:"count"`
Data []legend.ScaleTemplate `json:"data"`
}
type TemplateAllInfoResp struct {
AddTemplateResp
TemplateInfo *legend.ScaleTemplate
AnyMoneyInfo *legend.AnyMoney
FixMoneyInfos []legend.FixMoney
PresentFixMoneyInfos []legend.FixPresent
PresentScaleMoneyInfos []legend.ScalePresent
}

View File

@ -49,5 +49,9 @@ func logicInit() {
web.Router("/template/list", &controllers.TemplateController{}, "*:TemplateList")
web.Router("/delete/template", &controllers.TemplateController{}, "*:TemplateDelete")
web.Router("/template/info", &controllers.TemplateController{}, "*:TemplateAllInfo")
web.Router("/group/list", &controllers.GroupController{}, "*:ListGroup")
web.Router("/add/group", &controllers.GroupController{}, "*:AddGroup")
web.Router("/delete/group", &controllers.GroupController{}, "*:DeleteGroup")
web.Router("/edit/group", &controllers.GroupController{}, "*:EditGroup")
web.InsertFilter("/*", web.BeforeRouter, filter.LoginFilter)
}

View File

@ -0,0 +1,87 @@
package service
import (
"github.com/rs/xid"
"legend/models/legend"
"legend/response"
"legend/utils"
)
type GroupService struct {
BaseService
}
func (c *GroupService) GroupAdd(groupName string) *response.BaseResp {
resp := new(response.BaseResp)
resp.Code = -1
group := new(legend.Group)
uid := xid.New().String()
group.GroupName = groupName
group.Uid = uid
group.CreateTime = utils.GetNowTime()
group.UpdateTime = utils.GetNowTime()
if legend.InsertGroup(group) {
resp.Code = 0
resp.Msg = "添加分组成功"
} else {
resp.Msg = "添加分组失败"
}
return resp
}
func (c *GroupService) GroupList(page, limit int) *response.GroupListResp {
offset := utils.CountOffset(page, limit)
count := legend.GetGroupAllCont()
groups := legend.GetGroupList(offset, limit)
for i, _ := range groups {
groups[i].Id = offset + i + 1
}
groupListResp := new(response.GroupListResp)
groupListResp.Count = count
groupListResp.Code = 0
groupListResp.Data = groups
return groupListResp
}
func (c *GroupService) GroupDelete(uid string) *response.BaseResp {
resp := new(response.BaseResp)
resp.Code = 0
if legend.DeleteGroupByUid(uid) {
resp.Msg = "删除成功"
} else {
resp.Msg = "删除分组信息失败"
resp.Code = -1
}
return resp
}
func (c *GroupService) GroupEdit(uid, groupName string) *response.BaseResp {
resp := new(response.BaseResp)
resp.Code = -1
group := legend.GetGroupByUid(uid)
if group == nil || group.Uid == "" {
resp.Msg = "不存在这样的分组信息"
} else {
group.UpdateTime = utils.GetNowTime()
group.GroupName = groupName
if legend.UpdateGroup(group) {
resp.Code = 0
resp.Msg = "更新成功"
} else {
resp.Msg = "更新失败"
}
}
return resp
}

View File

@ -54,15 +54,15 @@
table.render({
elem: "#demo"
,height: 500
,url: '/static/data/group.json' //数据接口
,url: '/group/list' //数据接口
,page: true //开启分页
,limits: [10, 20, 30, 50, 100, 200]
,limits: [10, 20, 30, 50, 100]
,cols: [[ //表头
{field: 'id', title: 'ID', sort: true, fixed: 'left'}
,{field: 'groupname', title: '分组名称'}
,{field: 'createtime', title: '创建时间', sort: true}
,{field: 'updatetime', title: '修改时间', sort:true}
,{fixed: 'right', title: "操作", width:240, align:'center', toolbar: '#toolbarDemo'}
{field: 'Id', title: 'ID', sort: true, fixed: 'left'}
,{field: 'GroupName', title: '分组名称'}
,{field: 'Uid', title: "分组id"}
,{field: 'CreateTime', title: '创建时间', sort: true}
,{fixed: 'right', title: "操作", width:260, align:'center', toolbar: '#toolbarDemo'}
]]
,toolbar: "#toolbarHead"
});
@ -78,7 +78,32 @@
btnAlign:'c'
}, function (value, index, elem) {
// 做分组的修改内容
layer.close(index);
$.ajax({
url: "/add/group",
data: {
"groupName": value
},
success: function (res) {
if (res.Code !== 0) {
alert(res.Msg)
} else {
table.reload('demo', {
url: "/group/list",
where: {
"page":1
}
})
}
layer.close(index)
}
})
})
} else if ("flush" === event) {
table.reload('demo', {
url: "/group/list",
where: {
"page":1
}
})
}
});
@ -86,17 +111,63 @@
// 监听行工具事件
table.on('tool(test)', function (data) {
let event = data.event;
console.log(data)
if ("recharge-url" === event) {
location.href = "https://www.taobao.com";
} else if ("edit-group" === event) {
layer.msg("请做编辑逻辑的代码");
layer.prompt({
formType:2,
value: data.data.GroupName,
title: "修改分组名",
area:['180px', '30px'],
btnAlign:'c'
}, function (value, index, elem) {
// 做分组的修改内容
$.ajax({
url: "/edit/group",
data: {
"uid": data.data.Uid,
"groupName":value
},
success: function (res) {
if (res.Code !== 0) {
alert(res.Msg)
} else {
table.reload('demo', {
url: "/group/list"
})
}
layer.close(index)
}
})
})
// layer.msg("请做编辑逻辑的代码");
} else if ("delete-group" === event) {
layer.confirm("是否要删除该行?", {
btn:["YES", "NO"]
}, function () {
layer.msg("做删除代码的逻辑");
}, function () {
return false;
}, function (index) {
$.ajax({
url: '/delete/group',
data: {
"uid": data.data.Uid
},
success: function (res) {
if (res.Code === 0) {
data.del()
table.reload('demo', {
url: "/group/list",
where: {
"page": 1
}
})
} else {
alert(res.Msg)
}
}
})
layer.close(index)
}, function (index) {
layer.close(index)
})
}
})

View File

@ -95,7 +95,10 @@
if (res.Code === 0) {
obj.del()
table.reload('demo', {
url: "/template/list"
url: "/template/list",
where: {
"page":1
}
})
} else {
alert(res.Msg)