-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
337 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
'use strict'; | ||
let init={ | ||
mydb:"item", | ||
title:"分类管理", | ||
edit:"分类编辑", | ||
add:"分类添加", | ||
action:"item" | ||
let init = { | ||
mydb: "item", | ||
title: "分类管理", | ||
edit: "分类编辑", | ||
add: "分类添加", | ||
action: "item" | ||
} | ||
import Base from './base.js'; | ||
export default class extends Base { | ||
/** | ||
* index action | ||
* @return {Promise} [] | ||
*/ | ||
async indexAction(){ | ||
let info={ | ||
db:init.mydb, | ||
page:this.get("page")||1, | ||
pagesize:this.get("pagesize")||10 | ||
} | ||
let mydata=await this.model('util').getIndex(info); | ||
this.assign("itemList",mydata.itemList); | ||
this.assign('pageData',mydata.pageData); | ||
this.assign("title",init.title); | ||
this.assign("action",init.action); | ||
return this.display(); | ||
} | ||
/** | ||
* index action | ||
* @return {Promise} [] | ||
*/ | ||
async indexAction() { | ||
let info = { | ||
db: init.mydb, | ||
page: this.get("page") || 1, | ||
pagesize: this.get("pagesize") || 10 | ||
} | ||
let mydata = await this.model('util').getIndex(info); | ||
this.assign("itemList", mydata.itemList); | ||
this.assign('pageData', mydata.pageData); | ||
this.assign("title", init.title); | ||
this.assign("action", init.action); | ||
return this.display(); | ||
} | ||
|
||
async itemAction(){ | ||
async itemAction() { | ||
|
||
let info={ | ||
db:init.mydb, | ||
edit:init.edit, | ||
add:init.add, | ||
id:this.get('id') | ||
} | ||
let mydata=await this.model('util').getItem(info); | ||
this.assign("title",mydata.title); | ||
this.assign('item',mydata.item); | ||
this.assign("action",init.action); | ||
return this.display(); | ||
} | ||
let info = { | ||
db: init.mydb, | ||
edit: init.edit, | ||
add: init.add, | ||
id: this.get('id') | ||
} | ||
let mydata = await this.model('util').getItem(info); | ||
this.assign("title", mydata.title); | ||
this.assign('item', mydata.item); | ||
this.assign("action", init.action); | ||
return this.display(); | ||
} | ||
|
||
//编辑或者新增接口 | ||
async saveAction() { | ||
let info={ | ||
db:init.mydb, | ||
data:this.post(), | ||
id:this.post('id') | ||
} | ||
let mydata=await this.model('util').doSave(info); | ||
if(mydata.status===1) return this.success(); | ||
//编辑或者新增接口 | ||
async saveAction() { | ||
let info = { | ||
db: init.mydb, | ||
data: this.post(), | ||
id: this.post('id') | ||
} | ||
let mydata = await this.model('util').doSave(info); | ||
if (mydata.status === 1) return this.success(); | ||
} | ||
|
||
//删除或批量删除接口 | ||
async delsomeAction(){ | ||
let info={ | ||
db:init.mydb, | ||
arr:this.post('delarr[]') | ||
} | ||
let where={id: ["IN", info.arr]}; | ||
let rs=await this.model("admin").deleteRecord(info.db,where); | ||
if(rs) return this.success(); | ||
async delsomeAction() { | ||
let info = { | ||
db: init.mydb, | ||
arr: this.post('delarr[]') | ||
} | ||
let where = { id: ["IN", info.arr] }; | ||
let rs = await this.model("admin").deleteRecord(info.db, where); | ||
if (rs) return this.success(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,80 @@ | ||
'use strict'; | ||
let init={ | ||
mydb:"links", | ||
title:"友情链接管理", | ||
action:"links" | ||
let init = { | ||
mydb: "links", | ||
title: "友情链接管理", | ||
action: "links" | ||
} | ||
import Base from './base.js'; | ||
export default class extends Base { | ||
/** | ||
* index action | ||
* @return {Promise} [] | ||
*/ | ||
async indexAction(){ | ||
let info={ | ||
db:init.mydb, | ||
page:this.get("page")||1, | ||
pagesize:this.get("pagesize")||10 | ||
} | ||
let mydata=await this.model('util').getIndex(info); | ||
this.assign("itemList",mydata.itemList); | ||
this.assign('pageData',mydata.pageData); | ||
this.assign("title",init.title); | ||
this.assign("action",init.action); | ||
return this.display(); | ||
} | ||
//删除或批量删除接口 | ||
async delsomeAction(){ | ||
let info={ | ||
db:init.mydb, | ||
arr:this.post('delarr[]') | ||
/** | ||
* index action | ||
* @return {Promise} [] | ||
*/ | ||
async indexAction() { | ||
let info = { | ||
db: init.mydb, | ||
page: this.get("page") || 1, | ||
pagesize: this.get("pagesize") || 10 | ||
} | ||
let where={id: ["IN", info.arr]}; | ||
let rs=await this.model("admin").deleteRecord(info.db,where); | ||
if(rs) return this.success(); | ||
} | ||
let mydata = await this.model('util').getIndex(info, { flag: 0 }); | ||
this.assign("itemList", mydata.itemList); | ||
this.assign('pageData', mydata.pageData); | ||
this.assign("title", init.title); | ||
this.assign("action", init.action); | ||
return this.display(); | ||
} | ||
async listAction() { | ||
let info = { | ||
db: init.mydb, | ||
page: this.get("page") || 1, | ||
pagesize: this.get("pagesize") || 10 | ||
} | ||
let mydata = await this.model('util').getList(info); | ||
this.assign("itemList", mydata.itemList); | ||
this.assign('pageData', mydata.pageData); | ||
this.assign("title", init.title); | ||
this.assign("action", init.action); | ||
return this.display(); | ||
} | ||
// 列表页 | ||
async itemAction() { | ||
let info = { | ||
db: init.mydb, | ||
edit: init.edit, | ||
add: init.add, | ||
id: this.get('id') | ||
} | ||
let mydata = await this.model('util').getItem(info); | ||
this.assign("title", mydata.title); | ||
this.assign('item', mydata.item); | ||
this.assign("action", init.action); | ||
return this.display(); | ||
} | ||
//编辑或者新增接口 | ||
async saveAction() { | ||
let info = { | ||
db: init.mydb, | ||
data: this.post(), | ||
id: this.post('id') | ||
} | ||
let mydata = await this.model('util').doSave(info); | ||
if (mydata.status === 1) return this.success(); | ||
} | ||
// 更新友情链接状态 | ||
async upstatusAction() { | ||
let newData = this.post(); | ||
let rs = this.model("links").where({ id: this.post("id") }).update(newData); | ||
if (rs) return this.success(); | ||
} | ||
//删除或批量删除接口 | ||
async delsomeAction() { | ||
let info = { | ||
db: init.mydb, | ||
arr: this.post('delarr[]') | ||
} | ||
let where = { id: ["IN", info.arr] }; | ||
let rs = await this.model("admin").deleteRecord(info.db, where); | ||
if (rs) return this.success(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,60 @@ | ||
'use strict'; | ||
export default class extends think.model.base { | ||
|
||
async getIndex(info){ | ||
async getIndex(info, where) { | ||
|
||
let itemList=await this.model(info.db).page(info.page,info.pagesize).select(); | ||
let result = await this.model(info.db).page(info.page,info.pagesize).countSelect(); | ||
let Page=think.adapter("template", "page"); | ||
let page = new Page(); | ||
let pageData=page.pagination(result,info.page); | ||
let itemList = await this.model(info.db).where(where).page(info.page, info.pagesize).select(); | ||
let result = await this.model(info.db).page(info.page, info.pagesize).countSelect(); | ||
let Page = think.adapter("template", "page"); | ||
let page = new Page(); | ||
let pageData = page.pagination(result, info.page); | ||
|
||
return { | ||
itemList:itemList, | ||
pageData:pageData | ||
}; | ||
} | ||
async getItem(info){ | ||
let title="",item={}; | ||
if(info.id){ | ||
title=info.edit; | ||
item=await this.model(info.db).where({id:info.id}).find(); | ||
}else{ | ||
title=info.add; | ||
item={} | ||
} | ||
return{ | ||
title:title, | ||
item:item | ||
} | ||
} | ||
async doSave(info){ | ||
let status=0 | ||
if(!think.isEmpty(info.id)){ | ||
let rs=await this.model(info.db).where({id:info.id}).update(info.data); | ||
if(rs) status=1; | ||
}else{ | ||
let rs=await this.model(info.db).add(info.data); | ||
if(rs) status=1; | ||
} | ||
return{ | ||
status:status | ||
} | ||
} | ||
} | ||
return { | ||
itemList: itemList, | ||
pageData: pageData | ||
}; | ||
} | ||
async getList(info) { | ||
|
||
let itemList = await this.model(info.db).where({ | ||
flag: 1 | ||
}).page(info.page, info.pagesize).select(); | ||
let result = await this.model(info.db).page(info.page, info.pagesize).countSelect(); | ||
let Page = think.adapter("template", "page"); | ||
let page = new Page(); | ||
let pageData = page.pagination(result, info.page); | ||
|
||
return { | ||
itemList: itemList, | ||
pageData: pageData | ||
}; | ||
} | ||
async getItem(info) { | ||
let title = "", | ||
item = {}; | ||
if (info.id) { | ||
title = info.edit; | ||
item = await this.model(info.db).where({ id: info.id }).find(); | ||
} else { | ||
title = info.add; | ||
item = {} | ||
} | ||
return { | ||
title: title, | ||
item: item | ||
} | ||
} | ||
async doSave(info) { | ||
let status = 0 | ||
if (!think.isEmpty(info.id)) { | ||
let rs = await this.model(info.db).where({ id: info.id }).update(info.data); | ||
if (rs) status = 1; | ||
} else { | ||
let rs = await this.model(info.db).add(info.data); | ||
if (rs) status = 1; | ||
} | ||
return { | ||
status: status | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.