同步操作将从 Asciphx/ThinkTs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
@Class(["add","del","fix","info","page"])//or @Class("/admin",……)or @Class("admin",……)
class AdminController extends Controller{
@Inject(AdminService) readonly adminSvc:AdminService
@Inject(UserService) readonly userSvc:UserService
@Middle(W.Log,W.V_B("account|1#3~10","pwd#6~23|1"))
@app.post("login")
login(@B body) {
return this.userSvc.login(body.account,body.pwd)
}
}
/** Here's how to show EJS template rendering */
class View{
@Get() @Get("index.html")
index(ctx:Context){
html(ctx,{test:"test",author:"asciphx"})
}
@Get("login.html")
login(ctx:Context){
html(ctx,{test:"test",author:"Login"})
}
}
export class UserService extends Service implements UserFace{
constructor(
private user:Repository<User>=Cache["User"],
private role:Repository<Role>=Cache["Role"]
) {
super({
leftJoin:{e:"user.roles",a:'role'},
addSelect:['role.id','role.name'],
where: query => {
return new Brackets(qb => {
if (query.account) qb.where('account like :v', { v: `%${query.account}%` })
if (query.id) qb.andWhere('id >:i', { i: query.id })
});
},
orderBy: { "user.id": "desc" }
})
}
}
export 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
a:`${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 Because I use windows 10, PM2 does not support Linux or Mac temporarily. If you need to use it, please rewrite it and test it yourself
npm i
commandormconfig.json
filenpm start
commandmenu 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
entity layer
interface layer
service layer
base layer
tool layer
background EJS template rendering folder
Windows uses the RM and CP instructions of Linux, and needs to put the environment variable directory
output the route file to view. Each controller will create one
the storage directory of the uploaded file
package back end to formal environment directory
PM2 output log directory
Built by the world's No.1 man, Asciphx
Please wait this project will generate a blog project
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。