优化页面展示
This commit is contained in:
1 parent
cbcd6b4c7f
commit
1ed38c6648
67 files changed
+4484
-370
No files matched your search
@@ -1,12 +1,21 @@
|
||||
package com.babytracker;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.babytracker.module.**.mapper")
|
||||
public class BabyTrackerApplication {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BabyTrackerApplication.class, args);
|
||||
}
|
||||
|
||||
@@ -11,22 +11,40 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public abstract class BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除状态: 0未删除, 1已删除
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(value = "deleted", fill = FieldFill.INSERT)
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "created_by", fill = FieldFill.INSERT)
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -16,27 +16,51 @@ import java.time.temporal.ChronoUnit;
|
||||
@TableName("baby_profile")
|
||||
public class BabyProfile extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 宝宝ID,雪花ID字符串
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
@TableField("family_id")
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝姓名或昵称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别: boy(男宝), girl(女宝), unknown(未知)
|
||||
*/
|
||||
@TableField("gender")
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
@TableField("birth_date")
|
||||
private LocalDate birthDate;
|
||||
|
||||
/**
|
||||
* 分娩方式: natural(顺产), c_section(剖腹产), unknown(未知)
|
||||
*/
|
||||
@TableField("delivery_type")
|
||||
private String deliveryType;
|
||||
|
||||
/**
|
||||
* 是否默认宝宝: 0否, 1是
|
||||
*/
|
||||
@TableField("is_default")
|
||||
private Integer isDefault;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -7,19 +7,78 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class BabyDTO {
|
||||
/**
|
||||
* 宝宝ID,雪花ID字符串
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝姓名或昵称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别: boy(男宝), girl(女宝), unknown(未知)
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private LocalDate birthDate;
|
||||
|
||||
/**
|
||||
* 分娩方式: natural(顺产), c_section(剖腹产), unknown(未知)
|
||||
*/
|
||||
private String deliveryType;
|
||||
|
||||
/**
|
||||
* 是否默认宝宝: 0否, 1是
|
||||
*/
|
||||
private Integer isDefault;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 出生天数
|
||||
*/
|
||||
private long ageDays;
|
||||
|
||||
/**
|
||||
* 月龄/天数文案描述(如: 出生第 3 天)
|
||||
*/
|
||||
private String ageText;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -5,18 +5,39 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateBabyRO {
|
||||
/**
|
||||
* 所属家庭ID,选填(不填则默认为当前活跃家庭)
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝姓名或昵称
|
||||
*/
|
||||
@NotBlank(message = "宝宝姓名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别: boy(男宝), girl(女宝), unknown(未知)
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 出生日期 (格式: yyyy-MM-dd)
|
||||
*/
|
||||
private String birthDate;
|
||||
|
||||
/**
|
||||
* 分娩方式: natural(顺产), c_section(剖腹产), unknown(未知)
|
||||
*/
|
||||
private String deliveryType;
|
||||
|
||||
/**
|
||||
* 是否设置为当前默认宝宝
|
||||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SetDefaultBabyRO {
|
||||
/**
|
||||
* 目标宝宝ID
|
||||
*/
|
||||
@NotBlank(message = "宝宝ID不能为空")
|
||||
private String babyId;
|
||||
}
|
||||
@@ -5,16 +5,34 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateBabyRO {
|
||||
/**
|
||||
* 宝宝ID(选填,不填则默认修改当前宝宝)
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 宝宝姓名或昵称
|
||||
*/
|
||||
@NotBlank(message = "宝宝姓名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别: boy(男宝), girl(女宝), unknown(未知)
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 出生日期 (格式: yyyy-MM-dd)
|
||||
*/
|
||||
private String birthDate;
|
||||
|
||||
/**
|
||||
* 分娩方式: natural(顺产), c_section(剖腹产), unknown(未知)
|
||||
*/
|
||||
private String deliveryType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -7,20 +7,79 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class BabyVO {
|
||||
/**
|
||||
* 宝宝ID,雪花ID字符串
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝姓名或昵称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 性别: boy(男宝), girl(女宝), unknown(未知)
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private LocalDate birthDate;
|
||||
|
||||
/**
|
||||
* 分娩方式: natural(顺产), c_section(剖腹产), unknown(未知)
|
||||
*/
|
||||
private String deliveryType;
|
||||
|
||||
/**
|
||||
* 是否默认宝宝: 0否, 1是
|
||||
*/
|
||||
private Integer isDefault;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 出生天数
|
||||
*/
|
||||
private long ageDays;
|
||||
|
||||
/**
|
||||
* 月龄/天数文案描述(如: 出生第 3 天)
|
||||
*/
|
||||
private String ageText;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
|
||||
@@ -13,15 +13,27 @@ import lombok.EqualsAndHashCode;
|
||||
@TableName("family")
|
||||
public class FamilyInfo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 家庭ID,雪花ID字符串
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 家庭共享邀请码
|
||||
*/
|
||||
@TableField("invite_code")
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
}
|
||||
@@ -13,24 +13,45 @@ import lombok.EqualsAndHashCode;
|
||||
@TableName("family_member")
|
||||
public class FamilyMember extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 成员记录ID,雪花ID字符串
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
@TableField("family_id")
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 关联用户ID(未绑定系统用户时可为空)
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 角色称谓(如: 宝妈、宝爸、月嫂、奶奶、外婆)
|
||||
*/
|
||||
@TableField("role_name")
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限类型: owner(家庭主理人), caregiver(看护成员)
|
||||
*/
|
||||
@TableField("role_type")
|
||||
private String roleType;
|
||||
|
||||
/**
|
||||
* 是否当前默认记录人
|
||||
*/
|
||||
@TableField("is_default_operator")
|
||||
private boolean defaultOperator;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
}
|
||||
@@ -6,13 +6,48 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FamilyDTO {
|
||||
/**
|
||||
* 家庭ID,雪花ID字符串
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 家庭共享邀请码
|
||||
*/
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -6,16 +6,63 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FamilyMemberDTO {
|
||||
/**
|
||||
* 成员ID,雪花ID字符串
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 关联用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 角色称谓(如: 宝妈、宝爸、月嫂、奶奶)
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限类型: owner(主理人), caregiver(看护人), viewer(观察者)
|
||||
*/
|
||||
private String roleType;
|
||||
|
||||
/**
|
||||
* 是否当前默认记录人
|
||||
*/
|
||||
private boolean defaultOperator;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -5,14 +5,29 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateMemberRO {
|
||||
/**
|
||||
* 所属家庭ID,选填(不填则默认为当前活跃家庭)
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 角色称谓(如: 宝妈、宝爸、月嫂、奶奶)
|
||||
*/
|
||||
@NotBlank(message = "角色称谓不能为空")
|
||||
private String roleName;
|
||||
|
||||
private String roleType; // owner, caregiver, viewer
|
||||
/**
|
||||
* 权限角色类型: owner(主理人), caregiver(看护人), viewer(观察者)
|
||||
*/
|
||||
private String roleType;
|
||||
|
||||
/**
|
||||
* 是否设为默认记录人
|
||||
*/
|
||||
private Boolean defaultOperator;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -5,8 +5,14 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeleteMemberRO {
|
||||
/**
|
||||
* 家庭ID,选填
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 待删除的成员ID
|
||||
*/
|
||||
@NotBlank(message = "成员ID不能为空")
|
||||
private String memberId;
|
||||
}
|
||||
@@ -5,12 +5,24 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateFamilyRO {
|
||||
/**
|
||||
* 家庭ID(选填,不填则默认修改当前家庭)
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
*/
|
||||
@NotBlank(message = "家庭名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 家庭共享邀请码
|
||||
*/
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -5,17 +5,35 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateMemberRO {
|
||||
/**
|
||||
* 家庭ID,选填
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 成员ID
|
||||
*/
|
||||
@NotBlank(message = "成员ID不能为空")
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 角色称谓(如: 宝妈、宝爸、月嫂、奶奶)
|
||||
*/
|
||||
@NotBlank(message = "角色称谓不能为空")
|
||||
private String roleName;
|
||||
|
||||
private String roleType; // owner, caregiver, viewer
|
||||
/**
|
||||
* 权限角色类型: owner(主理人), caregiver(看护人), viewer(观察者)
|
||||
*/
|
||||
private String roleType;
|
||||
|
||||
/**
|
||||
* 是否设为默认记录人
|
||||
*/
|
||||
private Boolean defaultOperator;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -7,7 +7,18 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FamilyContextVO {
|
||||
/**
|
||||
* 当前家庭信息
|
||||
*/
|
||||
private FamilyVO family;
|
||||
|
||||
/**
|
||||
* 家庭下的宝宝档案列表
|
||||
*/
|
||||
private List<BabyVO> babies;
|
||||
|
||||
/**
|
||||
* 家庭成员列表
|
||||
*/
|
||||
private List<FamilyMemberVO> members;
|
||||
}
|
||||
@@ -6,17 +6,64 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FamilyMemberVO {
|
||||
/**
|
||||
* 成员ID,雪花ID字符串
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 所属家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 关联用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 角色称谓(如: 宝妈、宝爸、月嫂、奶奶)
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限类型: owner(主理人), caregiver(看护人), viewer(观察者)
|
||||
*/
|
||||
private String roleType;
|
||||
|
||||
/**
|
||||
* 是否当前默认记录人
|
||||
*/
|
||||
private boolean defaultOperator;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
|
||||
@@ -6,14 +6,49 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FamilyVO {
|
||||
/**
|
||||
* 家庭ID,雪花ID字符串
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 家庭名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 家庭共享邀请码
|
||||
*/
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 状态: active(正常), archived(归档)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
|
||||
@@ -16,42 +16,93 @@ import java.time.LocalDateTime;
|
||||
@TableName("care_record")
|
||||
public class CareRecord extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 记录ID,雪花ID字符串
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String recordId;
|
||||
|
||||
/**
|
||||
* 家庭ID
|
||||
*/
|
||||
@TableField("family_id")
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
@TableField("baby_id")
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 记录类型: feeding(喂奶), sleep(睡眠), excretion(排泄)
|
||||
*/
|
||||
@TableField("record_type")
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 开始时间 / 发生时间
|
||||
*/
|
||||
@TableField("start_time")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间(可选,计时类项目结束时填充)
|
||||
*/
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时长(分钟)
|
||||
*/
|
||||
@TableField("duration_minutes")
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
@TableField("left_duration_minutes")
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
@TableField("right_duration_minutes")
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
@TableField("feeding_method")
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 奶量(毫升 ml,瓶喂/配方奶时填写)
|
||||
*/
|
||||
@TableField("amount_ml")
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 排泄类型: pee(小便), poop(大便)
|
||||
*/
|
||||
@TableField("excretion_type")
|
||||
private String excretionType;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
@TableField("operator_name")
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 记录人用户ID(可选)
|
||||
*/
|
||||
@TableField("operator_user_id")
|
||||
private String operatorUserId;
|
||||
|
||||
/**
|
||||
* 记录来源: h5, miniapp, admin, system
|
||||
*/
|
||||
@TableField("source")
|
||||
private String source = "h5";
|
||||
|
||||
|
||||
@@ -28,27 +28,50 @@ public class CareRecordService {
|
||||
private final SnowflakeIdGenerator idGenerator;
|
||||
|
||||
public List<CareRecordVO> list(String babyId, LocalDate date) {
|
||||
LocalDate targetDate = date == null ? LocalDate.now() : date;
|
||||
LocalDateTime dayStart = targetDate.atStartOfDay();
|
||||
LocalDateTime dayEnd = targetDate.plusDays(1).atStartOfDay();
|
||||
LambdaQueryWrapper<CareRecord> wrapper = new LambdaQueryWrapper<CareRecord>()
|
||||
.eq(CareRecord::getBabyId, babyId);
|
||||
if (date != null) {
|
||||
LocalDateTime dayStart = date.atStartOfDay();
|
||||
LocalDateTime dayEnd = date.plusDays(1).atStartOfDay();
|
||||
wrapper.ge(CareRecord::getStartTime, dayStart)
|
||||
.lt(CareRecord::getStartTime, dayEnd);
|
||||
}
|
||||
wrapper.orderByDesc(CareRecord::getStartTime)
|
||||
.orderByDesc(CareRecord::getRecordId);
|
||||
|
||||
List<CareRecord> records = careRecordMapper.selectList(
|
||||
new LambdaQueryWrapper<CareRecord>()
|
||||
.eq(CareRecord::getBabyId, babyId)
|
||||
.ge(CareRecord::getStartTime, dayStart)
|
||||
.lt(CareRecord::getStartTime, dayEnd)
|
||||
.orderByDesc(CareRecord::getStartTime)
|
||||
.orderByDesc(CareRecord::getRecordId)
|
||||
);
|
||||
List<CareRecord> records = careRecordMapper.selectList(wrapper);
|
||||
return CareRecordConvert.toVOList(records);
|
||||
}
|
||||
|
||||
public CareRecordVO createFeeding(CreateFeedingRO request) {
|
||||
CareRecord record = baseRecord(request.getBabyId(), "feeding", request.getFeedingTime(), request.getOperatorName(), request.getRemark());
|
||||
String remark = "breastfeed".equals(request.getFeedingMethod()) ? buildFeedingRemark(request) : request.getRemark();
|
||||
LocalDateTime startTime = request.getFeedingTime() == null ? LocalDateTime.now() : request.getFeedingTime();
|
||||
LocalDateTime endTime = request.getEndTime();
|
||||
Integer duration = request.getDurationMinutes();
|
||||
|
||||
if (duration == null && (request.getLeftDurationMinutes() != null || request.getRightDurationMinutes() != null)) {
|
||||
int sum = (request.getLeftDurationMinutes() == null ? 0 : request.getLeftDurationMinutes())
|
||||
+ (request.getRightDurationMinutes() == null ? 0 : request.getRightDurationMinutes());
|
||||
if (sum > 0) {
|
||||
duration = sum;
|
||||
}
|
||||
}
|
||||
|
||||
if (endTime == null && duration != null && duration > 0) {
|
||||
// 如果未传结束时间但传入了总时长,则以当前时间为结束时间,开始时间向前推导
|
||||
endTime = startTime;
|
||||
startTime = startTime.minusMinutes(duration);
|
||||
}
|
||||
|
||||
CareRecord record = baseRecord(request.getBabyId(), "feeding", startTime, request.getOperatorName(), remark);
|
||||
record.setFeedingMethod(request.getFeedingMethod());
|
||||
record.setAmountMl(request.getAmountMl());
|
||||
record.setEndTime(request.getEndTime());
|
||||
if (record.getStartTime() != null && record.getEndTime() != null) {
|
||||
record.setEndTime(endTime);
|
||||
record.setLeftDurationMinutes(request.getLeftDurationMinutes());
|
||||
record.setRightDurationMinutes(request.getRightDurationMinutes());
|
||||
if (duration != null) {
|
||||
record.setDurationMinutes(duration);
|
||||
} else if (record.getStartTime() != null && record.getEndTime() != null) {
|
||||
record.recalculateDuration();
|
||||
}
|
||||
careRecordMapper.insert(record);
|
||||
@@ -62,6 +85,8 @@ public class CareRecordService {
|
||||
}
|
||||
CareRecord record = baseRecord(request.getBabyId(), "feeding", request.getFeedingTime(), request.getOperatorName(), buildFeedingRemark(request));
|
||||
record.setFeedingMethod("breastfeed");
|
||||
record.setLeftDurationMinutes(request.getLeftDurationMinutes());
|
||||
record.setRightDurationMinutes(request.getRightDurationMinutes());
|
||||
careRecordMapper.insert(record);
|
||||
return CareRecordConvert.toVO(record);
|
||||
}
|
||||
@@ -76,10 +101,23 @@ public class CareRecordService {
|
||||
throw new BusinessException("INVALID_FEEDING_TIME", "喂奶结束时间不能早于开始时间");
|
||||
}
|
||||
activeFeeding.setEndTime(end);
|
||||
if (request.getLeftDurationMinutes() != null) {
|
||||
activeFeeding.setLeftDurationMinutes(request.getLeftDurationMinutes());
|
||||
}
|
||||
if (request.getRightDurationMinutes() != null) {
|
||||
activeFeeding.setRightDurationMinutes(request.getRightDurationMinutes());
|
||||
}
|
||||
if (request.getRemark() != null) {
|
||||
activeFeeding.setRemark(buildFeedingRemark(request));
|
||||
activeFeeding.setRemark(request.getRemark().trim().isEmpty() ? null : request.getRemark().trim());
|
||||
}
|
||||
activeFeeding.recalculateDuration();
|
||||
if (request.getLeftDurationMinutes() != null || request.getRightDurationMinutes() != null) {
|
||||
int sumSplit = (activeFeeding.getLeftDurationMinutes() == null ? 0 : activeFeeding.getLeftDurationMinutes())
|
||||
+ (activeFeeding.getRightDurationMinutes() == null ? 0 : activeFeeding.getRightDurationMinutes());
|
||||
if (sumSplit > 0 && (activeFeeding.getDurationMinutes() == null || activeFeeding.getDurationMinutes() < sumSplit)) {
|
||||
activeFeeding.setDurationMinutes(sumSplit);
|
||||
}
|
||||
}
|
||||
careRecordMapper.updateById(activeFeeding);
|
||||
return CareRecordConvert.toVO(activeFeeding);
|
||||
}
|
||||
@@ -137,6 +175,8 @@ public class CareRecordService {
|
||||
record.recalculateDuration();
|
||||
}
|
||||
record.setFeedingMethod(request.getFeedingMethod());
|
||||
record.setLeftDurationMinutes(request.getLeftDurationMinutes());
|
||||
record.setRightDurationMinutes(request.getRightDurationMinutes());
|
||||
record.setAmountMl(request.getAmountMl());
|
||||
record.setExcretionType(request.getExcretionType());
|
||||
record.setOperatorName(request.getOperatorName() == null || request.getOperatorName().trim().isEmpty() ? "宝妈" : request.getOperatorName().trim());
|
||||
@@ -173,6 +213,12 @@ public class CareRecordService {
|
||||
if (request.getFeedingMethod() != null) {
|
||||
record.setFeedingMethod(request.getFeedingMethod());
|
||||
}
|
||||
if (request.getLeftDurationMinutes() != null) {
|
||||
record.setLeftDurationMinutes(request.getLeftDurationMinutes());
|
||||
}
|
||||
if (request.getRightDurationMinutes() != null) {
|
||||
record.setRightDurationMinutes(request.getRightDurationMinutes());
|
||||
}
|
||||
if (request.getAmountMl() != null) {
|
||||
record.setAmountMl(request.getAmountMl());
|
||||
}
|
||||
@@ -231,16 +277,11 @@ public class CareRecordService {
|
||||
}
|
||||
|
||||
private String buildFeedingRemark(CreateFeedingRO request) {
|
||||
String side = request.getBreastSide();
|
||||
String remark = request.getRemark();
|
||||
if (side == null || side.trim().isEmpty()) {
|
||||
return remark;
|
||||
if (remark != null && !remark.trim().isEmpty()) {
|
||||
return remark.trim();
|
||||
}
|
||||
String sideText = "left".equals(side) ? "左侧" : "right".equals(side) ? "右侧" : side.trim();
|
||||
if (remark == null || remark.trim().isEmpty()) {
|
||||
return "亲喂侧: " + sideText;
|
||||
}
|
||||
return "亲喂侧: " + sideText + ";" + remark.trim();
|
||||
return null;
|
||||
}
|
||||
|
||||
private CareRecordVO createExcretion(ExcretionRO request, String excretionType) {
|
||||
|
||||
@@ -23,6 +23,8 @@ public final class CareRecordConvert {
|
||||
vo.setStartTime(entity.getStartTime());
|
||||
vo.setEndTime(entity.getEndTime());
|
||||
vo.setDurationMinutes(entity.getDurationMinutes());
|
||||
vo.setLeftDurationMinutes(entity.getLeftDurationMinutes());
|
||||
vo.setRightDurationMinutes(entity.getRightDurationMinutes());
|
||||
vo.setFeedingMethod(entity.getFeedingMethod());
|
||||
vo.setAmountMl(entity.getAmountMl());
|
||||
vo.setExcretionType(entity.getExcretionType());
|
||||
@@ -62,6 +64,8 @@ public final class CareRecordConvert {
|
||||
dto.setStartTime(entity.getStartTime());
|
||||
dto.setEndTime(entity.getEndTime());
|
||||
dto.setDurationMinutes(entity.getDurationMinutes());
|
||||
dto.setLeftDurationMinutes(entity.getLeftDurationMinutes());
|
||||
dto.setRightDurationMinutes(entity.getRightDurationMinutes());
|
||||
dto.setFeedingMethod(entity.getFeedingMethod());
|
||||
dto.setAmountMl(entity.getAmountMl());
|
||||
dto.setExcretionType(entity.getExcretionType());
|
||||
|
||||
@@ -6,23 +6,108 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CareRecordDTO {
|
||||
/**
|
||||
* 记录ID,雪花ID字符串
|
||||
*/
|
||||
private String recordId;
|
||||
|
||||
/**
|
||||
* 家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 记录类型: feeding(喂奶), sleep(睡眠), excretion(排泄)
|
||||
*/
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 开始时间 / 发生时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时长(分钟)
|
||||
*/
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 奶量(毫升 ml)
|
||||
*/
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 排泄类型: pee(小便), poop(大便)
|
||||
*/
|
||||
private String excretionType;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 记录人用户ID
|
||||
*/
|
||||
private String operatorUserId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 来源: h5, miniapp, admin, system
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 删除状态: 0未删除, 1已删除
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -7,17 +7,61 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CreateFeedingRO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
@NotBlank(message = "宝宝ID不能为空")
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
@NotBlank(message = "喂养方式不能为空")
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 喂奶开始时间(不传默认当前时间)
|
||||
*/
|
||||
private LocalDateTime feedingTime;
|
||||
|
||||
/**
|
||||
* 喂奶结束时间(可选)
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 喂奶总时长(分钟)
|
||||
*/
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶量(毫升 ml,瓶喂/配方奶时使用)
|
||||
*/
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 亲喂侧别: left(左侧), right(右侧), both(双侧)
|
||||
*/
|
||||
private String breastSide;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -8,21 +8,67 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CreateManualRecordRO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
@NotBlank(message = "宝宝ID不能为空")
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 记录类型: feeding(喂奶), sleep(睡眠), excretion(排泄)
|
||||
*/
|
||||
@NotBlank(message = "记录类型不能为空")
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 开始时间 / 发生时间
|
||||
*/
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间(可选)
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时长(分钟)
|
||||
*/
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 奶量(毫升 ml,瓶喂/配方奶时使用)
|
||||
*/
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 排泄类型: pee(小便), poop(大便)
|
||||
*/
|
||||
private String excretionType;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeleteCareRecordRO {
|
||||
/**
|
||||
* 待删除的照护记录ID
|
||||
*/
|
||||
@NotBlank(message = "记录ID不能为空")
|
||||
private String recordId;
|
||||
}
|
||||
@@ -7,11 +7,25 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ExcretionRO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
@NotBlank(message = "宝宝ID不能为空")
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 发生时间(不传默认当前时间)
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -7,11 +7,25 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SleepRO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
@NotBlank(message = "宝宝ID不能为空")
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 睡眠开始或结束时间(不传默认当前时间)
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -7,17 +7,65 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class UpdateCareRecordRO {
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@NotBlank(message = "记录ID不能为空")
|
||||
private String recordId;
|
||||
|
||||
/**
|
||||
* 记录类型: feeding(喂奶), sleep(睡眠), excretion(排泄)
|
||||
*/
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 开始时间 / 发生时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时长(分钟)
|
||||
*/
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 奶量(毫升 ml)
|
||||
*/
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 排泄类型: pee(小便), poop(大便)
|
||||
*/
|
||||
private String excretionType;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -6,25 +6,114 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CareRecordVO {
|
||||
/**
|
||||
* 记录ID,雪花ID字符串
|
||||
*/
|
||||
private String recordId;
|
||||
|
||||
/**
|
||||
* 家庭ID
|
||||
*/
|
||||
private String familyId;
|
||||
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 记录类型: feeding(喂奶), sleep(睡眠), excretion(排泄)
|
||||
*/
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 开始时间 / 发生时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时长(分钟)
|
||||
*/
|
||||
private Integer durationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂左侧时长(分钟)
|
||||
*/
|
||||
private Integer leftDurationMinutes;
|
||||
|
||||
/**
|
||||
* 亲喂右侧时长(分钟)
|
||||
*/
|
||||
private Integer rightDurationMinutes;
|
||||
|
||||
/**
|
||||
* 喂奶方式: breastfeed(亲喂), bottle(瓶喂), formula(配方奶), mixed(混合喂养), other(其他)
|
||||
*/
|
||||
private String feedingMethod;
|
||||
|
||||
/**
|
||||
* 奶量(毫升 ml)
|
||||
*/
|
||||
private Integer amountMl;
|
||||
|
||||
/**
|
||||
* 排泄类型: pee(小便), poop(大便)
|
||||
*/
|
||||
private String excretionType;
|
||||
|
||||
/**
|
||||
* 记录人称谓(如: 宝妈、宝爸、月嫂)
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 记录人用户ID
|
||||
*/
|
||||
private String operatorUserId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 兼容旧版备注字段
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* 来源: h5, miniapp, admin, system
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 删除状态: 0未删除, 1已删除
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
public String getNote() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -14,10 +15,11 @@ import java.util.Map;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SummaryService {
|
||||
private static final ZoneId SHANGHAI_ZONE = ZoneId.of("Asia/Shanghai");
|
||||
private final CareRecordService careRecordService;
|
||||
|
||||
public DailySummaryVO daily(String babyId, LocalDate date) {
|
||||
LocalDate targetDate = date == null ? LocalDate.now() : date;
|
||||
LocalDate targetDate = date == null ? LocalDate.now(SHANGHAI_ZONE) : date;
|
||||
List<CareRecordVO> timeline = careRecordService.list(babyId, targetDate);
|
||||
DailySummaryVO summary = new DailySummaryVO();
|
||||
summary.setBabyId(babyId);
|
||||
|
||||
@@ -8,15 +8,58 @@ import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class DailySummaryDTO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 汇总日期 (yyyy-MM-dd)
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 今日喂奶总次数
|
||||
*/
|
||||
private int feedingCount;
|
||||
|
||||
/**
|
||||
* 今日各喂奶方式次数统计(key: feedingMethod, value: 次数)
|
||||
*/
|
||||
private Map<String, Integer> feedingMethodCounts;
|
||||
|
||||
/**
|
||||
* 今日睡眠总时长(分钟)
|
||||
*/
|
||||
private int sleepTotalMinutes;
|
||||
|
||||
/**
|
||||
* 今日小便次数
|
||||
*/
|
||||
private int peeCount;
|
||||
|
||||
/**
|
||||
* 今日大便次数
|
||||
*/
|
||||
private int poopCount;
|
||||
|
||||
/**
|
||||
* 最近一次喂奶记录
|
||||
*/
|
||||
private CareRecordDTO lastFeeding;
|
||||
|
||||
/**
|
||||
* 当前进行中的亲喂记录(若无则为 null)
|
||||
*/
|
||||
private CareRecordDTO activeFeeding;
|
||||
|
||||
/**
|
||||
* 当前进行中的睡眠记录(若无则为 null)
|
||||
*/
|
||||
private CareRecordDTO activeSleep;
|
||||
|
||||
/**
|
||||
* 今日照护事件时间轴列表
|
||||
*/
|
||||
private List<CareRecordDTO> timeline;
|
||||
}
|
||||
@@ -7,8 +7,14 @@ import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class SummaryQueryRO {
|
||||
/**
|
||||
* 宝宝ID(选填,不填则默认查询当前宝宝)
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 汇总日期(选填,格式 yyyy-MM-dd,不传默认当日)
|
||||
*/
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
private LocalDate date;
|
||||
}
|
||||
@@ -8,15 +8,58 @@ import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class DailySummaryVO {
|
||||
/**
|
||||
* 宝宝ID
|
||||
*/
|
||||
private String babyId;
|
||||
|
||||
/**
|
||||
* 汇总日期 (yyyy-MM-dd)
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 今日喂奶总次数
|
||||
*/
|
||||
private int feedingCount;
|
||||
|
||||
/**
|
||||
* 今日各喂奶方式次数统计(key: feedingMethod, value: 次数)
|
||||
*/
|
||||
private Map<String, Integer> feedingMethodCounts;
|
||||
|
||||
/**
|
||||
* 今日睡眠总时长(分钟)
|
||||
*/
|
||||
private int sleepTotalMinutes;
|
||||
|
||||
/**
|
||||
* 今日小便次数
|
||||
*/
|
||||
private int peeCount;
|
||||
|
||||
/**
|
||||
* 今日大便次数
|
||||
*/
|
||||
private int poopCount;
|
||||
|
||||
/**
|
||||
* 最近一次喂奶记录
|
||||
*/
|
||||
private CareRecordVO lastFeeding;
|
||||
|
||||
/**
|
||||
* 当前进行中的亲喂记录(若无则为 null)
|
||||
*/
|
||||
private CareRecordVO activeFeeding;
|
||||
|
||||
/**
|
||||
* 当前进行中的睡眠记录(若无则为 null)
|
||||
*/
|
||||
private CareRecordVO activeSleep;
|
||||
|
||||
/**
|
||||
* 今日照护事件时间轴列表
|
||||
*/
|
||||
private List<CareRecordVO> timeline;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.babytracker.module.system;
|
||||
|
||||
import com.babytracker.common.response.ApiResponse;
|
||||
import com.babytracker.module.system.vo.ServerTimeVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 系统通用接口控制器
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v1/system")
|
||||
public class SystemController {
|
||||
|
||||
private static final ZoneId SHANGHAI_ZONE = ZoneId.of("Asia/Shanghai");
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
|
||||
/**
|
||||
* 获取服务器当前时间信息(支持 GET 请求)
|
||||
*/
|
||||
@GetMapping("/time")
|
||||
public ApiResponse<ServerTimeVO> getServerTime() {
|
||||
return ApiResponse.ok(buildServerTimeVO());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器当前时间信息(支持 POST 请求)
|
||||
*/
|
||||
@PostMapping("/time")
|
||||
public ApiResponse<ServerTimeVO> getServerTimeByPost() {
|
||||
return ApiResponse.ok(buildServerTimeVO());
|
||||
}
|
||||
|
||||
private ServerTimeVO buildServerTimeVO() {
|
||||
ZonedDateTime now = ZonedDateTime.now(SHANGHAI_ZONE);
|
||||
return ServerTimeVO.builder()
|
||||
.serverTime(now.toLocalDateTime())
|
||||
.currentDate(now.format(DATE_FORMATTER))
|
||||
.currentTime(now.format(TIME_FORMATTER))
|
||||
.timeZone(SHANGHAI_ZONE.getId())
|
||||
.timestamp(now.toInstant().toEpochMilli())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.babytracker.module.system.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 服务器当前时间信息响应体
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServerTimeVO {
|
||||
|
||||
/**
|
||||
* 服务器当前日期时间 (格式: yyyy-MM-dd HH:mm:ss)
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime serverTime;
|
||||
|
||||
/**
|
||||
* 服务器当前日期 (格式: yyyy-MM-dd)
|
||||
*/
|
||||
private String currentDate;
|
||||
|
||||
/**
|
||||
* 服务器当前时间 (格式: HH:mm:ss)
|
||||
*/
|
||||
private String currentTime;
|
||||
|
||||
/**
|
||||
* 服务器时区 (如: Asia/Shanghai)
|
||||
*/
|
||||
private String timeZone;
|
||||
|
||||
/**
|
||||
* 服务器当前时间戳毫秒数
|
||||
*/
|
||||
private Long timestamp;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ spring:
|
||||
flyway:
|
||||
enabled: true
|
||||
baseline-on-migrate: true
|
||||
baseline-version: 0
|
||||
baseline-version: 3
|
||||
locations: classpath:db/migration
|
||||
jackson:
|
||||
time-zone: Asia/Shanghai
|
||||
|
||||
@@ -64,4 +64,26 @@ class BabyTrackerApplicationTests {
|
||||
// 测试逻辑删除
|
||||
careRecordService.delete(created.getRecordId());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private com.babytracker.module.system.SystemController systemController;
|
||||
|
||||
@Test
|
||||
void testSystemTimeEndpoint() {
|
||||
var getResp = systemController.getServerTime();
|
||||
assertNotNull(getResp);
|
||||
assertTrue(getResp.isSuccess());
|
||||
assertNotNull(getResp.getData());
|
||||
assertNotNull(getResp.getData().getServerTime());
|
||||
assertNotNull(getResp.getData().getCurrentDate());
|
||||
assertNotNull(getResp.getData().getCurrentTime());
|
||||
assertNotNull(getResp.getData().getTimeZone());
|
||||
assertNotNull(getResp.getData().getTimestamp());
|
||||
|
||||
var postResp = systemController.getServerTimeByPost();
|
||||
assertNotNull(postResp);
|
||||
assertTrue(postResp.isSuccess());
|
||||
assertNotNull(postResp.getData());
|
||||
assertEquals(getResp.getData().getCurrentDate(), postResp.getData().getCurrentDate());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user