快递,添加、编辑、名称、列表、详情
This commit is contained in:
@@ -49,7 +49,9 @@ type ExpressNames struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ExpressStatus struct {
|
type ExpressStatus struct {
|
||||||
Id int64 `json:"id" gorm:"id"` // ID
|
Id int64 `json:"id" gorm:"id"` // ID
|
||||||
Status uint8 `json:"status" gorm:"status"` // 状态,1为正常,2为禁用
|
Status uint8 `json:"status" gorm:"status"` // 状态,1为正常,2为禁用
|
||||||
Reason string `json:"reason" gorm:"reason"` // 原因
|
Reason string `json:"reason" gorm:"reason"` // 原因
|
||||||
|
AdminId int64 `json:"admin_id" gorm:"admin_id"` // 操作人ID
|
||||||
|
AdminName string `json:"admin_name" gorm:"admin_name"` // 操作人姓名
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"lone-services/pkg/utils"
|
||||||
"lone-services/rpc/express/pb"
|
"lone-services/rpc/express/pb"
|
||||||
|
"lone-services/services/express/internal/dao"
|
||||||
|
"lone-services/services/express/internal/model"
|
||||||
"lone-services/services/express/internal/svc"
|
"lone-services/services/express/internal/svc"
|
||||||
|
"lone-services/services/express/validator"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
@@ -25,7 +28,46 @@ func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *CreateLogic) Create(in *express.CreateRequest) (*express.Response, error) {
|
func (l *CreateLogic) Create(in *express.CreateRequest) (*express.Response, error) {
|
||||||
// todo: add your logic here and delete this line
|
var v validator.EditValidator
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
data := dao.Express{
|
||||||
|
Name: in.Name,
|
||||||
|
TransitId: uint8(in.TransitId),
|
||||||
|
AppCode: in.AppCode,
|
||||||
|
AppSecretKey: in.AppSecretKey,
|
||||||
|
AppUrl: in.AppUrl,
|
||||||
|
CardNumber: in.CardNumber,
|
||||||
|
PdfCode: in.PdfCode,
|
||||||
|
Province: in.Province,
|
||||||
|
City: in.City,
|
||||||
|
County: in.County,
|
||||||
|
Address: in.Address,
|
||||||
|
CompanyName: in.CompanyName,
|
||||||
|
Contact: in.Contact,
|
||||||
|
Mobile: in.Mobile,
|
||||||
|
Other: in.Other,
|
||||||
|
AdminId: adminInfo.ID,
|
||||||
|
AdminName: adminInfo.Name,
|
||||||
|
}
|
||||||
|
|
||||||
return &express.Response{}, nil
|
err := model.ExpressModel{}.Init().Create(&data)
|
||||||
|
if err != nil {
|
||||||
|
l.Logger.Error(err)
|
||||||
|
return l.fail(utils.Fail)
|
||||||
|
}
|
||||||
|
|
||||||
|
action := utils.ActionAdd{
|
||||||
|
NewContent: data,
|
||||||
|
Type: utils.LogActionTypeAdd,
|
||||||
|
ModuleName: utils.LogActionModuleExpress,
|
||||||
|
}
|
||||||
|
utils.SetActionLog(adminInfo, action)
|
||||||
|
|
||||||
|
return l.ok(data.Id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"lone-services/pkg/modelbase"
|
||||||
|
"lone-services/pkg/utils"
|
||||||
|
"lone-services/services/express/internal/dao"
|
||||||
|
"lone-services/services/express/internal/model"
|
||||||
|
"lone-services/services/express/validator"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"lone-services/rpc/express/pb"
|
"lone-services/rpc/express/pb"
|
||||||
"lone-services/services/express/internal/svc"
|
"lone-services/services/express/internal/svc"
|
||||||
@@ -25,7 +31,55 @@ func NewEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *EditLogic) Edit(in *express.CreateRequest) (*express.Response, error) {
|
func (l *EditLogic) Edit(in *express.CreateRequest) (*express.Response, error) {
|
||||||
// todo: add your logic here and delete this line
|
var v validator.EditValidator
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
return &express.Response{}, nil
|
var info dao.Express
|
||||||
|
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
||||||
|
err := model.ExpressModel{}.Init().GetOne(w, &info)
|
||||||
|
if err != nil {
|
||||||
|
return l.fail(utils.ErrorNotFund)
|
||||||
|
}
|
||||||
|
action := utils.ActionAdd{
|
||||||
|
OldContent: info,
|
||||||
|
Type: utils.LogActionTypeEdit,
|
||||||
|
ModuleName: utils.LogActionModuleExpress,
|
||||||
|
}
|
||||||
|
|
||||||
|
info.AdminId = adminInfo.ID
|
||||||
|
info.AdminName = adminInfo.Name
|
||||||
|
info.Name = in.Name
|
||||||
|
info.TransitId = uint8(in.TransitId)
|
||||||
|
info.AppCode = in.AppCode
|
||||||
|
info.AppSecretKey = in.AppSecretKey
|
||||||
|
info.AppUrl = in.AppUrl
|
||||||
|
info.CardNumber = in.CardNumber
|
||||||
|
info.PdfCode = in.PdfCode
|
||||||
|
info.Province = in.Province
|
||||||
|
info.City = in.City
|
||||||
|
info.County = in.County
|
||||||
|
info.Address = in.Address
|
||||||
|
info.CompanyName = in.CompanyName
|
||||||
|
info.Contact = in.Contact
|
||||||
|
info.Mobile = in.Mobile
|
||||||
|
info.Other = in.Other
|
||||||
|
|
||||||
|
row, err := model.ExpressModel{}.Init().Edit(w, &info)
|
||||||
|
if err != nil {
|
||||||
|
l.Logger.Error(err)
|
||||||
|
return l.fail(utils.Fail)
|
||||||
|
}
|
||||||
|
|
||||||
|
if row > utils.NumberZero {
|
||||||
|
action.NewContent = info
|
||||||
|
utils.SetActionLog(adminInfo, action)
|
||||||
|
}
|
||||||
|
|
||||||
|
return l.ok(info.Id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,14 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"lone-services/pkg/modelbase"
|
||||||
|
"lone-services/pkg/utils"
|
||||||
"lone-services/rpc/express/pb"
|
"lone-services/rpc/express/pb"
|
||||||
|
"lone-services/services/admin/validator"
|
||||||
|
"lone-services/services/express/internal/dao"
|
||||||
|
"lone-services/services/express/internal/model"
|
||||||
"lone-services/services/express/internal/svc"
|
"lone-services/services/express/internal/svc"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
@@ -25,7 +30,18 @@ func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *InfoLogic) Info(in *express.IdRequest) (*express.Response, error) {
|
func (l *InfoLogic) Info(in *express.IdRequest) (*express.Response, error) {
|
||||||
// todo: add your logic here and delete this line
|
var v validator.AdminInfoValidator
|
||||||
|
if fail := l.checkParams(in, &v); fail != nil {
|
||||||
|
return fail, nil
|
||||||
|
}
|
||||||
|
|
||||||
return &express.Response{}, nil
|
var info dao.ExpressInfo
|
||||||
|
modelObj := model.ExpressModel{}.Init()
|
||||||
|
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
||||||
|
err := modelObj.GetOne(w, &info)
|
||||||
|
if err != nil {
|
||||||
|
return l.fail(utils.ErrorNotFund)
|
||||||
|
}
|
||||||
|
|
||||||
|
return l.ok(info)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ func (l *ItemsLogic) Items(in *express.EmtpyRequest) (*express.Response, error)
|
|||||||
w := modelbase.Params{}
|
w := modelbase.Params{}
|
||||||
|
|
||||||
var data []dao.ExpressInfo
|
var data []dao.ExpressInfo
|
||||||
items, _ := modelObj.Page(w, &data)
|
modelObj.Items(w, &data)
|
||||||
|
|
||||||
return l.ok(items)
|
return l.ok(data)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"lone-services/pkg/modelbase"
|
||||||
|
"lone-services/pkg/utils"
|
||||||
|
"lone-services/services/express/internal/dao"
|
||||||
|
"lone-services/services/express/internal/model"
|
||||||
|
|
||||||
"lone-services/rpc/express/pb"
|
"lone-services/rpc/express/pb"
|
||||||
"lone-services/services/express/internal/svc"
|
"lone-services/services/express/internal/svc"
|
||||||
@@ -25,7 +29,16 @@ func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *NamesLogic) Names(in *express.EmtpyRequest) (*express.Response, error) {
|
func (l *NamesLogic) Names(in *express.EmtpyRequest) (*express.Response, error) {
|
||||||
// todo: add your logic here and delete this line
|
modelObj := model.ExpressModel{}.Init()
|
||||||
|
w := modelbase.Params{
|
||||||
|
Order: "id desc",
|
||||||
|
}
|
||||||
|
var items []dao.ExpressNames
|
||||||
|
err := modelObj.Items(w, &items)
|
||||||
|
if err != nil {
|
||||||
|
l.Logger.Error(err)
|
||||||
|
return l.fail(utils.Fail)
|
||||||
|
}
|
||||||
|
|
||||||
return &express.Response{}, nil
|
return l.ok(items)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"lone-services/pkg/modelbase"
|
||||||
|
"lone-services/pkg/utils"
|
||||||
|
"lone-services/services/express/internal/dao"
|
||||||
|
"lone-services/services/express/internal/model"
|
||||||
|
"lone-services/services/express/validator"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"lone-services/rpc/express/pb"
|
"lone-services/rpc/express/pb"
|
||||||
"lone-services/services/express/internal/svc"
|
"lone-services/services/express/internal/svc"
|
||||||
@@ -25,7 +31,42 @@ func NewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusLogi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *StatusLogic) Status(in *express.StatusRequest) (*express.Response, error) {
|
func (l *StatusLogic) Status(in *express.StatusRequest) (*express.Response, error) {
|
||||||
// todo: add your logic here and delete this line
|
var v validator.StatusValidator
|
||||||
|
if fail := l.checkParams(in, &v); fail != nil {
|
||||||
return &express.Response{}, nil
|
return fail, nil
|
||||||
|
}
|
||||||
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||||
|
if adminInfo.ID < utils.NumberOne {
|
||||||
|
return l.fail(utils.ErrorNoLoginInfo)
|
||||||
|
}
|
||||||
|
var action = utils.ActionAdd{}
|
||||||
|
var info dao.ExpressStatus
|
||||||
|
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
||||||
|
modelObj := model.ExpressModel{}.Init()
|
||||||
|
err := modelObj.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)
|
||||||
|
}
|
||||||
|
action.OldContent = info
|
||||||
|
info.Status = uint8(in.Status)
|
||||||
|
info.Reason = in.Reason
|
||||||
|
info.AdminName = adminInfo.Name
|
||||||
|
info.AdminId = adminInfo.ID
|
||||||
|
row, editErr := modelObj.Edit(w, info)
|
||||||
|
if editErr != nil {
|
||||||
|
l.Logger.Error(editErr)
|
||||||
|
return l.fail(utils.Fail)
|
||||||
|
}
|
||||||
|
if row > utils.NumberZero {
|
||||||
|
action.NewContent = info
|
||||||
|
action.Reason = in.Reason
|
||||||
|
action.Type = utils.LogActionTypeStatus
|
||||||
|
action.ModuleName = utils.LogActionModuleExpress
|
||||||
|
utils.SetActionLog(adminInfo, action)
|
||||||
|
}
|
||||||
|
return l.ok(utils.NumberOne)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user