DNSWebCtrl.java 2.5 KB
package com.ui.ctrl;

import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.domain.OutRecod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "dnspod")
public class DNSWebCtrl {

    private Logger log = LoggerFactory.getLogger(DNSWebCtrl.class);

    @Autowired
    HttpRestClient httpRestClient;

    /**
     * 获取域名列表
     *
     * @return 2016年5月12日下午1:49:48
     */
    @RequestMapping(value = "toDns")
    public ModelAndView getLocalRecords() {
        ModelAndView mdv = new ModelAndView("switch/dnsSwitch");
        BaseResponse<List<OutRecod>> response = httpRestClient.exchangeForget(HttpUriContants.VIEW_DNSPOD, new ParameterizedTypeReference<BaseResponse<List<OutRecod>>>() {
        }, null);
        mdv.addObject("code",response.getCode());
        mdv.addObject("orders", response.getData());
        return mdv;
    }

    /**
     * 发送验证码
     *
     * @return 2016年5月12日下午1:49:48
     */
    @RequestMapping(value = "initSwitch")
    @ResponseBody
    public BaseResponse switchbefore(String id) {
        Map map = new HashMap<>();
        map.put("id",id);
        return httpRestClient.defaultGet(HttpUriContants.DNS_SWITCH_BEFORE, BaseResponse.class, map);
    }

    /**
     * 切换
     *
     * @return 2016年5月12日下午1:49:48
     */
    @RequestMapping(value = "doSwitch")
    @ResponseBody
    public BaseResponse doswitch(String token, String ticket) {
        Map map = new HashMap<>();
        map.put("token",token);
        map.put("ticket",ticket);
        return httpRestClient.defaultGet(HttpUriContants.SWITCH_DNS, BaseResponse.class, map);
    }

    /**
     * 获取token
     *
     * @return 2016年5月18日上午10:22:44
     */
    @RequestMapping(value = "validateAPIToken")
    @ResponseBody
    public BaseResponse getApiToken(String gcode) {
        Map map = new HashMap<>();
        map.put("gcode",gcode);
        return httpRestClient.defaultGet(HttpUriContants.VALIDE_TOKEN, BaseResponse.class, map);
    }

}