springmvc中應用通用入口路由匹配
阿新 • • 發佈:2019-01-22
package com.dstech.dssp.httpclient.control;
import com.dstech.dssp.base.user.User;
import com.dstech.dssp.control.WebUser;
import com.dstech.dssp.httpclient.service.HttpClientService;
import com.dstech.dssp.web.util.UserUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/rest"})
public class HttpClientControl extends AbstractHttpClientControl
{
@Value("${restUrl}")
private String restUrl;
@Value("${webSecurity:false}")
private boolean security;
@Autowired
private HttpClientService httpClientService;
@RequestMapping(value={"/{busiComp}/{serviceName}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.DELETE})
public void delete(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String id, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/codeList/{codeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCodeList(@PathVariable String busiComp, @PathVariable String codeName, @RequestParam(required=false, defaultValue="false") boolean refresh, HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false, defaultValue="") String dsspUserId)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/codeList/{codeItem}/{codeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCodeList(@PathVariable String busiComp, @PathVariable String codeItem, @PathVariable String codeName, @RequestParam(required=false, defaultValue="false") boolean refresh, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{service}/{operate}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCommonDeal(@PathVariable String busiComp, @PathVariable String service, @PathVariable String operate, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
public HttpClientService getHttpClientService()
{
return this.httpClientService;
}
public String getRestUrl()
{
return this.restUrl;
}
@RequestMapping(value={"/{busiComp}/tree/{treeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getTreeNodeList(@PathVariable String busiComp, @PathVariable String treeName, @RequestParam(required=false) String id, @RequestParam(required=false, defaultValue="") String viewName, @RequestParam(required=false) String defaultId, @RequestParam(required=false, defaultValue="false") boolean allData, HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false, defaultValue="") String dsspUserId)
throws Exception
{
doService(request, response, null);
}
public User getUser(HttpServletRequest request)
{
return UserUtil.getUser(request);
}
@RequestMapping(value={"/user"}, method={org.springframework.web.bind.annotation.RequestMethod.GET}, produces={"application/json; charset=UTF-8"})
@ResponseBody
public User getWebUser(HttpServletRequest request) {
User user = UserUtil.getUser(request);
if ((user != null) && ((user instanceof WebUser))) {
user = ((WebUser)user).getUser();
}
return user;
}
public boolean isSecurity()
{
return this.security;
}
@RequestMapping(value={"/{busiComp}/{service}/{operate}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST, org.springframework.web.bind.annotation.RequestMethod.PUT, org.springframework.web.bind.annotation.RequestMethod.DELETE})
public void postCommonDeal(@PathVariable String busiComp, @PathVariable String service, @PathVariable String operate, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{service}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void queryById(@PathVariable String busiComp, @PathVariable String service, @PathVariable String id, @RequestParam(required=false) String beanName, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveInsert(@PathVariable String busiComp, @PathVariable String serviceName, @RequestParam(required=false, defaultValue="false") boolean multi, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/saveMasterDetail/{detailBeanName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveMasterDetail(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String detailBeanName, HttpServletRequest request, HttpServletResponse response) throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/saveMasterDetail2/{detail1BeanName}/{detail2BeanName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveMasterDetail2(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String detail1BeanName, @PathVariable String detail2BeanName, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.PUT})
public void saveUpdate(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String id, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
}
import com.dstech.dssp.base.user.User;
import com.dstech.dssp.control.WebUser;
import com.dstech.dssp.httpclient.service.HttpClientService;
import com.dstech.dssp.web.util.UserUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/rest"})
public class HttpClientControl extends AbstractHttpClientControl
{
@Value("${restUrl}")
private String restUrl;
@Value("${webSecurity:false}")
private boolean security;
@Autowired
private HttpClientService httpClientService;
@RequestMapping(value={"/{busiComp}/{serviceName}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.DELETE})
public void delete(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String id, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/codeList/{codeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCodeList(@PathVariable String busiComp, @PathVariable String codeName, @RequestParam(required=false, defaultValue="false") boolean refresh, HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false, defaultValue="") String dsspUserId)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/codeList/{codeItem}/{codeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCodeList(@PathVariable String busiComp, @PathVariable String codeItem, @PathVariable String codeName, @RequestParam(required=false, defaultValue="false") boolean refresh, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{service}/{operate}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getCommonDeal(@PathVariable String busiComp, @PathVariable String service, @PathVariable String operate, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
public HttpClientService getHttpClientService()
{
return this.httpClientService;
}
public String getRestUrl()
{
return this.restUrl;
}
@RequestMapping(value={"/{busiComp}/tree/{treeName}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void getTreeNodeList(@PathVariable String busiComp, @PathVariable String treeName, @RequestParam(required=false) String id, @RequestParam(required=false, defaultValue="") String viewName, @RequestParam(required=false) String defaultId, @RequestParam(required=false, defaultValue="false") boolean allData, HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false, defaultValue="") String dsspUserId)
throws Exception
{
doService(request, response, null);
}
public User getUser(HttpServletRequest request)
{
return UserUtil.getUser(request);
}
@RequestMapping(value={"/user"}, method={org.springframework.web.bind.annotation.RequestMethod.GET}, produces={"application/json; charset=UTF-8"})
@ResponseBody
public User getWebUser(HttpServletRequest request) {
User user = UserUtil.getUser(request);
if ((user != null) && ((user instanceof WebUser))) {
user = ((WebUser)user).getUser();
}
return user;
}
public boolean isSecurity()
{
return this.security;
}
@RequestMapping(value={"/{busiComp}/{service}/{operate}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST, org.springframework.web.bind.annotation.RequestMethod.PUT, org.springframework.web.bind.annotation.RequestMethod.DELETE})
public void postCommonDeal(@PathVariable String busiComp, @PathVariable String service, @PathVariable String operate, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{service}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
public void queryById(@PathVariable String busiComp, @PathVariable String service, @PathVariable String id, @RequestParam(required=false) String beanName, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveInsert(@PathVariable String busiComp, @PathVariable String serviceName, @RequestParam(required=false, defaultValue="false") boolean multi, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/saveMasterDetail/{detailBeanName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveMasterDetail(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String detailBeanName, HttpServletRequest request, HttpServletResponse response) throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/saveMasterDetail2/{detail1BeanName}/{detail2BeanName}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void saveMasterDetail2(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String detail1BeanName, @PathVariable String detail2BeanName, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
@RequestMapping(value={"/{busiComp}/{serviceName}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.PUT})
public void saveUpdate(@PathVariable String busiComp, @PathVariable String serviceName, @PathVariable String id, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
doService(request, response, null);
}
}