const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class PicturewarehouseService extends ServiceBase {
  constructor() {
    super("aggregation", ServiceBase.getDaoName(PicturewarehouseService));
    this.redisdel = system.getObject("service.aggregation.redisdelSve");
  }

  async create(pobj) {
    let code = await this.getBusUid("img");
    pobj.code = code;
    if (!pobj.pic_url) {
      return system.getResultFail(-123, "图片不能为空");
    }
    return system.getResultSuccess(this.dao.create(pobj));
  }


  async update(pobj) {
    if (!pobj.pic_url) {
      return system.getResultFail(-123, "图片不能为空");
    }
    try {
      var functionName = "productDetail";
      await this.redisdel.redisInfo(functionName);
    } catch (error) {
      console.log(error)
    }
    return system.getResultSuccess(this.dao.update(pobj));
  }

  async delete(pobj) {
    try {
      var functionName = "productDetail";
      await this.redisdel.redisInfo(functionName);
    } catch (error) {
      console.log(error)
    }
    return system.getResultSuccess(this.dao.delete(pobj));
  }
}
module.exports = PicturewarehouseService;