Commit e00f9166 by 兰国旗

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

parent 2a36259a
......@@ -9,7 +9,12 @@ class ImgInfoCtl extends CtlBase {
async create(pobj, qobj, req) {
pobj.company_id = req && req.xctx && req.xctx.companyid ?req.xctx.companyid : "";
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;
......@@ -5,11 +5,11 @@ class ImginfoService extends ServiceBase {
constructor() {
super("configmag", ServiceBase.getDaoName(ImginfoService));
}
async getImgList (pobj) {
async getImgList(pobj) {
let res = await this.dao.findAndCountAll(pobj);
return system.getResultSuccess(res);
}
async createImginfo (pobj) {
async createImginfo(pobj) {
let code = await this.getBusUid("img");
pobj.imginfo.code = code;
if (pobj.imginfo.company_id === undefined) {
......@@ -18,10 +18,35 @@ class ImginfoService extends ServiceBase {
let res = await this.dao.create(pobj.imginfo);
return system.getResultSuccess(res);
}
async create(pobj){
var code = await this.getBusUid("img");
async create(pobj) {
let code = await this.getBusUid("img");
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;
\ 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