diff --git a/model/gmodel/fs_shopping_cart_logic.go b/model/gmodel/fs_shopping_cart_logic.go index 1f508ac9..bc5f4101 100644 --- a/model/gmodel/fs_shopping_cart_logic.go +++ b/model/gmodel/fs_shopping_cart_logic.go @@ -27,6 +27,11 @@ func (s *FsShoppingCartModel) Create(ctx context.Context, data *FsShoppingCart) return s.db.WithContext(ctx).Create(&data).Error } +// 删除 +func (s *FsShoppingCartModel) Delete(ctx context.Context, id, userId int64) error { + return s.db.WithContext(ctx).Where("user_id = ? and id = ?", userId, id).Delete(&FsShoppingCart{}).Error +} + // 更新 func (s *FsShoppingCartModel) Update(ctx context.Context, id, userId int64, data *FsShoppingCart) error { return s.db.WithContext(ctx).Where("user_id = ? and id = ?", userId, id).Updates(&data).Error diff --git a/server/canteen/internal/logic/getcanteendetaillogic.go b/server/canteen/internal/logic/getcanteendetaillogic.go index ea741565..95cd63aa 100644 --- a/server/canteen/internal/logic/getcanteendetaillogic.go +++ b/server/canteen/internal/logic/getcanteendetaillogic.go @@ -31,7 +31,7 @@ func NewGetCanteenDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) * // 获取餐厅详情 func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } //获取餐厅类型数据 canteenTypeModel := gmodel.NewFsCanteenTypeModel(l.svcCtx.MysqlConn) diff --git a/server/canteen/internal/logic/savecanteentypeproductlogic.go b/server/canteen/internal/logic/savecanteentypeproductlogic.go index 2f1e9315..d66abf4d 100644 --- a/server/canteen/internal/logic/savecanteentypeproductlogic.go +++ b/server/canteen/internal/logic/savecanteentypeproductlogic.go @@ -32,7 +32,7 @@ func NewSaveCanteenTypeProductLogic(ctx context.Context, svcCtx *svc.ServiceCont // 保存餐厅类型的关联产品 func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCanteenTypeProductReq, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } if len(req.ProductList) == 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "product list can`t be empty") diff --git a/server/data-transfer/internal/logic/getqrcodesetlistlogic.go b/server/data-transfer/internal/logic/getqrcodesetlistlogic.go index 3b9215d4..e8395f9d 100644 --- a/server/data-transfer/internal/logic/getqrcodesetlistlogic.go +++ b/server/data-transfer/internal/logic/getqrcodesetlistlogic.go @@ -29,7 +29,7 @@ func NewGetQrCodeSetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) * // 获取二维码配置列表 func (l *GetQrCodeSetListLogic) GetQrCodeSetList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn) qrCodeList, err := qrCodeModel.GetAll(l.ctx) diff --git a/server/data-transfer/internal/logic/getstandardlogolistlogic.go b/server/data-transfer/internal/logic/getstandardlogolistlogic.go index 4e946796..e4e9b814 100644 --- a/server/data-transfer/internal/logic/getstandardlogolistlogic.go +++ b/server/data-transfer/internal/logic/getstandardlogolistlogic.go @@ -29,7 +29,7 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContex // 获取标准logo列表 func (l *GetStandardLogoListLogic) GetStandardLogoList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } standardLogoModel := gmodel.NewFsStandardLogoModel(l.svcCtx.MysqlConn) logoList, err := standardLogoModel.GetAll(l.ctx) diff --git a/server/map-library/internal/logic/getmaplibrarylistlogic.go b/server/map-library/internal/logic/getmaplibrarylistlogic.go index 1ecf5167..96f1d834 100644 --- a/server/map-library/internal/logic/getmaplibrarylistlogic.go +++ b/server/map-library/internal/logic/getmaplibrarylistlogic.go @@ -30,7 +30,7 @@ func NewGetMapLibraryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) func (l *GetMapLibraryListLogic) GetMapLibraryList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } mapLibraryModel := gmodel.NewFsMapLibraryModel(l.svcCtx.MysqlConn) mapLibraryList, err := mapLibraryModel.GetAllEnabledList(l.ctx) diff --git a/server/map-library/internal/logic/savemaplibrarylogic.go b/server/map-library/internal/logic/savemaplibrarylogic.go index 0b23c40b..d9373903 100644 --- a/server/map-library/internal/logic/savemaplibrarylogic.go +++ b/server/map-library/internal/logic/savemaplibrarylogic.go @@ -46,7 +46,7 @@ func (l *SaveMapLibraryLogic) BeforeLogic(w http.ResponseWriter, r *http.Request func (l *SaveMapLibraryLogic) SaveMapLibrary(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } if len(l.bodyData) == 0 { diff --git a/server/product/internal/logic/getlastproductdesignlogic.go b/server/product/internal/logic/getlastproductdesignlogic.go index b99f2a90..562aa314 100644 --- a/server/product/internal/logic/getlastproductdesignlogic.go +++ b/server/product/internal/logic/getlastproductdesignlogic.go @@ -31,7 +31,7 @@ func NewGetLastProductDesignLogic(ctx context.Context, svcCtx *svc.ServiceContex func (l *GetLastProductDesignLogic) GetLastProductDesign(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if !userinfo.IsUser() { - return resp.SetStatusAddMessage(basic.CodeUnAuth, "please login") + return resp.SetStatusAddMessage(basic.CodeUnAuth, "please sign in") } //获取用户信息 user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) diff --git a/server/product/internal/logic/getproductdesignlogic.go b/server/product/internal/logic/getproductdesignlogic.go index 8882bec3..8a2e9fad 100644 --- a/server/product/internal/logic/getproductdesignlogic.go +++ b/server/product/internal/logic/getproductdesignlogic.go @@ -31,7 +31,7 @@ func NewGetProductDesignLogic(ctx context.Context, svcCtx *svc.ServiceContext) * func (l *GetProductDesignLogic) GetProductDesign(req *types.GetProductDesignReq, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first") + return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in first") } if req.Sn == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param sn is required") diff --git a/server/product/internal/logic/getsizebyproductlogic.go b/server/product/internal/logic/getsizebyproductlogic.go index dea0a181..5e88ef39 100644 --- a/server/product/internal/logic/getsizebyproductlogic.go +++ b/server/product/internal/logic/getsizebyproductlogic.go @@ -35,7 +35,7 @@ func NewGetSizeByProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) * // 获取分类下的产品以及尺寸 func (l *GetSizeByProductLogic) GetSizeByProduct(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first") + return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in first") } //获取所有网站目录 tagsModel := gmodel.NewFsTagsModel(l.svcCtx.MysqlConn) diff --git a/server/product/internal/logic/getsuccessrecommandlogic.go b/server/product/internal/logic/getsuccessrecommandlogic.go index 601f7dab..67f6902c 100644 --- a/server/product/internal/logic/getsuccessrecommandlogic.go +++ b/server/product/internal/logic/getsuccessrecommandlogic.go @@ -30,7 +30,7 @@ func NewGetSuccessRecommandLogic(ctx context.Context, svcCtx *svc.ServiceContext // 获取推荐的产品列表 func (l *GetSuccessRecommandLogic) GetSuccessRecommand(req *types.GetSuccessRecommandReq, userInfo *auth.UserInfo) (resp *basic.Response) { if userInfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first") + return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in first") } //获取用户信息 userModel := gmodel.NewFsUserModel(l.svcCtx.MysqlConn) diff --git a/server/product/internal/logic/savedesignlogic.go b/server/product/internal/logic/savedesignlogic.go index 55fa1322..4894f508 100644 --- a/server/product/internal/logic/savedesignlogic.go +++ b/server/product/internal/logic/savedesignlogic.go @@ -47,7 +47,7 @@ func NewSaveDesignLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveDe func (l *SaveDesignLogic) SaveDesign(req *types.SaveDesignReq, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeUnAuth, "please login first") + return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in first") } //查询是否是加密的(不太合理) encryptWebsetting, err := l.svcCtx.AllModels.FsWebSet.FindValueByKey(l.ctx, "is_encrypt") diff --git a/server/shopping-cart/internal/logic/deletecartlogic.go b/server/shopping-cart/internal/logic/deletecartlogic.go index 865a811f..4c1bc37b 100644 --- a/server/shopping-cart/internal/logic/deletecartlogic.go +++ b/server/shopping-cart/internal/logic/deletecartlogic.go @@ -31,9 +31,14 @@ func NewDeleteCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete // } func (l *DeleteCartLogic) DeleteCart(req *types.DeleteCartReq, userinfo *auth.UserInfo) (resp *basic.Response) { - // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) - // userinfo 传入值时, 一定不为null - + if !userinfo.IsUser() { + return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in") + } + //删除购物车 + if err := l.svcCtx.AllModels.FsShoppingCart.Delete(l.ctx, userinfo.UserId, req.Id); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to delete shopping cart") + } return resp.SetStatus(basic.CodeOK) } diff --git a/server/upload/internal/logic/uploadqrcodelogic.go b/server/upload/internal/logic/uploadqrcodelogic.go index f3242661..e8328640 100644 --- a/server/upload/internal/logic/uploadqrcodelogic.go +++ b/server/upload/internal/logic/uploadqrcodelogic.go @@ -32,7 +32,7 @@ func NewUploadQrcodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Uplo func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first") } if req.Url == "" { resp.SetStatus(basic.CodeApiErr, "param url is empty")