Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

时城宜项目笔记

https://github.coventry.ac.uk/shic4/shic4-340CT-sem2.git github账号密码 shic4@coventry.ac.uk Scyscy5201314.

deno run --allow-all --unstable --watch index.js deno run --allow-all --unstable --inspect index.js

项目登录账号密码 卖家 artist1 p455w0rd 买家 p455w0rd

链接数据库 mysql -u root -p p455w0rd

show databases; show tables; use website; select * from accounts; select * from commodities;

2020-02-20 创建Commodities表的时候发现mysql表字段名不能直接用detail https://blog.csdn.net/qq_16186465/article/details/122330853

cookie中保存user id context.cookies.set('authorised', userId) getCookie('authorised') 还需要存储用户名,页面上面需要显示用户名

页面引入了main.js,为什么不能访问里边的方法?比如file2DataURI

<script type="module" src="/main.js"></script>

因为通过type="module"引入的模块有自己的作用域,在外面访问不到,需要像下面这样写 <script type="module"> import {file2DataURI,getCookie} from './main.js' </script>

cookie authorised is httpOnly,通过javascript脚本拿不到

mysql表名区分大小写,表名改为commodities后,下面sql报错 INSERT INTO COMMODITIES VALUES('dd', './public/uploads/artist1-1645447075147.jpeg', 100, '噶神', 'artist1'); 改成 INSERT INTO commodities VALUES('dd', './public/uploads/artist1-1645447075147.jpeg', 100, '噶神', 'artist1'); 还是报错 ERROR 1136 (21S01): Column count doesn't match value count at row 1 原因是,因为第一列被声明为主键,自增长,但是insert的时候还是如果这一列不给值还是不行的,所以要指定列名insert https://blog.csdn.net/qq_21144531/article/details/45501219 INSERT INTO commodities (name, picture, price, describe, userId) VALUES('dd', './public/uploads/artist1-1645447075147.jpeg', 100, '噶神', 'artist1');

mysql查询表结构 desc 【table name】,即 describe 【table name】

mysql时间类型 mysql枚举类型

由于不熟悉mysql枚举类型,且有些博客不建议使用mysql类型,我们使用VARCHAR定义商品状态status(on sale表示在售,sold out表示已售出)

hbs模板怎么求一个数组类型变量的长度?

codio没有停止终端服务刷新页面,然后再次启动项目,报错,端口占用

.hbs模板用法 https://www.jianshu.com/p/fc9d6c2157bf

deno router怎么取路由参数? 比如: https://blitz-vienna-8080.codio-box.uk/commodity/detail/1 像下面这样取不到路径参数 router.get('/commodity/detail/:id', async context => { console.log(context) const id = context.params.id 直接像下面这样写 router.get('/commodity/detail', async context => { // context.request.url.search可以从url中拿到参数,比如?id=1,然后写一个方法解析参数 const {id} = parseQueryString(context.request.url.search)

详情页面由于图片路径写过了导致图片没有加载出来,而且后端报了404,Response is not writable 其实后端404的逻辑有问题,或者说静态资源的404应该单独处理,而不是由页面404的逻辑来处理

商品onSaleTime是创建商品时有服务端计算的,由于new Date().toLocaleString()计算出来的时间格式不符合mysql的datetime类型格式要求,执行sql失败了,这种错误需要在前端展示吗? 我认为需要展示,因为发生了错误用户需要知道发生了什么,但是我又认为不应该展示,因为这个时间不是前端计算的,用户知道了也没有办法解决

创建商品的时候需要保存日期和时间,但是显示商品详情的时候只需要显示日期,不需要时间,怎么写sql? select date_format(onSaleDate,’%Y-%m-%d’) as onSaleDate from commodities;

const username = context.cookies.get('username') const isSeller = username.startsWith("artist")