| 
					
				 | 
			
			
				@ -1,142 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.controller.base.version; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.commnon.base.base.BaseVersionContants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.exception.business.JiWeiException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.feign.base.version.ServerVersionFeign; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.common.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.common.EnvelopRestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.cloud.sleuth.Tracer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.servlet.http.HttpServletResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by chenweida on 2017/5/19. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RequestMapping("{version}/"+BaseVersionContants.api_common) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Api(value = "服务器版本模块", description = "服务器版本模块接口管理") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class ServerVersionController extends EnvelopRestController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ServerVersionFeign serverVersionFegin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Tracer tracer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostMapping(value = BaseVersionContants.BaseServerVersion.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "创建服务器版本", notes = "创建单个服务器版本") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @HystrixCommand(commandProperties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.timeout.enabled", value = "false") }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop create( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "json_data", value = "", defaultValue = "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestBody String jsonData) throws JiWeiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tracer.getCurrentSpan().logEvent("创建服务器版本:jsonData="+jsonData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.create(jsonData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PutMapping(value = BaseVersionContants.BaseServerVersion.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "修改服务器版本", notes = "修改服务器版本") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop update( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "json_data", value = "", defaultValue = "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestBody String jsonData) throws JiWeiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tracer.getCurrentSpan().logEvent("修改服务器版本:jsonData="+jsonData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.update(jsonData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @DeleteMapping(value = BaseVersionContants.BaseServerVersion.api_delete) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "删除服务器版本", notes = "删除服务器版本") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @HystrixCommand(commandProperties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.timeout.enabled", value = "false") }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop delete( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "codes", value = "codes") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @PathVariable(value = "codes", required = true) String codes, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "userCode", value = "userCode") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "userCode", required = true) String userCode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "userName", value = "userName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "userName", required = true) String userName) throws JiWeiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tracer.getCurrentSpan().logEvent("删除服务器版本:codes="+codes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.delete(codes,userCode,userName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @GetMapping(value = BaseVersionContants.BaseServerVersion.api_getByCode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "根据code查找服务器版本", notes = "根据code查找服务器版本") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @HystrixCommand(commandProperties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.timeout.enabled", value = "false") }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop findByCode( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "code", value = "code") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @PathVariable(value = "code", required = true) String code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ) throws JiWeiException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tracer.getCurrentSpan().logEvent("根据code查找服务器版本:code="+code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.findByCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = BaseVersionContants.BaseServerVersion.api_getList, method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "获取服务器版本列表(分页)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @HystrixCommand(commandProperties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.timeout.enabled", value = "false") }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop getWlyyVersions( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "fields", required = false) String fields, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "filters", required = false) String filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "sorts", required = false) String sorts, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "size", value = "分页大小", defaultValue = "15") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "size", required = false) int size, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "page", value = "页码", defaultValue = "1") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "page", required = false) int page, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HttpServletRequest request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HttpServletResponse response) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterStr = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(filters)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters = filters.replaceAll("=", ":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject jsonResult = new JSONObject(filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(jsonResult.has("name")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                filterStr+="name?"+jsonResult.get("name")+";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(jsonResult.has("saasId")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                filterStr+="saasId="+jsonResult.get("saasId")+";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.getList(fields, filterStr, sorts, size, page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @GetMapping(value = BaseVersionContants.BaseServerVersion.api_getListNoPage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "获取服务器版本列表,不分页") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @HystrixCommand(commandProperties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @HystrixProperty(name = "execution.timeout.enabled", value = "false") }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop getListNoPage( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "fields", required = false) String fields, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "filters", required = false) String filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "sorts", required = false) String sorts) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterStr = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(filters)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters = filters.replaceAll("=", ":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject jsonResult = new JSONObject(filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(jsonResult.has("saasId")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                filterStr+="saasId="+jsonResult.get("saasId")+";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return serverVersionFegin.getListNoPage(fields, filterStr, sorts); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |