Feat: get share info / unlock share
This commit is contained in:
@@ -19,11 +19,6 @@ type ShareCreateService struct {
|
||||
Score int `json:"score" binding:"gte=0"`
|
||||
}
|
||||
|
||||
// ShareGetService 获取分享服务
|
||||
type ShareGetService struct {
|
||||
Password string `form:"password" binding:"max=255"`
|
||||
}
|
||||
|
||||
// Create 创建新分享
|
||||
func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
|
||||
user := currentUser(c)
|
||||
@@ -51,11 +46,12 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
|
||||
}
|
||||
|
||||
newShare := model.Share{
|
||||
Password: service.Password,
|
||||
IsDir: service.IsDir,
|
||||
UserID: user.ID,
|
||||
SourceID: service.SourceID,
|
||||
Score: service.Score,
|
||||
Password: service.Password,
|
||||
IsDir: service.IsDir,
|
||||
UserID: user.ID,
|
||||
SourceID: service.SourceID,
|
||||
Score: service.Score,
|
||||
RemainDownloads: -1,
|
||||
}
|
||||
|
||||
// 如果开启了自动过期
|
||||
@@ -85,20 +81,6 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
|
||||
|
||||
}
|
||||
|
||||
// Get 获取分享内容
|
||||
func (service *ShareGetService) Get(c *gin.Context) serializer.Response {
|
||||
user := currentUser(c)
|
||||
share := model.GetShareByHashID(c.Param("id"))
|
||||
if share == nil {
|
||||
return serializer.Err(serializer.CodeNotFound, "分享不存在或已被取消", nil)
|
||||
}
|
||||
|
||||
return serializer.Response{
|
||||
Code: 0,
|
||||
Data: user,
|
||||
}
|
||||
}
|
||||
|
||||
func currentUser(c *gin.Context) *model.User {
|
||||
var user *model.User
|
||||
if userCtx, ok := c.Get("user"); ok {
|
||||
|
||||
Reference in New Issue
Block a user