create table am_user(
	id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
	name varchar(20) NOT NULL,
	nickname varchar(50),
	password varchar(64) NOT NULL,
	is_admin int NOT NULL,
	phone varchar(11),
	post varchar(30),
	create_time datetime default CURRENT_TIMESTAMP,
	update_time datetime NOT NULL,
	unique key(name)
);

create table am_token(
	token varchar(32) NOT NULL PRIMARY KEY,
	user_id int NOT NULL ,
	expire_time datetime NOT NULL,
	update_time datetime NOT NULL
);

create table am_public_asset(
	id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
	code varchar(100) NOT NULL,
	name varchar(200)  NOT NULL,
	model_num varchar(100) NOT NULL,
	company varchar(200),
	num int NOT NULL default 0,
	position varchar(200),
	user_id int NOT NULL,
	description varchar(200),
	create_time datetime default CURRENT_TIMESTAMP,
	update_time datetime NOT NULL,
	unique key(code)
);

create table am_staff_asset(
	id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
	name varchar(200)  NOT NULL,
	model_num varchar(100) NOT NULL,
	num int NOT NULL default 0,
	position varchar(200),
	user_id int NOT NULL,
	description varchar(200),
	create_time datetime default CURRENT_TIMESTAMP,
	update_time datetime NOT NULL,
	unique key(name,user_id)
);

create table am_material(
	id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
	code varchar(100) NOT NULL,
	value varchar(200)  NOT NULL,
	model_num varchar(100) NOT NULL,
	packages varchar(100),
	company varchar(200),
	num int NOT NULL default 0,
	position varchar(200),
	description varchar(200),
	base_num int default 10,
	create_time datetime default CURRENT_TIMESTAMP,
	update_time datetime NOT NULL,
	unique key(code)
);

create table am_material_log(
	id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
	code varchar(100) NOT NULL,
	num int NOT NULL,
	status int NOT NULL default 0, -- -1:failed,0:no audit,1:success
	user_id int NOT NULL,
	description varchar(200),
	operate int NOT NULL, -- 0:in,1:out
	batch varchar(100),
	create_time datetime default CURRENT_TIMESTAMP
);

--- 编码是否要变
