提交 c0024bd4 编写于 作者: sq3536's avatar sq3536

合并dev2开发分支

上级 7fe90329
......@@ -31,9 +31,11 @@ TARGET=PSSYSAPP
</#if>
</dependencies>
<#if pub.getPSDeployCenter()?? && pub.getPSDeployCenter().getPSRegistryRepo()??>
<properties>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
<docker.image.prefix>${pub.getPSDeployCenter().getPSRegistryRepo().getConnStr()}</docker.image.prefix>
</properties>
</#if>
<profiles>
......@@ -107,7 +109,8 @@ TARGET=PSSYSAPP
</execution>
</executions>
</plugin>
<#if pub.getPSDeployCenter()?? && pub.getPSDeployCenter().getPSRegistryRepo()??>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
......@@ -125,6 +128,7 @@ TARGET=PSSYSAPP
</resources>
</configuration>
</plugin>
</#if>
</plugins>
</build>
</profile>
......
......@@ -17,6 +17,10 @@ services:
- "${httpPort}:${httpPort}"
networks:
- agent_network
<#if sysrun?? && sysrun.getPSDevSlnMSDepApp()?? && sysrun.getPSDevSlnMSDepApp().getPSDCMSPlatformNode()?? && sysrun.getPSDevSlnMSDepApp().getPSDCMSPlatformNode().getSSHIPAddr()??>
environment:
SPRING_CLOUD_NACOS_DISCOVERY_IP: ${sysrun.getPSDevSlnMSDepApp().getPSDCMSPlatformNode().getSSHIPAddr()}
</#if>
deploy:
mode: replicated
replicas: 1
......
......@@ -14,6 +14,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@Slf4j
@Import({
......@@ -28,9 +31,15 @@ import org.springframework.boot.SpringApplication;
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
})
public class ${app.getPKGCodeName()}Application{
public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplication.run(${app.getPKGCodeName()}Application.class,args);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new ${pub.getPKGCodeName()}.util.web.SearchContextHandlerMethodArgumentResolver());
}
}
......@@ -44,6 +44,15 @@ public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurer
@Value("${r'${ibiz.auth.path:v7/login}"'})
private String loginPath;
@Value("${r'${ibiz.file.uploadpath:ibizutil/upload}"'})
private String uploadpath;
@Value("${r'${ibiz.file.downloadpath:ibizutil/download}"'})
private String downloadpath;
@Value("${r'${ibiz.file.previewpath:ibizutil/preview}"'})
private String previewpath;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
......@@ -100,6 +109,10 @@ public class ${app.getPKGCodeName()}SecurityConfig extends WebSecurityConfigurer
).permitAll()
//放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll()
// 所有请求都需要认证
.anyRequest().authenticated()
// 防止iframe 造成跨域
......
......@@ -16,12 +16,16 @@ server:
#zuul网关路由设置
zuul:
routes:
<#assign haswfentity=false>
<#list item.getAllPSAppDataEntities() as appDataEntity>
<#assign serviceId="">
<#assign serviceUrl=srfpluralize(appDataEntity.codeName?lower_case)>
<#assign appEntity=appDataEntity.name?lower_case>
<#assign psDataEntity=appDataEntity.getPSDataEntity()>
<#assign systemName=sys.getCodeName()?lower_case>
<#if psDataEntity.hasPSDEWF()??>
<#assign haswfentity=true>
</#if>
<#if psDataEntity.getStorageMode()==4>
<#comment>serviceApi模式</#comment>
<#assign serviceId=(psDataEntity.getPSSubSysServiceAPI().getServiceCodeName())!''>
......@@ -36,6 +40,12 @@ zuul:
serviceId: ${serviceId}
stripPrefix: false
</#list>
<#if haswfentity==true>
wfcore:
path: /wfcore/**
serviceId: ibzwf-api
stripPrefix: false
</#if>
<#comment>通过设置该参数,避免Zuul转发请求时丢失Authorization请求头信息</#comment>
sensitive-headers:
- Cookie,Set-Cookie,Authorization
......
......@@ -10,6 +10,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@Slf4j
@EnableDiscoveryClient
......@@ -17,9 +20,15 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableTransactionManagement
@SpringBootApplication
@EnableFeignClients(basePackages = {"${pub.getPKGCodeName()}" })
public class DevBootApplication{
public class DevBootApplication extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new ${pub.getPKGCodeName()}.util.web.SearchContextHandlerMethodArgumentResolver());
}
}
......@@ -43,6 +43,15 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
@Value("${r'${ibiz.auth.path:v7/login}"'})
private String loginPath;
@Value("${r'${ibiz.file.uploadpath:ibizutil/upload}"'})
private String uploadpath;
@Value("${r'${ibiz.file.downloadpath:ibizutil/download}"'})
private String downloadpath;
@Value("${r'${ibiz.file.previewpath:ibizutil/preview}"'})
private String previewpath;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
......@@ -95,6 +104,10 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
).permitAll()
//放行登录请求
.antMatchers( HttpMethod.POST,"/"+loginPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll()
.anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
......
......@@ -10,4 +10,39 @@ TARGET=PSSYSTEM
</#if>
</#if>
server:
port: ${httpPort}
\ No newline at end of file
port: ${httpPort}
<#if item.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??>
#zuul网关路由设置
zuul:
routes:
<#assign haswfentity=false>
<#list item.getAllPSAppDataEntities() as appDataEntity>
<#assign serviceId="">
<#assign serviceUrl=srfpluralize(appDataEntity.codeName?lower_case)>
<#assign appEntity=appDataEntity.name?lower_case>
<#assign psDataEntity=appDataEntity.getPSDataEntity()>
<#assign systemName=sys.getCodeName()?lower_case>
<#if psDataEntity.hasPSDEWF()??>
<#assign haswfentity=true>
</#if>
<#if psDataEntity.getStorageMode()==4>
<#comment>serviceApi模式</#comment>
<#assign serviceId=(psDataEntity.getPSSubSysServiceAPI().getServiceCodeName())!''>
<#assign serviceUrl=srfpluralize(appDataEntity.name?lower_case)>
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
</#if>
</#list>
<#if haswfentity==true>
wfcore:
path: /wfcore/**
serviceId: ibzwf-api
stripPrefix: false
</#if>
<#comment>通过设置该参数,避免Zuul转发请求时丢失Authorization请求头信息</#comment>
sensitive-headers:
- Cookie,Set-Cookie,Authorization
</#if>
\ No newline at end of file
......@@ -50,7 +50,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[${item.getLogicName()}] 服务对象接口实现
*/
@Slf4j
@Service
@Service("${item.getCodeName()}ServiceImpl")
public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeName()}Mapper, ${de.getCodeName()}> implements I${de.getCodeName()}Service {
<#assign keyfield=de.getKeyPSDEField()>
......
......@@ -2,8 +2,10 @@
TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.getAllPSApps()??>
{
"predefineddatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
<#assign ct=0>
[
"entities":[
<#list sys.getAllPSApps() as app>
<#if app.getAllPSAppDataEntities?? && app.getAllPSAppDataEntities()??>
<#list app.getAllPSAppDataEntities() as appde><#comment>由于平台暂未开放获取实体操作标识的方法,所以暂时写死</#comment>
......@@ -11,18 +13,51 @@ TARGET=PSSYSTEM
<#if !P.exists(de.getCodeName(),"")>
<#if (ct>0)>
,</#if><#assign ct=ct+1>
<#assign dataSetResult=getDataSet()>
<#assign deActionResult=getDEAction()>
{
"dename":"${de.codeName}",
"delogicname":"${de.logicName}",
"sysmoudle":{"id":"${de.getPSSystemModule().codeName?upper_case}","name":"${de.getPSSystemModule().name}"},
"dedataset":[{"id":"Default","name":"默认数据集"}],
"dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}]
"dedataset":${dataSetResult},
"deaction":${deActionResult}
}
</#if>
</#list>
</#if>
</#list>
]
}
</#if>
<#comment>获取实体数据集</#comment>
<#function getDataSet>
<#assign result="[" >
<#if de.getAllPSDEDataSets()??>
<#list de.getAllPSDEDataSets() as dataSet>
<#if dataSet_index gt 0><#assign result=result+","></#if>
<#assign dataSetLogicName="">
<#if dataSet.getLogicName()?? && dataSet.getLogicName()!=''><#assign dataSetLogicName=dataSet.getLogicName()><#else><#assign dataSetLogicName=dataSet.codeName></#if>
<#assign result=result+"{\"id\":\""+dataSet.codeName+"\" , \"name\":\""+dataSetLogicName+"\"}">
</#list>
</#if>
<#assign result=result+"]" >
<#return result>
</#function>
<#comment>获取实体行为</#comment>
<#function getDEAction>
<#assign result="[" >
<#if de.getAllPSDEActions()??>
<#list de.getAllPSDEActions() as deAction>
<#if deAction_index gt 0><#assign result=result+","></#if>
<#assign deActionLogicName="">
<#if deAction.getLogicName()?? && deAction.getLogicName()!=''><#assign deActionLogicName=deAction.getLogicName()><#else><#assign deActionLogicName=deAction.codeName></#if>
<#assign result=result+"{\"id\":\""+deAction.codeName+"\" , \"name\":\""+deActionLogicName+"\" , \"type\":\""+deAction.getActionType()+"\" }">
</#list>
</#if>
<#assign result=result+"]" >
<#return result>
</#function>
......@@ -185,11 +185,13 @@ TARGET=PSDATAENTITY
</mapper>
</#if>
<#comment>上下文参数转换</#comment>
<#comment>上下文参数转换 原字符串:${srfdatacontext('field','{"defname":"PORGNAME","dename":"IBZORG"}')})</#comment>
<#comment>第一次替换:#{srf.datacontext.field','{"defname":"PORGNAME","dename":"IBZORG"}')})</#comment>
<#comment>第二次替换:#{srf.datacontext.field}</#comment>
<#function contextParamConvert contextParam>
<#assign resultParam="">
<#assign resultParam=contextParam?replace('$\{srfdatacontext(\'','#\{srf.datacontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>数据上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfsessioncontext(\'','#\{srf.sessioncontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>用户上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfwebcontext(\'','#\{srf.webcontext.')?replace("','\\{[\\S]*","\\}","r")><#comment>网页请求上下文</#comment>
<#assign resultParam=contextParam?replace('$\{srfdatacontext(\'','#\{srf.datacontext.')?replace("','\\{[\\S]*}'\\)}","\\}","r")><#comment>数据上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfsessioncontext(\'','#\{srf.sessioncontext.')?replace("','\\{[\\S]*}'\\)}","\\}","r")><#comment>用户上下文</#comment>
<#assign resultParam=resultParam?replace('$\{srfwebcontext(\'','#\{srf.webcontext.')?replace("','\\{[\\S]*}'\\)}","\\}","r")><#comment>网页请求上下文</#comment>
<#return resultParam>
</#function>
......@@ -34,9 +34,11 @@ TARGET=PSSYSSERVICEAPI
</dependency>
</dependencies>
<#if pub.getPSDeployCenter()?? && pub.getPSDeployCenter().getPSRegistryRepo()??>
<properties>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
<docker.image.prefix>${pub.getPSDeployCenter().getPSRegistryRepo().getConnStr()}</docker.image.prefix>
</properties>
</#if>
<profiles>
<profile>
......@@ -69,6 +71,8 @@ TARGET=PSSYSSERVICEAPI
</execution>
</executions>
</plugin>
<#if pub.getPSDeployCenter()?? && pub.getPSDeployCenter().getPSRegistryRepo()??>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
......@@ -86,6 +90,7 @@ TARGET=PSSYSSERVICEAPI
</resources>
</configuration>
</plugin>
</#if>
</plugins>
</build>
</profile>
......
......@@ -17,6 +17,10 @@ services:
- "${httpPort}:${httpPort}"
networks:
- agent_network
<#if sysrun?? && sysrun.getPSDevSlnMSDepAPI()?? && sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode()?? && sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode().getSSHIPAddr()??>
environment:
SPRING_CLOUD_NACOS_DISCOVERY_IP: ${sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode().getSSHIPAddr()}
</#if>
deploy:
mode: replicated
replicas: 1
......
......@@ -12,6 +12,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@Slf4j
@EnableDiscoveryClient
......@@ -23,9 +26,15 @@ import org.mybatis.spring.annotation.MapperScan;
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
})
public class ${sys.codeName}${item.codeName}Application{
public class ${sys.codeName}${item.codeName}Application extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplication.run(${sys.codeName}${item.codeName}Application.class, args);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new ${pub.getPKGCodeName()}.util.web.SearchContextHandlerMethodArgumentResolver());
}
}
......@@ -17,6 +17,8 @@ TARGET=PSDESERVICEAPI
<#assign itemSysApiCodeName = item.getPSSysServiceAPI().getCodeName()>
<#assign itemSysApiCodeNameLC = item.getPSSysServiceAPI().getCodeName()?lower_case>
<#assign keyCNLC = "_id">
<#assign deStorageMode="None">
<#if de.getStorageMode()==1><#assign deStorageMode="Sql"><#elseif de.getStorageMode()==2><#assign deStorageMode="NoSQL"><#elseif de.getStorageMode()==4><#assign deStorageMode="ServiceApi"></#if>
package ${pubPkgCodeName}.${itemSysApiCodeNameLC}.rest;
import java.sql.Timestamp;
......@@ -147,7 +149,7 @@ public class ${itemCodeName}Resource {
<#if deaction.codeName?lower_case == 'create'>
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@PreAuthorize("hasPermission('','Create',{this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
......@@ -158,7 +160,7 @@ public class ${itemCodeName}Resource {
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@PreAuthorize("hasPermission('','Create',{this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "createBatch", tags = {"createBatch" }, notes = "createBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/createbatch")
public ResponseEntity<Boolean> createBatch(${etParamsList}) {
......@@ -167,7 +169,7 @@ public class ${itemCodeName}Resource {
}
<#elseif deaction.codeName?lower_case == 'update'>
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'UPDATE',this.getEntity())")
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'Update',{this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.PUT, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
......@@ -179,7 +181,7 @@ public class ${itemCodeName}Resource {
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'UPDATE',this.getEntity())")
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'Update',{this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "UpdateBatch", tags = {"UpdateBatch" }, notes = "UpdateBatch")
@RequestMapping(method = RequestMethod.POST, value = "${fullPath}/updatebatch")
public ResponseEntity<Boolean> updateBatch(${etParamsList}) {
......@@ -202,7 +204,7 @@ public class ${itemCodeName}Resource {
}
<#elseif deaction.codeName?lower_case == 'remove'>
@PreAuthorize("hasPermission('DELETE',{#${itemCodeNameLC + keyCNLC},this.getEntity()})")
@PreAuthorize("hasPermission('Remove',{#${itemCodeNameLC + keyCNLC},{this.getEntity(),'${deStorageMode}'}})")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.DELETE, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
<#if de.getStorageMode()==4><#else> @Transactional</#if>
......@@ -218,7 +220,7 @@ public class ${itemCodeName}Resource {
}
<#elseif deaction.codeName?lower_case == 'get'>
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'READ',this.getEntity())")
@PreAuthorize("hasPermission(#${itemCodeNameLC + keyCNLC},'Get',{this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "${deaction.getLogicName()}", tags = {"${itemCodeName}" }, notes = "${deaction.getLogicName()}")
@RequestMapping(method = RequestMethod.GET, value = "${fullPath}/{${itemCodeNameLC + keyCNLC}}")
public ResponseEntity<${itemCodeName}DTO> get(${idParams}) {
......@@ -261,7 +263,7 @@ public class ${itemCodeName}Resource {
</#if>
<#elseif apiMethod.getActionType()=='FETCH'>
<#assign deds = apiMethod.getPSDEDataSet()>
@PreAuthorize("hasPermission('READ',{#context,'${deds.getCodeName()}',this.getEntity()})")
@PreAuthorize("hasPermission('Get',{#context,'${deds.getCodeName()}',this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "fetch${deds.getLogicName()}", tags = {"${itemCodeName}" } ,notes = "fetch${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<List<${itemCodeName}DTO>> fetch<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) {
......@@ -275,7 +277,7 @@ public class ${itemCodeName}Resource {
.body(list);
}
@PreAuthorize("hasPermission('READ',{#context,'${deds.getCodeName()}',this.getEntity()})")
@PreAuthorize("hasPermission('Get',{#context,'${deds.getCodeName()}',this.getEntity(),'${deStorageMode}'})")
@ApiOperation(value = "search${deds.getLogicName()}", tags = {"${itemCodeName}" } ,notes = "search${deds.getLogicName()}")
@RequestMapping(method= RequestMethod.${reqMtd} , value="${fullPath}/search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()?lower_case}<#else>${deds.getCodeName()?lower_case}</#if>")
public ResponseEntity<Page<${itemCodeName}DTO>> search<#if (deds.getName()=='DEFAULT')>${deds.getCodeName()}<#else>${deds.getCodeName()}</#if>(${deCodeName}SearchContext context) {
......
......@@ -17,6 +17,8 @@ public class FileItem
{
private String id;
private String name;
private String fileid;
private String filename;
private long size;
private String ext;
}
......@@ -3,6 +3,7 @@ TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()}.util.filter;
import ${pub.getPKGCodeName()}.util.security.AuthenticationUser;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
......@@ -109,16 +110,11 @@ public class SearchContextBase implements ISearchContext{
}
/**
* 用户上下文参数
*/
Map<String,Object> sessionparams = new HashMap<String,Object>() ;
/**
* 获取用户上下文
* @return
*/
* 获取用户上下文
* @return
*/
public Map<String,Object> getSessioncontext() {
return sessionparams;
return AuthenticationUser.getAuthenticationUser().getSessionParams();
}
@JsonAnyGetter
......
......@@ -44,14 +44,13 @@ public class PermissionSyncJob implements ApplicationRunner {
private String systemId;
@Override
public void run(ApplicationArguments args) throws Exception {
public void run(ApplicationArguments args) {
if(enablePermissionValid){
try {
InputStream permission= this.getClass().getResourceAsStream("/deprivs/DEPrivs.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONArray jsonNodePermission = JSONArray.parseArray(permissionResult);
Map<String,Object> map=new HashMap<String,Object>();
map.put("menu",new JSONArray());
JSONObject jsonNodePermission = JSONObject.parseObject(permissionResult);
Map<String,Object> map=new HashMap<>();
map.put("permission",jsonNodePermission);
client.pushSystemPermissionData(map,systemId);
}
......
......@@ -17,21 +17,20 @@ import java.io.*;
@Slf4j
@RestController
@RequestMapping("/")
public class FileController
{
@Autowired
private FileService fileService;
@PostMapping(value = "${r'${ibiz.uploadpath.path:ibizutil/upload}'}")
@PostMapping(value = "${r'${ibiz.file.uploadpath:ibizutil/upload}'}")
public ResponseEntity<FileItem> upload(@RequestParam("file") MultipartFile multipartFile){
return ResponseEntity.ok().body(fileService.saveFile(multipartFile));
}
private final String defaultdownloadpath="ibizutil/download/{id}";
protected String getDefaultdownloadpath(){
return defaultdownloadpath;
}
@GetMapping(value = "${r'${ibiz.file.downloadpath:"+defaultdownloadpath+"}'}")
@ResponseStatus(HttpStatus.OK)
......
......@@ -58,7 +58,7 @@ public class AuthenticationUser implements UserDetails
private String fontsize;
private String lang;
private String memo;
private Map <String,String> sessionParams;
private Map <String,Object> sessionParams;
@JsonIgnore
private Collection<GrantedAuthority> authorities;
@JsonIgnore
......@@ -68,7 +68,7 @@ public class AuthenticationUser implements UserDetails
private String orglevel;//单位级别
private String deptlevel;//部门级别
@JsonIgnore
private Map<String,String> userSessionParam;//用户自定义session
private Map<String,Object> userSessionParam;//用户自定义session
@JsonIgnore
private JSONObject orgInfo;//上下级组织信息
......@@ -118,7 +118,7 @@ public class AuthenticationUser implements UserDetails
return authuserdetail;
}
public Map <String,String> getSessionParams()
public Map <String,Object> getSessionParams()
{
if(this.sessionParams==null)
{
......@@ -142,7 +142,7 @@ public class AuthenticationUser implements UserDetails
}
return this.sessionParams;
}
private Map<String, String> getUserSessionParam() {
private Map<String, Object> getUserSessionParam() {
if(userSessionParam!=null)
return userSessionParam;
else
......
......@@ -4,8 +4,9 @@ TARGET=PSSYSTEM
package ${pub.getPKGCodeName()}.util.service;
import ${pub.getPKGCodeName()}.util.domain.FileItem;
import com.cmbchina.util.errors.InternalServerErrorException;
import ${pub.getPKGCodeName()}.util.errors.InternalServerErrorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.DigestUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
......@@ -14,7 +15,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.UUID;
@Primary
@Slf4j
......@@ -24,26 +24,22 @@ public class SimpleFileService implements FileService {
@Value("${r'${ibiz.filePath:/app/file/}'}")
private String fileRoot;
@Override
public FileItem saveFile(MultipartFile multipartFile) {
FileItem item=null;
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String extname="."+getExtensionName(fileName);
// uuid作为文件名,防止生成的临时文件重复
String fileid= UUID.randomUUID().toString();
String fileFullPath = this.fileRoot+"ibztuit"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath);
File parent = new File(file.getParent());
if(!parent.exists())
parent.mkdirs();
try {
FileCopyUtils.copy(multipartFile.getInputStream() , Files.newOutputStream(file.toPath()));
item=new FileItem(fileid,fileName, (int)multipartFile.getSize() ,extname);
String fileid= DigestUtils.md5DigestAsHex(multipartFile.getInputStream());
String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath);
File parent = new File(file.getParent());
if(!parent.exists())
parent.mkdirs();
FileCopyUtils.copy(multipartFile.getInputStream(),Files.newOutputStream(file.toPath()));
item=new FileItem(fileid,fileName,fileid,fileName,(int)multipartFile.getSize(),extname);
} catch (IOException e) {
throw new InternalServerErrorException("文件上传失败");
}
......@@ -52,7 +48,7 @@ public class SimpleFileService implements FileService {
@Override
public File getFile(String fileid) {
String dirpath = this.fileRoot+"ibztuit"+File.separator+fileid;
String dirpath = this.fileRoot+"ibizutil"+File.separator+fileid;
File parent = new File(dirpath);
if (parent.exists() && parent.isDirectory() && parent.listFiles().length > 0) {
return parent.listFiles()[0];
......
......@@ -112,7 +112,10 @@ public class SimpleUserService implements AuthenticationUserService{
JSONObject orgInfo=ouFeignClient.getOrgInfo(user.getLoginname());
if(orgInfo==null)
throw new RuntimeException("获取用户信息失败,请检查用户中心[IBZOU]中是否存在当前用户!");
JSONObject curUser=orgInfo.getJSONObject("curuser");
user.setOrgInfo(orgInfo);
user.setMdeptid(curUser.getString("orgdept"));
user.setOrgid(curUser.getString("org"));
}
}
......
......@@ -78,3 +78,7 @@ logging:
ribbon:
ReadTimeout: 60000
ConnectTimeout: 60000
#系统是否开启权限验证
ibiz:
enablePermissionValid: false
......@@ -2,7 +2,7 @@
TARGET=PSSYSTEM
</#ibiztemplate>
<#if pub.getPSDeployCenter()?? && sysrun.getRunMode()??>
<#if pub.getPSDeployCenter().getDeployCenterType()?? && (pub.getPSDeployCenter().getDeployCenterType()=="JENKINS") >
<#if pub.getPSDeployCenter().getCIType()?? && (pub.getPSDeployCenter().getCIType()=="JENKINS") >
<#if sysrun.getRunMode() == "STARTMSAPI">
<#assign depapi = sysrun.getPSDevSlnMSDepAPI()>
<#assign configId = depapi.getId()>
......@@ -53,6 +53,7 @@ TARGET=PSSYSTEM
<hudson.tasks.Shell>
<command>
BUILD_ID=DONTKILLME
echo "${pub.getPSDeployCenter().getPSRegistryRepo().getConnStr()}"
source /etc/profile
rm -rf ${sys.codeName?lower_case}
git clone -b ${branch} $para2 ${sys.codeName?lower_case}/
......@@ -60,10 +61,13 @@ TARGET=PSSYSTEM
cd ${sys.codeName?lower_case}/
<#if sysrun.getRunMode() == "STARTMSAPP">
mvn clean package -P${pub.getPSApplication().getPKGCodeName()?lower_case}
<#if pub.getPSDeployCenter().getCDType()?? && (pub.getPSDeployCenter().getCDType()=="SWARM") >
cd ${pub.getCodeName()?lower_case}-app/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}
mvn -P${pub.getPSApplication().getPKGCodeName()?lower_case} docker:build
mvn -P${pub.getPSApplication().getPKGCodeName()?lower_case} docker:push
docker -H tcp://172.16.102.110:2375 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.yaml dev --with-registry-auth
docker -H $para1 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.yaml dev --with-registry-auth
<#elseif pub.getPSDeployCenter().getCDType()?? && (pub.getPSDeployCenter().getCDType()=="K8S") >
<#else>
echo &apos;echo &quot;$para1&quot;&apos; &gt; apppasswd.sh
chmod -R 777 *
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;mkdir -p ${depnode.getWorkshopPath()}/${configId}&quot;
......@@ -71,18 +75,23 @@ TARGET=PSSYSTEM
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;ps -ef | grep &apos;${depnode.getWorkshopPath()}/${configId}&apos;| tr -s &apos; &apos;|cut -d&apos; &apos; -f2,8,9 | grep -v grep | grep &apos;jar&apos; | cut -d&apos; &apos; -f1|xargs --no-run-if-empty kill -9&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;source /etc/profile;source ~/.bash_profile; nohup java -jar -Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=128m ${depnode.getWorkshopPath()}/${configId}/${pub.getCodeName()?lower_case}-app-${pub.getPSApplication().getPKGCodeName()?lower_case}.jar &gt;&gt;${depnode.getWorkshopPath()}/${configId}/${sys.codeName?lower_case}_${config?lower_case}-`date --date=&apos;0 days ago&apos; +%Y-%m-%d`.log 2&gt;&amp;1 &amp;&quot;
</#if>
</#if>
<#if sysrun.getRunMode() == "STARTMSAPI">
mvn clean package -P${pub.getPSSysServiceAPI().getCodeName()?lower_case}
<#if pub.getPSDeployCenter().getCDType()?? && (pub.getPSDeployCenter().getCDType()=="SWARM") >
cd ${pub.getCodeName()?lower_case}-provider/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}
mvn -P${pub.getPSSysServiceAPI().getCodeName()?lower_case} docker:build
mvn -P${pub.getPSSysServiceAPI().getCodeName()?lower_case} docker:push
docker -H tcp://172.16.102.110:2375 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.yaml dev --with-registry-auth
docker -H $para1 stack deploy --compose-file=src/main/docker/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.yaml dev --with-registry-auth
<#elseif pub.getPSDeployCenter().getCDType()?? && (pub.getPSDeployCenter().getCDType()=="K8S") >
<#else>
echo &apos;echo &quot;$para1&quot;&apos; &gt; apppasswd.sh
chmod -R 777 *
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;mkdir -p ${depnode.getWorkshopPath()}/${configId}&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; scp -r ${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.jar ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()}:${depnode.getWorkshopPath()}/${configId}
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;ps -ef | grep &apos;${depnode.getWorkshopPath()}/${configId}&apos;| tr -s &apos; &apos;|cut -d&apos; &apos; -f2,8,9 | grep -v grep | grep &apos;jar&apos; | cut -d&apos; &apos; -f1|xargs --no-run-if-empty kill -9&quot;
setsid env SSH_ASKPASS=&apos;./apppasswd.sh&apos; DISPLAY=&apos;none:0&apos; ssh ${depnode.getSSHUserName()}@${depnode.getSSHIPAddr()} &quot;source /etc/profile;source ~/.bash_profile; nohup java -jar -Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=128m ${depnode.getWorkshopPath()}/${configId}/${pub.getCodeName()?lower_case}-provider-${pub.getPSSysServiceAPI().getCodeName()?lower_case}.jar &gt;&gt;${depnode.getWorkshopPath()}/${configId}/${sys.codeName?lower_case}_${config?lower_case}-`date --date=&apos;0 days ago&apos; +%Y-%m-%d`.log 2&gt;&amp;1 &amp;&quot;
</#if>
</#if>
</command>
</hudson.tasks.Shell>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册