merch module enabled + fix
This commit is contained in:
parent
78a54cc4ac
commit
3ff0e6d641
5 changed files with 34 additions and 27 deletions
|
|
@ -70,10 +70,10 @@ func (co *controller) addMerch(c *gin.Context) {
|
|||
// @Description Получить всю информацию про мерч по его uuid
|
||||
// @Tags Merch
|
||||
// @Security BearerAuth
|
||||
// @Param uuid path string true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Param uuid path string true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /merch/{uuid} [get]
|
||||
func (co *controller) getSingleMerch(c *gin.Context) {
|
||||
merchUuid := c.Param("uuid")
|
||||
|
|
@ -103,9 +103,9 @@ func (co *controller) getSingleMerch(c *gin.Context) {
|
|||
// @Description Получить все записи мерча
|
||||
// @Tags Merch
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {array} ListResponse
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Success 200 {array} ListResponse
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /merch/{uuid} [get]
|
||||
func (co *controller) getAllMerch(c *gin.Context) {
|
||||
userUuid, err := co.utils.GetUserUuidFromContext(c)
|
||||
|
|
@ -129,10 +129,10 @@ func (co *controller) getAllMerch(c *gin.Context) {
|
|||
// @Description Обновить информацию про мерч по его uuid в json-е
|
||||
// @Tags Merch
|
||||
// @Security BearerAuth
|
||||
// @Param body body MerchDTO true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Param body body MerchDTO true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /merch/{uuid} [put]
|
||||
func (co *controller) updateMerch(c *gin.Context) {
|
||||
var payload MerchDTO
|
||||
|
|
@ -160,10 +160,10 @@ func (co *controller) updateMerch(c *gin.Context) {
|
|||
// @Description Пометить мерч как удаленный по его uuid
|
||||
// @Tags Merch
|
||||
// @Security BearerAuth
|
||||
// @Param uuid path string true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Param uuid path string true "merch_uuid"
|
||||
// @Success 200 {object} MerchDTO
|
||||
// @Failure 400 {object} responses.ErrorResponse400
|
||||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /merch/{uuid} [delete]
|
||||
func (co *controller) deleteMerch(c *gin.Context) {
|
||||
merchUuid := c.Param("uuid")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package merch
|
||||
|
||||
type merchBundle struct {
|
||||
Merch Merch
|
||||
Surugaya Surugaya
|
||||
Mandarake Mandarake
|
||||
Merch *Merch
|
||||
Surugaya *Surugaya
|
||||
Mandarake *Mandarake
|
||||
}
|
||||
type MerchDTO struct {
|
||||
MerchUuid string `json:"merch_uuid"`
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ type repository interface {
|
|||
}
|
||||
|
||||
func (r *Repo) addMerch(bundle merchBundle) error {
|
||||
if err := r.db.Create(bundle.Merch).Error; err != nil {
|
||||
if err := r.db.Model(&Merch{}).Create(bundle.Merch).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := r.db.Create(bundle.Surugaya).Error; err != nil {
|
||||
if err := r.db.Model(&Surugaya{}).Create(bundle.Surugaya).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := r.db.Create(bundle.Mandarake).Error; err != nil {
|
||||
if err := r.db.Model(&Mandarake{}).Create(bundle.Mandarake).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ func (r *Repo) addMerch(bundle merchBundle) error {
|
|||
}
|
||||
|
||||
func (r *Repo) getSingleMerch(userUuid, merchUuid string) (merchBundle, error) {
|
||||
var merch Merch
|
||||
var merch *Merch
|
||||
if err := r.db.
|
||||
Where("user_uuid = ?", userUuid).
|
||||
Where("merch_uuid = ?", merchUuid).
|
||||
|
|
@ -53,14 +53,14 @@ func (r *Repo) getSingleMerch(userUuid, merchUuid string) (merchBundle, error) {
|
|||
return merchBundle{}, err
|
||||
}
|
||||
|
||||
var surugaya Surugaya
|
||||
var surugaya *Surugaya
|
||||
if err := r.db.
|
||||
Where("merch_uuid = ?", merchUuid).
|
||||
First(&surugaya).Error; err != nil {
|
||||
return merchBundle{}, err
|
||||
}
|
||||
|
||||
var mandarake Mandarake
|
||||
var mandarake *Mandarake
|
||||
if err := r.db.
|
||||
Where("merch_uuid = ?", merchUuid).
|
||||
First(&mandarake).Error; err != nil {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ func (s *service) addMerch(payload MerchDTO, userUuid string) error {
|
|||
merchUuid := uuid.NewString()
|
||||
|
||||
bundle := merchBundle{
|
||||
Merch{
|
||||
&Merch{
|
||||
CreatedAt: time.Time{},
|
||||
UpdatedAt: sql.NullTime{Valid: false},
|
||||
DeletedAt: sql.NullTime{Valid: false},
|
||||
|
|
@ -30,14 +30,14 @@ func (s *service) addMerch(payload MerchDTO, userUuid string) error {
|
|||
Name: payload.Name,
|
||||
},
|
||||
|
||||
Surugaya{
|
||||
&Surugaya{
|
||||
DeletedAt: sql.NullTime{},
|
||||
MerchUuid: merchUuid,
|
||||
Link: payload.OriginSurugaya.Link,
|
||||
CookieValues: payload.OriginSurugaya.CookieValues,
|
||||
},
|
||||
|
||||
Mandarake{
|
||||
&Mandarake{
|
||||
DeletedAt: sql.NullTime{},
|
||||
MerchUuid: merchUuid,
|
||||
Link: payload.OriginMandarake.Link,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue