| 
					
				 | 
			
			
				@ -0,0 +1,97 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.quota.controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.ehr.constants.ApiVersion; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.ehr.util.rest.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.quota.model.source.DataSourcesTable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.quota.model.source.DataSourcesTableField; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.quota.service.source.DataSourcesTableFieldService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.quota.service.source.DataSourcesTableService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMethod; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.net.URLDecoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by wxw on 2018/9/10. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @author wxw. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RequestMapping(ApiVersion.Version1_0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Api(value = "DataSourcesTableController", description = "OLAP-数据源中表", tags = {"OLAP-数据源中表"}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class DataSourcesTableController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ObjectMapper objectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DataSourcesTableService dataSourcesService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DataSourcesTableFieldService dataSourcesFieldService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "/olap/searchDataSources", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "根据查询条件查询,具有分页功能;filters='id=1'") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop searchDataSources( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "fields", required = false) String fields, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "filters", required = false) String filters, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+type") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @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) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop envelop = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DataSourcesTable> search = dataSourcesService.search(fields, filters, sorts, page, size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null != search && search.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (DataSourcesTable table : search) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<DataSourcesTableField> list = dataSourcesFieldService.search("tableId=" + table.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (null != list && list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    table.setDataSourcesTableFields(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setSuccessFlg(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setDetailModelList(search); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "/olap/saveOrUpdateDataSources", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "添加或修改操作") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop saveOrUpdateDataSources( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "model", value = "json数据模型", defaultValue = "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam String model) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop envelop = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DataSourcesTable dataSourcesTable = objectMapper.readValue(URLDecoder.decode(model, "UTF-8"), DataSourcesTable.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null == dataSourcesTable.getId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 新增 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dataSourcesService.save(dataSourcesTable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dataSourcesService.save(dataSourcesTable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setSuccessFlg(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "/olap/deleteDataSourceById", method = RequestMethod.DELETE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "根据id删除") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop deleteDataSourceById( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "id", value = "编号", defaultValue = "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "id") Integer id) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop envelop = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        dataSourcesService.deleteById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setSuccessFlg(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |