feat: 个人中心发布
This commit is contained in:
@@ -14,9 +14,11 @@ type Post struct {
|
||||
ViewCount int `json:"viewCount" form:"viewCount" gorm:"default:0;column:view_count;comment:浏览次数"`
|
||||
CommentCount int `json:"commentCount" form:"commentCount" gorm:"default:0;column:comment_count;comment:评论次数"`
|
||||
LikeCount int `json:"likeCount" form:"likeCount" gorm:"default:0;column:like_count;comment:点赞次数"`
|
||||
StarCount int `json:"starCount" form:"starCount" gorm:"default:0;column:star_count;comment:收藏次数"`
|
||||
Location string `json:"location" form:"location" gorm:"column:location;size:100;comment:位置"`
|
||||
HasReviewed int `json:"hasReviewed" form:"hasReviewed" gorm:"column:has_reviewed;default:0;comment:是否审核通过"`
|
||||
HasReviewed int `json:"hasReviewed" form:"hasReviewed" gorm:"column:has_reviewed;default:0;comment:是否审核通过"`
|
||||
HasLiked int `json:"hasLiked" form:"hasLiked" gorm:"-"`
|
||||
HasStar int `json:"hasStar" form:"hasStar" gorm:"-"`
|
||||
//图片
|
||||
ImgList []*system.Oss `json:"imgList" form:"imgList" gorm:"many2many:post_oss;comment:图片列表"`
|
||||
//评论
|
||||
|
||||
@@ -35,13 +35,14 @@ func (p *MyPlant) AfterCreate(tx *gorm.DB) (err error) {
|
||||
for _, v := range p.CarePlans {
|
||||
dueDate := today.AddDate(0, 0, v.Period)
|
||||
task := CareTask{
|
||||
UserId: p.UserId,
|
||||
PlantId: p.Id,
|
||||
PlanId: v.Id,
|
||||
Name: v.Name,
|
||||
Icon: v.Icon,
|
||||
DueDate: dueDate,
|
||||
Status: 1,
|
||||
UserId: p.UserId,
|
||||
PlantId: p.Id,
|
||||
PlanId: v.Id,
|
||||
Name: v.Name,
|
||||
Icon: v.Icon,
|
||||
TargetAction: v.TargetAction,
|
||||
DueDate: dueDate,
|
||||
Status: 1,
|
||||
}
|
||||
err = tx.Create(&task).Error
|
||||
if err != nil {
|
||||
|
||||
@@ -10,11 +10,12 @@ import (
|
||||
// CarePlan 养护计划
|
||||
type CarePlan struct {
|
||||
global.BaseModel
|
||||
UserId string `json:"userId" form:"userId" gorm:"size:50;column:user_id;comment:用户id"`
|
||||
PlantId string `json:"plantId" form:"plantId" gorm:"size:50;column:plant_id;comment:植物id"`
|
||||
Icon string `json:"icon" form:"icon" gorm:"type:text;"`
|
||||
Name string `json:"name"`
|
||||
Period int `json:"period" form:"period" gorm:"column:period;comment:周期"`
|
||||
UserId string `json:"userId" form:"userId" gorm:"size:50;column:user_id;comment:用户id"`
|
||||
PlantId string `json:"plantId" form:"plantId" gorm:"index;size:50;column:plant_id;comment:植物id"`
|
||||
Icon string `json:"icon" form:"icon" gorm:"type:text;"`
|
||||
Name string `json:"name"`
|
||||
Period int `json:"period" form:"period" gorm:"column:period;comment:周期"`
|
||||
TargetAction string `gorm:"type:varchar(32);index;not null;column:target_action;comment:触发动作代码" json:"targetAction"`
|
||||
}
|
||||
|
||||
// AfterUpdate 钩子函数 修改计划后重新生成任务
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
|
||||
type CareTask struct {
|
||||
global.BaseModel
|
||||
PlantId string `json:"plantId" gorm:"index"`
|
||||
PlanId string `json:"planId" gorm:"index"`
|
||||
UserId string `json:"userId" gorm:"index"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon" gorm:"type:text"`
|
||||
DueDate time.Time `json:"dueDate"` // 应做时间(用于判断逾期)
|
||||
CompletedAt *time.Time `json:"completedAt" gorm:"column:completed_at"` // 完成时间(为nil表示未完成)
|
||||
Status int `json:"status"` // 1:待执行 2:已完成 3:已跳过
|
||||
PlantId string `json:"plantId" gorm:"index"`
|
||||
PlanId string `json:"planId" gorm:"index"`
|
||||
UserId string `json:"userId" gorm:"index"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon" gorm:"type:text"`
|
||||
TargetAction string `gorm:"type:varchar(32);index;column:target_action;comment:触发动作代码" json:"targetAction"`
|
||||
DueDate time.Time `json:"dueDate"` // 应做时间(用于判断逾期)
|
||||
CompletedAt *time.Time `json:"completedAt" gorm:"column:completed_at"` // 完成时间(为nil表示未完成)
|
||||
Status int `json:"status"` // 1:待执行 2:已完成 3:已跳过
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package request
|
||||
|
||||
type CarePlan struct {
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
TargetAction string `json:"targetAction"` // 触动的动作
|
||||
}
|
||||
type CreateCarePlan struct {
|
||||
PlantId string `json:"plantId" binding:"required"`
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
PlantId string `json:"plantId" binding:"required"`
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
TargetAction string `json:"targetAction"` // 触动的动作
|
||||
}
|
||||
type AddPlans struct {
|
||||
CarePlan []CreateCarePlan `json:"carePlan"`
|
||||
@@ -29,10 +31,11 @@ type CreateMyPlant struct {
|
||||
}
|
||||
|
||||
type UpdatePlan struct {
|
||||
Id string `json:"id" binding:"required"`
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
Id string `json:"id" binding:"required"`
|
||||
Icon string `json:"icon"` // icon信息
|
||||
Name string `json:"name"` // 农事名称
|
||||
Period int `json:"period"` // 周期
|
||||
TargetAction string `json:"targetAction"` // 触动的动作
|
||||
}
|
||||
|
||||
// UpdateMyPlant 修改植物
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package request
|
||||
|
||||
import common "sundynix-go/model/commom/request"
|
||||
|
||||
type UpdateProfile struct {
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarId string `json:"avatarId"`
|
||||
}
|
||||
|
||||
type StarsPageReq struct {
|
||||
common.PageInfo
|
||||
Class int `json:"class"` //分类 0 全部 1百科 2社交动态
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package response
|
||||
|
||||
import "sundynix-go/model/plant"
|
||||
|
||||
// TaskCompletionResult 定义返回给前端的组合对象
|
||||
type TaskCompletionResult struct {
|
||||
NewBadge *plant.BadgeConfig `json:"newBadge"` // 本次新获得的徽章,无则为 nil
|
||||
CurrentLevel *plant.LevelConfig `json:"currentLevel"` // 当前最新的等级信息
|
||||
IsLevelUp bool `json:"isLevelUp"` // 是否升级了
|
||||
IsGetBadge bool `json:"isGetBadge"` // 本次任务是否获得徽章
|
||||
}
|
||||
@@ -8,6 +8,6 @@ import (
|
||||
type UserBadge struct {
|
||||
global.BaseModel
|
||||
UserId string `gorm:"type:varchar(50);index;not null;column:user_id;comment:用户id" json:"userId"`
|
||||
BadgeId uint `gorm:"index:idx_user_badge,unique;not null;column:badge_id;comment:徽章配置ID" json:"badgeId"`
|
||||
BadgeId string `gorm:"index:idx_user_badge,unique;not null;column:badge_id;comment:徽章配置ID" json:"badgeId"`
|
||||
AcquiredAt time.Time `gorm:"autoCreateTime;column:acquired_at;comment:获得时间" json:"acquiredAt"`
|
||||
}
|
||||
|
||||
@@ -11,12 +11,17 @@ type UserProfile struct {
|
||||
MiniOpenId string `gorm:"size:80;column:mini_open_id" json:"miniOpenId" form:"miniOpenId"`
|
||||
Nickname string `json:"nickname" gorm:"column:nick_name"`
|
||||
AvatarId string `json:"avatarId" gorm:"column:avatar_id"`
|
||||
LevelId string `json:"levelId" gorm:"column:level_id"` // 当前等级id
|
||||
CurrentSunlight int64 `json:"currentSunlight" gorm:"column:current_sunlight"` // 当前持有阳光值 (可消耗)
|
||||
TotalSunlight int64 `json:"totalSunlight" gorm:"column:total_sunlight"` // 历史累计阳光值 (用于计算等级)
|
||||
PlantCount int64 `json:"plantCount" gorm:"column:plant_count"`
|
||||
CareCount int64 `json:"careCount" gorm:"column:care_count"`
|
||||
PostCount int64 `json:"postCount" gorm:"column:post_count"`
|
||||
LevelId string `json:"levelId" gorm:"column:level_id"` // 当前等级id
|
||||
CurrentSunlight int64 `json:"currentSunlight" gorm:"not null;default:0;column:current_sunlight"` // 当前持有阳光值 (可消耗)
|
||||
TotalSunlight int64 `json:"totalSunlight" gorm:"not null;default:0;column:total_sunlight"` // 历史累计阳光值 (用于计算等级)
|
||||
PlantCount int64 `json:"plantCount" gorm:"not null;default:0;column:plant_count"`
|
||||
CareCount int64 `json:"careCount" gorm:"not null;default:0;column:care_count"`
|
||||
PostCount int64 `json:"postCount" gorm:"not null;default:0;column:post_count"`
|
||||
WaterCount int64 `json:"waterCount" gorm:"not null;default:0;column:water_count"` // 浇水次数
|
||||
FertilizeCount int64 `json:"fertilizeCount" gorm:"not null;default:0;column:fertilize_count"` // 施肥次数
|
||||
RepotCount int64 `json:"repotCount" gorm:"not null;default:0;column:repot_count"` // 换盆次数
|
||||
PruneCount int64 `json:"pruneCount" gorm:"not null;default:0;column:prune_count"` // 剪枝次数
|
||||
PhotoCount int64 `json:"photoCount" gorm:"not null;default:0;column:photo_count"` // 拍照次数
|
||||
Avatar *system.Oss `json:"avatar" gorm:"foreignKey:AvatarId"`
|
||||
Level *LevelConfig `json:"level" gorm:"foreignKey:LevelId"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package plant
|
||||
|
||||
import "sundynix-go/global"
|
||||
|
||||
type UserStar struct {
|
||||
global.BaseModel
|
||||
UserId string `json:"userId" gorm:"index"`
|
||||
Type int `json:"type" gorm:"index"` //1.百科 //2.社交动态
|
||||
WikiId string `json:"wikiId" gorm:"index"`
|
||||
PostId string `json:"postId" gorm:"index"`
|
||||
Wiki *Wiki `json:"wiki" gorm:"foreignKey:WikiId"`
|
||||
Post *Post `json:"post" gorm:"foreignKey:PostId"`
|
||||
}
|
||||
+2
-1
@@ -39,7 +39,8 @@ type Wiki struct {
|
||||
FloweringShape string `json:"floweringShape" form:"floweringShape" gorm:"size:100;column:flowering_shape;comment:开花形状"`
|
||||
FlowerDiameter int `json:"flowerDiameter" form:"flowerDiameter" gorm:"size:10;column:flower_diameter;comment:花直径"`
|
||||
//果
|
||||
Fruit string `json:"fruit" form:"fruit" gorm:"size:200;column:fruit;comment:果实"`
|
||||
Fruit string `json:"fruit" form:"fruit" gorm:"size:200;column:fruit;comment:果实"`
|
||||
HasStar int `json:"hasStar" form:"hasStar" gorm:"-"`
|
||||
|
||||
//相关推荐
|
||||
RelatedWiki []*Wiki `gorm:"many2many:wiki_related;" json:"relatedWiki"`
|
||||
|
||||
Reference in New Issue
Block a user