Commit e00f9166 by 兰国旗

'优化新增图片、修改图片、查看图片'

parent 2a36259a
...@@ -9,7 +9,12 @@ class ImgInfoCtl extends CtlBase { ...@@ -9,7 +9,12 @@ class ImgInfoCtl extends CtlBase {
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : ""; pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
const up = await this.service.create(pobj); const up = await this.service.create(pobj);
return system.getResult(up); return up;
}
async update(pobj, qobj, req) {
const up = await this.service.update(pobj);
return up;
} }
} }
module.exports = ImgInfoCtl; module.exports = ImgInfoCtl;
...@@ -5,23 +5,48 @@ class ImginfoService extends ServiceBase { ...@@ -5,23 +5,48 @@ class ImginfoService extends ServiceBase {
constructor() { constructor() {
super("configmag", ServiceBase.getDaoName(ImginfoService)); super("configmag", ServiceBase.getDaoName(ImginfoService));
} }
async getImgList (pobj) { async getImgList(pobj) {
let res = await this.dao.findAndCountAll(pobj); let res = await this.dao.findAndCountAll(pobj);
return system.getResultSuccess(res); return system.getResultSuccess(res);
} }
async createImginfo (pobj) { async createImginfo(pobj) {
let code = await this.getBusUid("img"); let code = await this.getBusUid("img");
pobj.imginfo.code = code; pobj.imginfo.code = code;
if (pobj.imginfo.company_id === undefined) { if (pobj.imginfo.company_id === undefined) {
pobj.imginfo.company_id = 10; pobj.imginfo.company_id = 10;
} }
let res = await this.dao.create(pobj.imginfo); let res = await this.dao.create(pobj.imginfo);
return system.getResultSuccess(res); return system.getResultSuccess(res);
} }
async create(pobj){ async create(pobj) {
var code = await this.getBusUid("img"); let code = await this.getBusUid("img");
pobj.code = code; pobj.code = code;
return this.dao.create(pobj); if (!pobj.pic_url) {
return system.getResultFail(-123, "图片不能为空");
}
return system.getResultSuccess(this.dao.create(pobj));
}
async update(pobj) {
let whereParams = {
id: pobj.id
}
let res = await this.dao.findOne(whereParams,[]);
if(!pobj.id){
return system.getResultFail(-124, "未知图片信息");
}
if(!pobj.pic_url){
pobj.pic_url = res.pic_url;
}
if(!pobj.pic_size){
pobj.pic_size = res.pic_size;
}
if(!pobj.name){
pobj.name = res.name;
}
return system.getResultSuccess(this.dao.update(pobj));
} }
} }
module.exports = ImginfoService; module.exports = ImginfoService;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment