美文网首页
更新接口

更新接口

作者: d655059c22cc | 来源:发表于2017-08-08 17:19 被阅读0次

    1.新建接口

    public interface UpdateService {
    
        /**
         *更新接口
         * @param updatevo
         * @throws Exception
         */
        void UpdateClient(UpdateVO updatevo) throws Exception;
    }
    

    2.接口实现

    /**
     * 更新接口的实现
     * Created by zyy on 2017/7/24.
     */
    public class UpdateServicelmpl implements UpdateService{
        private Handler handler;
    
        private ServerDataExchangeUtil serverDataExchangeUtil;
    
        public UpdateServicelmpl(Handler handler) {
            this.handler = handler;
            init();
    
        }
    
        /**
         * 初始化
         */
        private void init() {
            try {
                serverDataExchangeUtil = new ServerDataExchangeUtil();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        @Override
        public void UpdateClient(UpdateVO updatevo) throws Exception {
            String url= Constant.UPDATEURL;
            if(null != url && !"".equals(url)) {
                String mac = Constant.MAC;
                url = "http://" + url + FunctionUtil.getFunctionList(FunctionListEnum.UpdateClient.toString());
                Map<String, Object> mapPara = new HashMap<>();
                mapPara.put("mac", mac);
                //创个userUser, 使之有token
                InstanceServiceUtil.writeMap(UserUser.class.toString(), new UserUser());
                serverDataExchangeUtil.handler = handler;
                serverDataExchangeUtil.PostValue(CommandEnum.UPDATA_CLIENT, FunctionListEnum.UpdateClient.toString(), url, mapPara,ContentTypeEnum.Text.getContentType());
            }
        }
    }
    

    3.接口实体

    public class UpdateVO {
        //服务器中APP版本号
        private int serverVersionCode;
        private String url;
    
        public int getServerVersionCode() {
            return serverVersionCode;
        }
    
        public void setServerVersionCode(int serverVersionCode) {
            this.serverVersionCode = serverVersionCode;
        }
    
        public String getUrl() {
            return url;
        }
    
        public void setUrl(String url) {
            this.url = url;
        }
    }
    

    相关文章

      网友评论

          本文标题:更新接口

          本文链接:https://www.haomeiwen.com/subject/lhxxrxtx.html