service apis edit, info, items, status, names
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"admin/admin"
|
||||
"admin/internal/dao"
|
||||
"admin/internal/model"
|
||||
"admin/internal/svc"
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"pkg.local/modelbase"
|
||||
"pkg.local/utils"
|
||||
)
|
||||
|
||||
type ServiceNamesLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewServiceNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ServiceNamesLogic {
|
||||
return &ServiceNamesLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ServiceNamesLogic) ServiceNames(in *admin.ServiceNameRequest) (*admin.Response, error) {
|
||||
var items []dao.ServicesNames
|
||||
modelObj := model.ServicesModel{}.Init()
|
||||
w := modelbase.Params{
|
||||
Eq: map[string]string{"status": utils.StringStatusOk},
|
||||
}
|
||||
w.Like = make(map[string]string)
|
||||
if len(in.Name) > utils.NumberZero {
|
||||
w.Like["name LIKE ? "] = "%%" + in.Name + "%%"
|
||||
}
|
||||
err := modelObj.Items(w, &items)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail), nil
|
||||
}
|
||||
return l.ok(items), nil
|
||||
}
|
||||
Reference in New Issue
Block a user