feat: test ci cd
This commit is contained in:
@@ -68,13 +68,13 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
if check.Id > 0 {
|
||||
return failErr(utils.ErrorDataIsExist), nil
|
||||
return failResponse(utils.ErrorDataIsExist), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminName := ""
|
||||
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
data := dao.ProductCreate{
|
||||
Name: req.Name,
|
||||
Subhead: req.Subhead,
|
||||
@@ -103,8 +103,8 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
IsBuy: uint8(req.IsBuy),
|
||||
PublishTime: publishTime,
|
||||
TryNumber: uint8(req.TryNumber),
|
||||
AdminName: adminName,
|
||||
AdminId: adminId,
|
||||
AdminName: adminInfo.Name,
|
||||
AdminId: int(adminInfo.ID),
|
||||
}
|
||||
if data.IsIndex == 0 {
|
||||
data.IsIndex = 2
|
||||
@@ -153,7 +153,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) {
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
return okResponse(utils.StructToJson(data.Id)), nil
|
||||
return okResponse(utils.StringEmpty), nil
|
||||
}
|
||||
|
||||
func parsePublishTime(s string) (time.Time, error) {
|
||||
|
||||
@@ -51,8 +51,11 @@ func (l *EditApplyLogic) EditApply(in *product.EditApplyReq) (*product.Response,
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
|
||||
info, err := apply.Get(l.ctx, adminId, int(req.Id))
|
||||
if err != nil {
|
||||
@@ -90,8 +93,11 @@ func (l *EditApplyLogic) EditApplyPass(in *product.EditApplyPassReq) (*product.R
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
|
||||
if err = apply.Pass(l.ctx, adminId, int(req.Id)); err != nil {
|
||||
if apply.IsAlreadyHandled(err) {
|
||||
|
||||
@@ -41,12 +41,15 @@ func (l *EditBaseLogic) EditBase(in *product.EditBaseReq) (*product.Response, er
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminName := ""
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
adminName := adminInfo.Name
|
||||
|
||||
if !apply.CanEdit(l.ctx, adminId, int(req.Id)) {
|
||||
return failErr(utils.ErrorAuthority), nil
|
||||
return failResponse(utils.ErrorAuthority), nil
|
||||
}
|
||||
|
||||
w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}}
|
||||
@@ -68,7 +71,7 @@ func (l *EditBaseLogic) EditBase(in *product.EditBaseReq) (*product.Response, er
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
if nameCheck.Id > 0 && nameCheck.Id != int(req.Id) {
|
||||
return failErr(utils.ErrorDataIsExist), nil
|
||||
return failResponse(utils.ErrorDataIsExist), nil
|
||||
}
|
||||
|
||||
publishTime := time.Now()
|
||||
|
||||
@@ -50,12 +50,15 @@ func (l *EditSusceptibleLogic) EditSusceptible(in *product.EditSusceptibleReq) (
|
||||
}
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminName := ""
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
adminName := adminInfo.Name
|
||||
|
||||
if !apply.CanEdit(l.ctx, adminId, int(req.Id)) {
|
||||
return failErr(utils.ErrorAuthority), nil
|
||||
return failResponse(utils.ErrorAuthority), nil
|
||||
}
|
||||
|
||||
w := modelbase.Params{
|
||||
|
||||
@@ -51,8 +51,11 @@ func (l *InfoLogic) Info(in *product.InfoReq) (*product.Response, error) {
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
if applyData, err := apply.Get(l.ctx, adminId, info.Id); err == nil {
|
||||
info.Edit = applyData.Status
|
||||
}
|
||||
|
||||
@@ -65,9 +65,13 @@ func (l *ItemsLogic) Items(in *product.ItemsReq) (*product.Response, error) {
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
|
||||
items := make([]*product.Item, 0, len(info))
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
for _, row := range info {
|
||||
if applyData, err := apply.Get(l.ctx, adminId, row.Id); err == nil {
|
||||
row.Edit = applyData.Status
|
||||
|
||||
@@ -27,11 +27,3 @@ func outResponse(status utils.Status, msg string) *product.Response {
|
||||
Msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
// failErr 兼容仍返回 utils.Error 的旧错误码
|
||||
func failErr(err utils.Error) *product.Response {
|
||||
return &product.Response{
|
||||
Code: int32(err.GetCode()),
|
||||
Msg: err.GetMsg(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,14 @@ func (l *SortLogic) Sort(in *product.SortReq) (*product.Response, error) {
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
|
||||
info.Sort = uint16(req.Sort)
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
info.AdminName = ""
|
||||
info.AdminId = 0
|
||||
info.AdminName = adminInfo.Name
|
||||
info.AdminId = int(adminInfo.ID)
|
||||
|
||||
if _, err = m.Edit(w, &info); err != nil {
|
||||
log.Errorf("product sort edit: %v", err)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) {
|
||||
}
|
||||
|
||||
if req.Status == uint32(dao.ProductStatusDisabled) && len(req.Reason) < 1 {
|
||||
return failErr(utils.ErrorReasonParams), nil
|
||||
return failResponse(utils.ErrorReasonParams), nil
|
||||
}
|
||||
|
||||
var info dao.ProductCheckExist
|
||||
@@ -59,12 +59,16 @@ func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) {
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
|
||||
update := dao.ProductStatusUpdate{
|
||||
Status: uint8(req.Status),
|
||||
Reason: req.Reason,
|
||||
AdminName: "",
|
||||
AdminId: 0,
|
||||
AdminName: adminInfo.Name,
|
||||
AdminId: int(adminInfo.ID),
|
||||
}
|
||||
if _, err = m.Edit(w, &update); err != nil {
|
||||
log.Errorf("product status edit: %v", err)
|
||||
|
||||
@@ -108,7 +108,7 @@ func (l *VerifyLogic) Verify(in *product.VerifyReq) (*product.Response, error) {
|
||||
err = json.Unmarshal([]byte(v.Content), &content)
|
||||
if err != nil {
|
||||
log.Errorf("product verify content json: %v", err)
|
||||
return failErr(utils.ErrorFormatDataError), nil
|
||||
return failResponse(utils.ErrorFormatDataError), nil
|
||||
}
|
||||
items = append(items, &product.VerifyItem{
|
||||
Name: row.Name,
|
||||
|
||||
@@ -51,7 +51,7 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS
|
||||
}
|
||||
|
||||
if req.Status == uint32(dao.VerifyActionReject) && len(req.Reason) < 1 {
|
||||
return failErr(utils.ErrorReasonParams), nil
|
||||
return failResponse(utils.ErrorReasonParams), nil
|
||||
}
|
||||
|
||||
var info dao.VerifyStatusRow
|
||||
@@ -70,9 +70,12 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS
|
||||
return failResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
// 管理员信息后续从 ctx / metadata 取
|
||||
adminId := 0
|
||||
adminName := ""
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
adminId := int(adminInfo.ID)
|
||||
adminName := adminInfo.Name
|
||||
|
||||
nextStatus := dao.VerifyStatusPass
|
||||
reason := req.Reason
|
||||
@@ -163,7 +166,7 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS
|
||||
if err != nil {
|
||||
log.Errorf("verify status tx: %v", err)
|
||||
if isJSONError(err) {
|
||||
return failErr(utils.ErrorFormatDataError), nil
|
||||
return failResponse(utils.ErrorFormatDataError), nil
|
||||
}
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user