'use strict';

var angular = require('angular');
require('../modules');
require('./InfoLocalStorageService');


var module = angular.module('info.services');
/**
 * 从服务器到缓存
 * @param {[type]} models [description]
 */
module.factory('InfoRepository', function(infoLocalStorageService) {
  var service = {
    /**
     * 添加或者更新info
     * @param {} info 一条详细信息
     * @param {String} md5    MD5值
     */
    addOrUpdateInfo: function(infoId, info, md5) {
      infoLocalStorageService.setMd5(infoId, md5);
      return infoLocalStorageService.setInfo(infoId, info);
    },
    /**
     * 从缓存中获取info
     */
    getInfo: function(infoId) {
      return infoLocalStorageService.getInfo(infoId);
    },
    /**
     * 从缓存中获取MD5值
     */
    getMd5: function(infoId) {
      return infoLocalStorageService.getMd5(infoId);
    }
  };
  return service;
});
