今天跟前端他们那边讨论了一下,把商品删去了一些(多了任务量会变多),并且在表里面增改了一些字段名。但是改完之后发现id的自增长出现了问题,没有从1开始增长。
ALTER TABLE product AUTO_INCREMENT = 1;
这样改了就好了。
正式开始今天的内容。
一、用户信息的添加、修改与删除
在数据库填入用户输入的信息,语句如下
增加了用户信息修改功能,用户注册登录之后可以增加个人的信息
//用户注册
INSERT INTO `user`(id,user_name,password) VALUES(null,#{userName},#{password});
//增加用户信息
insert into user (creat_time,user_mail,gender,birthday,med_card) values (#{createTime},#{userMail},#{gender},#{birthday},#{medCard});
//删除用户信息
delete from user where id=#{id};
//修改用户信息
update user set user_name = #{userName},
password = #{password},
user_mail = #{userMail},
gender=#{gender},
birthday=#{birthday},
med_card=#{medCard};
二、订单信息的增加、修改与删除
这一块增加#{orderNumber}我们感觉有点问题,用户在选择商品时应改是商品数量增加而不是订单数量,后续应该会再做修改。
//订单的增加
INSERT INTO order
VALUES(null,#{userId},#{orderNumber},#{totalPrice},#{orderState});
//订单的删除
DELETE FROM order WHERE id = #{id}
//订单的更新
UPDATE `order`
Set user_id=#{userId},order_number=#{orderNumber},total_price=#{totalPrice},order_state=#{orderState})
where id=#{id};
三、查询语句
这里我们采用了模糊查询的语句,对商品类别、商品名称和订单做了查询。
//对商品名称模糊查询
select * from product where product_name like CONCAT(#{productName},'关爱父母基础体验卡');
select * from product where product_name like CONCAT(#{productName},'关爱父母升级体验卡');
select * from product where product_name like CONCAT(#{productName},'心脑血管基本套餐');
select * from product where product_name like CONCAT(#{productName},'支气管哮喘套餐');
select * from product where product_name like CONCAT(#{productName},'贫血筛查');
select * from product where product_name like CONCAT(#{productName},'基础型体检套餐');
select * from product where product_name like CONCAT(#{productName},'经济型体检套餐');
select * from product where product_name like CONCAT(#{productName},'至尊型体检套餐');
//订单的查询
SELECT * FROM order WHERE id LIKE CONCAT('%',#{id},'%');
//商品类别的查询
select * from productclass where class_name like CONCAT(#{className},'老年体检');
select * from productclass where class_name like CONCAT(#{className},'常规体检');
select * from productclass where class_name like CONCAT(#{className},'专项体检');
后续应该我们负责数据库这一板块的同学除了微调我们的SQL语句就没有什么工作量了。
---------------------------------更新------------------------------------------
前端增加了一个用户反馈的功能,所以我们又建了一个表用来存储用户反馈
CREATE table feedback(
id INT PRIMARY KEY AUTO_INCREMENT,
uer_name VARCHAR(50),
user_mail VARCHAR(50),
feed_con VARCHAR(255)
)comment '用户反馈';
然后我们更改了一下商品的模糊查询和产品种类的查询语句,实现导航栏的功能
//对商品名称模糊查询
select * from product where product_name like CONCAT(#{productName},'%');
//根据类别查找商品
SELECT * FROM product where productclass_id=1
SELECT * FROM product where productclass_id=2
SELECT * FROM product where productclass_id=3