Subversion Repositories SmartDukaan

Rev

Rev 14385 | Rev 15183 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.dtrapi.controllers;

import java.util.List;

import org.apache.log4j.Logger;

import in.shop2020.model.v1.dtr.DtrService.Client;
import in.shop2020.thrift.clients.DtrClient;

import com.google.gson.Gson;
import com.mongodb.util.JSON;


public class LivePricingController extends BaseController{
    private static Logger log = Logger.getLogger(Class.class);
    
    private static final long serialVersionUID = 1L;
    
    private String skuBundleId;
    private String source_id;
    private String id;
    

    public String index(){
        Gson gs = new Gson();
        Client dc = null;
        try {
            dc = new DtrClient().getClient();
            List<in.shop2020.model.v1.dtr.LivePricing> pricingObj = dc.getLatestPricing(Long.valueOf(skuBundleId), Long.valueOf(source_id));
            setResultJson(JSON.parse(gs.toJson(pricingObj)).toString());
        } catch (Exception e) {
            log.info(e);
        }
        return "index";
    }
    
    public String latestPriceById(){
        Client dc = null;
        try {
            dc = new DtrClient().getClient();
            dc.updateLatestPriceForItem(Long.valueOf(id));
            setResultJson("{1:'Updated Successfully'}");
        } catch (Exception e) {
            log.info(e);
            setResultJson("{0:'Unable to update'}");
        }
        return "index";
   
    }
    
    public String getSkuBundleId() {
        return skuBundleId;
    }


    public void setSkuBundleId(String skuBundleId) {
        this.skuBundleId = skuBundleId;
    }
    
    public String getSource_id() {
        return source_id;
    }

    public void setSource_id(String source_id) {
        this.source_id = source_id;
    }

        public void setId(String id) {
                this.id = id;
        }

        public String getId() {
                return id;
        }
        
        public static void main (String[] args){
                LivePricingController live = new LivePricingController();
                live.setId("84");
                live.latestPriceById();
                System.out.println(live.getResultJson());
        }



}