Closed efarsoft closed 3 months ago
表结构发下
CREATE TABLE gxcc_social_category
(
id
int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
pid
int unsigned NOT NULL DEFAULT '0' COMMENT '上级ID',
level
int NOT NULL DEFAULT '0' COMMENT '菜单级别',
name
varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '版块名称',
image
varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '缩略图',
description
varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '版块简介',
sort
smallint unsigned NOT NULL DEFAULT '255' COMMENT '排序(ASC)',
status
tinyint unsigned NOT NULL DEFAULT '1' COMMENT '状态值',
is_section
tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否设置为版块',
is_recommend
tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否推荐',
cross_plfm
tinyint unsigned NOT NULL DEFAULT '0',
cross_plfm_app_id
int DEFAULT NULL COMMENT '跨平台ID',
cross_plfm_category_id
int DEFAULT NULL COMMENT '分类id',
link_url
varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '跳转链接',
app_id
int NOT NULL COMMENT '应用ID',
create_time
int NOT NULL COMMENT '创建时间',
update_time
int NOT NULL COMMENT '更新时间',
delete_time
int DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (id
) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
同样的问题
自动写入时间戳字段仅会处理系统自动生成的值,你自己传入的 update_time
和 create_time
不会处理。
自动写入时间戳字段输出的时候会自动进行格式转换,写入时不会自动进行格式转换。
如果你需要对自己传入的 update_time
和 create_time
自动进行格式转换,以下提出两种方案:
文档:https://doc.thinkphp.cn/v8_0/type_conversion.html
class GxccSocialCategory extends Model
{
protected $type = [
'create_time' => 'timestamp',
'update_time' => 'timestamp',
];
}
文档:https://doc.thinkphp.cn/v8_0/model_setter.html
class GxccSocialCategory extends Model
{
public function setCreateTimeAttr($value)
{
return strtotime($value);
}
public function setUpdateTimeAttr($value)
{
return strtotime($value);
}
}
更新数据时,创建时间字段create_time 未自动转换
已开启全局自动写入时间戳
提交数据
{"id":2,"work_type":1,"resume_id":2,"city":"12312312","post_id":0,"post_name":"3123123","salary_min":0,"salary_max":0,"salary_scope":"123123123","preference":"","industry":"123123123","create_time":"2024-05-11 16:01:55","update_time":"2024-05-11 16:01:55"}
请求返回