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

  async update(pobj) {
    if (!pobj.pic_url) {
      return system.getResultFail(-101, "图片不能为空");
    }
    if (!pobj.jump_link_type) {
      return system.getResultFail(-104, "连接不能为空");
    }
    if (pobj.pic_describe && pobj.pic_describe.length > 19) {
      return system.getResultFail(-105, "图片描述最多20位字符");
    }
    try {
      var functionName = "cycleProduct";
      await this.redisdel.redisInfo(functionName);
      var functionName1 = "productTypeFirst";
      await this.redisdel.redisInfo(functionName1);
      var functionName2 = "productTypeSecend";
      await this.redisdel.redisInfo(functionName2);
      var functionName3 = "productList";
      await this.redisdel.redisInfo(functionName3);
      var functionName4 = "productDetail";
      await this.redisdel.redisInfo(functionName4);
    } catch (error) {
      console.log(error)
    }
    return system.getResultSuccess(this.dao.update(pobj));
  }
}
module.exports = CycleproductService;