Thinkts refers to the implementation of [ThinkPHP + Nestjs + FastAPI]. Of course, the purpose is also for product managers. The idea is that it is possible to achieve a small goal (project) every day…
@Class(["add","del","fix","info","page"])//or @Class("/admin",……)or @Class("admin",……)
class Admin extends Controller{
@Inject(Admin$) readonly a_:Admin$
@Inject(User$) readonly u_:User$
@Middle(W.Log,W.V_B("account|1#3~10","pwd#6~23|1"))
@app.post("register")
add(@B b,@R r:Response) {
r.status=202;//Set status code
return this.u_.register(b.account,b.pwd)
}
}
/** Here's how to show EJS template rendering */
class View{
@Get() @Get("index.html")
index(ctx:Context){
html(ctx,{test:"test",author:"asciphx"}).next().value
}
@Get("login.html")
login(ctx:Context){
html(ctx,{test:"test",author:"Login"}).next().value
}
}
export default class User$ extends $ implements F{
constructor(
private u=Inject(User),private r=Inject(Role)
) {
super({
leftJoin:{e:"u.roles",a:'role'},
addSelect:['role.id','role.name'],
where: query => new Brackets(qb => {
if (query.account) qb.where('account like :v', { v: `%${query.account}%` })
if (query.id) qb.andWhere('u.id >:i', { i: query.id })
}),
orderBy: { "u.id": "desc" }
},"u")
}
}
export default interface UserFace{
/** register one*/register(entity)
/** login one*/login(entity)
}
/
+ entity class name, which can also be customizedThe header request header now has two parameters, and the original JWT does not change. Now add a secret. Secret is now provided by the back end. The algorithm is in the cryptoUtil.ts in
t:`${token}` s:`${secret}`In particular, localhost:8080/index.html It is the postman interface. Remember to record token and sercet after login and use it as above. The front-end is still in implementation. Let's use postman for a while. For instructions started in a formal environment, windows uses NPM run pro, while MAC or Linux uses NPM run prod
npm i
commandormconfig.json
filenpm start
commandPlease refer to nestjs's microservice pattern document, which can be basically implemented
menu path,automatically generated(Matching rule)
Add:POST/admin
Delete:DELETE/admin/
Modification:PUT/admin/
Query:GET/admin/
Pagination:GET/admin
The return value in restful specification actually costs too much bandwidth. However, I think the front end only needs to judge whether the return is a string or an object. For example, the string is displayed directly (the front-end pop-up window is OK), If an object is returned, the request status code must be 200, so only the important data is taken without the code status code and mass message to indicate success (those two things are totally a waste of traffic).
back end file entry
control layer
-> /^[A-Z_]\w*/entity layer
interface layer
service layer
base layer
tool layer
background EJS template rendering folder/front end packaging folder
Windows uses the RM and CP instructions of Linux, and needs to put the environment variable directory
Provide front-end routing file. Each controller will create one
the storage directory of the uploaded file
package back end to formal environment directory
PM2 output log directory
save the template of permission management, as well as the common template
Built by the world's No.1 man, Asciphx
Please wait this project will generate a blog project
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。