message
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 48s
CI / chore (push) Successful in 0s
CI / equipment (push) Failing after 10s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 1s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 1s
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 48s
CI / chore (push) Successful in 0s
CI / equipment (push) Failing after 10s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 1s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 1s
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/equipment/validator"
|
||||
"strconv"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApiBeansAddLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApiBeansAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBeansAddLogic {
|
||||
return &ApiBeansAddLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApiBeansAddLogic) ApiBeansAdd(in *equipment.ApiBeansAddRequest) (*equipment.Response, error) {
|
||||
var v validator.BeansImagesValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
if in.Id < utils.NumberOne {
|
||||
return l.add(in, adminInfo)
|
||||
}
|
||||
|
||||
return l.update(in)
|
||||
}
|
||||
|
||||
func (l *ApiBeansAddLogic) update(in *equipment.ApiBeansAddRequest) (*equipment.Response, error) {
|
||||
var info dao.BeansInfo
|
||||
w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}}
|
||||
err := model.BeansModel{}.Init().GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
info.SecondTime = utils.Now()
|
||||
info.SecondImage = in.Image
|
||||
_, err = model.BeansModel{}.Init().Edit(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
|
||||
func (l *ApiBeansAddLogic) add(in *equipment.ApiBeansAddRequest, adminInfo utils.UserInfo) (*equipment.Response, error) {
|
||||
create := dao.BeansCreate{
|
||||
UserId: adminInfo.ID,
|
||||
UserName: adminInfo.Name,
|
||||
UserNickName: adminInfo.Name,
|
||||
FirstImage: in.Image,
|
||||
FirstTime: utils.Now(),
|
||||
}
|
||||
err := model.BeansModel{}.Init().Create(&create)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"strconv"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApiBeansItemsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApiBeansItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBeansItemsLogic {
|
||||
return &ApiBeansItemsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApiBeansItemsLogic) ApiBeansItems(in *equipment.ApiBeansItemsRequest) (*equipment.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
var info []dao.BeansInfo
|
||||
w := modelbase.Params{
|
||||
Size: int(in.Size),
|
||||
Order: "id desc",
|
||||
Page: int(in.Page),
|
||||
Eq: map[string]string{"user_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)},
|
||||
}
|
||||
|
||||
items, err := model.BeansModel{}.Init().Page(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
return l.ok(items)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"strconv"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApiBeansLastLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApiBeansLastLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBeansLastLogic {
|
||||
return &ApiBeansLastLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApiBeansLastLogic) ApiBeansLast(in *equipment.EmptyRequest) (*equipment.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
var info dao.BeansInfo
|
||||
w := modelbase.Params{
|
||||
Eq: map[string]string{"user_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)},
|
||||
Order: "id desc",
|
||||
}
|
||||
err := model.BeansModel{}.Init().GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
return l.ok(info)
|
||||
}
|
||||
Reference in New Issue
Block a user