mirror of
https://github.com/cuigh/swirl
synced 2025-06-26 18:16:50 +00:00
Refactor code
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/cuigh/auxo/data"
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
)
|
||||
|
||||
// ChartHandler encapsulates chart related handlers.
|
||||
@@ -28,8 +28,8 @@ func NewChart(b biz.ChartBiz) *ChartHandler {
|
||||
func chartSearch(b biz.ChartBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) (err error) {
|
||||
var (
|
||||
args = &model.ChartSearchArgs{}
|
||||
charts []*model.Chart
|
||||
args = &dao.ChartSearchArgs{}
|
||||
charts []*dao.Chart
|
||||
total int
|
||||
)
|
||||
|
||||
@@ -75,7 +75,7 @@ func chartDelete(b biz.ChartBiz) web.HandlerFunc {
|
||||
|
||||
func chartSave(b biz.ChartBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
r := &model.Chart{}
|
||||
r := &dao.Chart{}
|
||||
err := ctx.Bind(r, true)
|
||||
if err == nil {
|
||||
if r.ID == "" {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/cuigh/auxo/ext/times"
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
)
|
||||
|
||||
// DashboardHandler encapsulates dashboard related handlers.
|
||||
@@ -30,7 +30,7 @@ func NewDashboard(b biz.DashboardBiz) *DashboardHandler {
|
||||
func dashboardFind(b biz.DashboardBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) (err error) {
|
||||
var (
|
||||
d *model.Dashboard
|
||||
d *dao.Dashboard
|
||||
name = ctx.Query("name")
|
||||
key = ctx.Query("key")
|
||||
)
|
||||
@@ -44,7 +44,7 @@ func dashboardFind(b biz.DashboardBiz) web.HandlerFunc {
|
||||
|
||||
func dashboardSave(b biz.DashboardBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
dashboard := &model.Dashboard{}
|
||||
dashboard := &dao.Dashboard{}
|
||||
err := ctx.Bind(dashboard)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/cuigh/auxo/errors"
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
)
|
||||
|
||||
// EventHandler encapsulates event related handlers.
|
||||
@@ -25,8 +25,8 @@ func NewEvent(b biz.EventBiz) *EventHandler {
|
||||
func eventSearch(b biz.EventBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) (err error) {
|
||||
var (
|
||||
args = &model.EventSearchArgs{}
|
||||
events []*model.Event
|
||||
args = &dao.EventSearchArgs{}
|
||||
events []*dao.Event
|
||||
total int
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package api
|
||||
import (
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
)
|
||||
|
||||
// RegistryHandler encapsulates registry related handlers.
|
||||
@@ -61,7 +61,7 @@ func registryDelete(b biz.RegistryBiz) web.HandlerFunc {
|
||||
|
||||
func registrySave(b biz.RegistryBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
r := &model.Registry{}
|
||||
r := &dao.Registry{}
|
||||
err := ctx.Bind(r, true)
|
||||
if err == nil {
|
||||
if r.ID == "" {
|
||||
|
||||
@@ -3,7 +3,7 @@ package api
|
||||
import (
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
)
|
||||
|
||||
// RoleHandler encapsulates role related handlers.
|
||||
@@ -62,7 +62,7 @@ func roleDelete(b biz.RoleBiz) web.HandlerFunc {
|
||||
|
||||
func roleSave(b biz.RoleBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
r := &model.Role{}
|
||||
r := &dao.Role{}
|
||||
err := ctx.Bind(r, true)
|
||||
if err == nil {
|
||||
if r.ID == "" {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
"github.com/cuigh/swirl/docker/compose"
|
||||
"github.com/cuigh/swirl/model"
|
||||
)
|
||||
|
||||
// StackHandler encapsulates stack related handlers.
|
||||
@@ -54,7 +54,7 @@ func stackSearch(b biz.StackBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) (err error) {
|
||||
var (
|
||||
args = &Args{}
|
||||
stacks []*model.Stack
|
||||
stacks []*dao.Stack
|
||||
)
|
||||
|
||||
if err = ctx.Bind(args); err == nil {
|
||||
@@ -122,7 +122,7 @@ func stackDeploy(b biz.StackBiz) web.HandlerFunc {
|
||||
func stackSave(b biz.StackBiz) web.HandlerFunc {
|
||||
type Args struct {
|
||||
ID string `json:"id"`
|
||||
model.Stack
|
||||
dao.Stack
|
||||
}
|
||||
|
||||
return func(ctx web.Context) error {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/cuigh/auxo/errors"
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
"github.com/cuigh/swirl/docker"
|
||||
"github.com/cuigh/swirl/misc"
|
||||
"github.com/cuigh/swirl/model"
|
||||
)
|
||||
|
||||
// SystemHandler encapsulates system related handlers.
|
||||
@@ -77,7 +77,7 @@ func systemSummarize(d *docker.Docker) web.HandlerFunc {
|
||||
|
||||
func systemCreateAdmin(ub biz.UserBiz) web.HandlerFunc {
|
||||
return func(c web.Context) (err error) {
|
||||
user := &model.User{}
|
||||
user := &dao.User{}
|
||||
if err = c.Bind(user, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/cuigh/auxo/data"
|
||||
"github.com/cuigh/auxo/net/web"
|
||||
"github.com/cuigh/swirl/biz"
|
||||
"github.com/cuigh/swirl/model"
|
||||
"github.com/cuigh/swirl/dao"
|
||||
"github.com/cuigh/swirl/security"
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ func userSignIn(auth *security.Identifier, eb biz.EventBiz) web.HandlerFunc {
|
||||
|
||||
func userSave(b biz.UserBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
user := &model.User{}
|
||||
user := &dao.User{}
|
||||
err := ctx.Bind(user, true)
|
||||
if err == nil {
|
||||
if user.ID == "" {
|
||||
@@ -167,7 +167,7 @@ func userModifyPassword(b biz.UserBiz) web.HandlerFunc {
|
||||
|
||||
func userModifyProfile(b biz.UserBiz) web.HandlerFunc {
|
||||
return func(ctx web.Context) error {
|
||||
u := &model.User{}
|
||||
u := &dao.User{}
|
||||
err := ctx.Bind(u, true)
|
||||
if err == nil {
|
||||
err = b.ModifyProfile(u, ctx.User())
|
||||
|
||||
Reference in New Issue
Block a user