提交 69049561 编写于 作者: ibizdev's avatar ibizdev

初始化提交

上级 f8a39c95
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}-app-usr</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app-usr-${app.getPKGCodeName()?lower_case}</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} User Code ${app.getPKGCodeName()}</name>
<description>${pub.getCodeName()?lower_case?cap_first} User Code ${app.getPKGCodeName()}</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app-usr</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} User Code</name>
<description>${pub.getCodeName()?lower_case?cap_first} user code</description>
<packaging>pom</packaging>
<#-- modules -->
<#if sys.getAllPSApps()??>
<modules>
<#list sys.getAllPSApps() as app>
<module>${pub.getCodeName()?lower_case}-app-usr-${app.getPKGCodeName()?lower_case}</module>
</#list>
</modules>
</#if>
<dependencies>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}-app</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} ${app.getPKGCodeName()}</name>
<description>${pub.getCodeName()?lower_case?cap_first} ${app.getPKGCodeName()}</description>
<dependencies>
<#if app.getAppMode()?? && app.getAppMode() == "WFAPP">
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-workflow</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#if>
</dependencies>
<profiles>
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>exec-yarn-run-install</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>yarn</executable>
<workingDirectory>../../app_${app.getPKGCodeName()}</workingDirectory>
</configuration>
</execution>
<execution>
<id>exec-yarn-run-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>yarn</executable>
<arguments>
<argument>build</argument>
</arguments>
<workingDirectory>../../app_${app.getPKGCodeName()}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>${r'${basedir}'}/src/main/webapp</directory>
<!--注意此次必须要放在此目录下才能被访问到 -->
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>${r'${basedir}'}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${app.getPKGCodeName()}Application</mainClass>
<#-- <outputDirectory>../</outputDirectory> -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case};
import java.util.List;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.fasterxml.jackson.databind.ObjectMapper;
import ${pub.getPKGCodeName()}.util.web.SearchContextHandlerMethodArgumentResolver;
import ${pub.getPKGCodeName()}.util.serialize.DomainSerializerProvider;
import lombok.Data;
@SpringBootApplication(exclude = {
})
@Import({
FeignClientsConfiguration.class
})
@ComponentScans({
@ComponentScan(basePackages = {"${pub.getPKGCodeName()}.util", "${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}"})
})
@EnableDiscoveryClient
@Configuration
@EnableFeignClients
<#if app.getPSSysServiceAPI()??>
@EnableConfigurationProperties(${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${app.getPKGCodeName()}Application.${app.getPSSysServiceAPI().getCodeName()}ClientProperties.class)
</#if>
public class ${app.getPKGCodeName()}Application extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplicationBuilder builder=new SpringApplicationBuilder(${app.getPKGCodeName()}Application.class);
builder.run(args);
}
@Bean
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter(ObjectMapper objectMapper) {
objectMapper.setSerializerProvider(new DomainSerializerProvider()) ;
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
return converter;
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new SearchContextHandlerMethodArgumentResolver());
}
<#if app.getPSSysServiceAPI()??>
@ConfigurationProperties(prefix = "app.service.${app.getPSSysServiceAPI().getCodeName()?lower_case?replace('_','.')}")
@Data
public class ${app.getPSSysServiceAPI().getCodeName()}ClientProperties {
private String tokenUrl ;
private String clientId ;
private String clientSecret ;
private String serviceUrl ;
private String serviceId ;
}
</#if>
}
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${de.getPSSystemModule().getCodeName()?lower_case}.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 应用实体[${item.getLogicName()}]
*/
public class ${item.getCodeName()} implements Serializable {
private static final long serialVersionUID = 1L;
<#if item.getAllPSAppDEFields()??>
<#list item.getAllPSAppDEFields() as appfield>
/**
* ${appfield.getPSDEField().getLogicName()}
*/
<#assign defDataType = (appfield.getPSDEField().getDataType())!"">
<#if defDataType == "DATETIME" || (defDataType=='PICKUPDATA' && srfdatatype(appfield.getPSDEField().getStdDataType())== "DATETIME" && appfield.getPSDEField().getValueFormat()=="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
<#elseif defDataType == "DATE" || (defDataType=='PICKUPDATA' && srfdatatype(appfield.getPSDEField().getStdDataType())== "DATETIME" && appfield.getPSDEField().getValueFormat()=="%1$tY-%1$tm-%1$td")>
@JsonFormat(pattern="yyyy-MM-dd", locale = "zh" , timezone="GMT+8")
<#elseif defDataType == "TIME" || (defDataType=='PICKUPDATA' && srfdatatype(appfield.getPSDEField().getStdDataType())== "DATETIME" && appfield.getPSDEField().getValueFormat()=="%1$tH:%1$tM:%1$tS")>
@JsonFormat(pattern="HH:mm", locale = "zh" , timezone="GMT+8")
</#if>
private ${srfjavatype(appfield.getStdDataType())} ${appfield.getCodeName()?uncap_first};
@JsonIgnore
private boolean ${appfield.getCodeName()?uncap_first}DirtyFlag;
</#list>
<#list item.getAllPSAppDEFields() as appfield>
/**
* 获取 [${appfield.getPSDEField().getLogicName()}]
*/
@JsonProperty("${appfield.getCodeName()?lower_case}")
public ${srfjavatype(appfield.getStdDataType())} get${appfield.getCodeName()?cap_first}(){
return this.${appfield.getCodeName()?uncap_first} ;
}
/**
* 设置 [${appfield.getPSDEField().getLogicName()}]
*/
@JsonProperty("${appfield.getCodeName()?lower_case}")
public void set${appfield.getCodeName()?cap_first}(${srfjavatype(appfield.getStdDataType())} ${appfield.getCodeName()?uncap_first}){
this.${appfield.getCodeName()?uncap_first} = ${appfield.getCodeName()?uncap_first} ;
this.${appfield.getCodeName()?uncap_first}DirtyFlag = true ;
}
/**
* 获取 [${appfield.getPSDEField().getLogicName()}]脏标记
*/
@JsonIgnore
public boolean get${appfield.getCodeName()?cap_first}DirtyFlag(){
return this.${appfield.getCodeName()?uncap_first}DirtyFlag ;
}
</#list>
</#if>
<#comment>嵌套对象</#comment>
<#if item.getMajorPSAppDERSs()?? >
<#list item.getMajorPSAppDERSs() as appder>
<#assign subs = srfpluralize(appder.getMinorPSAppDataEntity().getCodeName())?lower_case >
<#-- <#if appder.getParentFilter()?? >
<#assign subs = appder.getParentFilter()?uncap_first >
<#else>
<#if appder.getPSDER1N()??>
<#assign subs = appder.getPSDER1N().getCodeName()?uncap_first >
</#if>
</#if> -->
private List <${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${appder.getMinorPSAppDataEntity().getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${appder.getMinorPSAppDataEntity().getCodeName()}> ${subs} = new ArrayList<${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${appder.getMinorPSAppDataEntity().getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${appder.getMinorPSAppDataEntity().getCodeName()}>() ;
public List<${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${appder.getMinorPSAppDataEntity().getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${appder.getMinorPSAppDataEntity().getCodeName()}> get${subs?cap_first}(){
return ${subs} ;
}
public void set${subs?cap_first}(List <${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${appder.getMinorPSAppDataEntity().getPSDataEntity().getPSSystemModule().getCodeName()?lower_case}.domain.${appder.getMinorPSAppDataEntity().getCodeName()}> ${subs}){
this.${subs} = ${subs} ;
}
</#list>
</#if>
}
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${de.getPSSystemModule().codeName?lower_case}.filter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import ${pub.getPKGCodeName()}.util.SearchContext;
@Data
public class ${item.getCodeName()}SearchContext extends SearchContext implements Serializable {
<#list de.getPSDEFields() as defield>
<#if defield.getAllPSDEFSearchModes()??>
<#list defield.getAllPSDEFSearchModes() as formitem>
<#assign defDataType=formitem.getPSDEField().getDataType()>
<#if defDataType == "DATETIME">
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
<#elseif defDataType == "DATE">
@JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
<#elseif defDataType == "TIME">
@JsonFormat(pattern="HH:mm", timezone="GMT+8")
</#if>
public ${srfjavatype(formitem.getPSDEField().stdDataType)} ${formitem.getName()?lower_case};//[${defield.getLogicName()}]
</#list>
</#if>
</#list>
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.app;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import ${pub.getPKGCodeName()}.util.helper.SpringContextHolder;
import ${pub.getPKGCodeName()}.util.security.userdetail.LoginUser;
import ${pub.getPKGCodeName()}.util.web.SessionConstants;
import ${pub.getPKGCodeName()}.util.web.AppContextConstants;
@RestController
@RequestMapping(value = "")
public class ${app.getPKGCodeName()}AppController {
@RequestMapping(method = RequestMethod.GET, value = "/appdata")
public ResponseEntity<JSONObject> getAppData() {
JSONObject appData = new JSONObject() ;
JSONObject context = new JSONObject() ;
List<Map> orgDepts = new ArrayList<Map>();
LoginUser loginUser = SpringContextHolder.getCurLoginUser();
if (loginUser != null) {
context.put(AppContextConstants.CONTEXT_USERID, loginUser.getPersonId());
context.put(AppContextConstants.CONTEXT_USERNAME, loginUser.getOrgUserName());
context.put(AppContextConstants.CONTEXT_USERICONPATH, loginUser.getUserIconPath());
context.put(AppContextConstants.CONTEXT_USERMODE, loginUser.getUserMode());
context.put(AppContextConstants.CONTEXT_LOGINNAME, loginUser.getUsername());
context.put(AppContextConstants.CONTEXT_LOCALE, loginUser.getLocale());
context.put(AppContextConstants.CONTEXT_TIMEZONE, loginUser.getTimeZone());
context.put(AppContextConstants.CONTEXT_ORGID, loginUser.getOrgId());
context.put(AppContextConstants.CONTEXT_ORGNAME, loginUser.getOrgName());
context.put(AppContextConstants.CONTEXT_ORGSECTORID, loginUser.getOrgDeptId());
context.put(AppContextConstants.CONTEXT_ORGSECTORNAME, loginUser.getOrgDeptName());
orgDepts = loginUser.getOrgDepts() ;
}
appData.put(AppContextConstants.CONTEXT_ORGSECTORS, orgDepts) ;
appData.put("context", context);
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.controller;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.domain.SRFFILE;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.domain.SRFFILEItem;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.service.SRFFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.UUID;
/**
* 文件上传下载
*/
@RestController
@RequestMapping("/")
public class SRFFileController
{
@Autowired
private SRFFileService srfFileService;
//文件存在目录
@Value(${r'"${ibiz.filepath:/app/file/}"'})
private String FILEPATH;
//文件上传URL
private final String defaultuploadpath="ibizutil/upload";
//文件下载URL
private final String defaultdownloadpath="ibizutil/download/{id}";
/**
* 文件上传
* @param multipartFile
* @return
* @throws Exception
*/
@PostMapping(value = ${r'"${ibiz.file.uploadpath:"'}+defaultuploadpath+"}")
public ResponseEntity<SRFFILEItem> upload(@RequestParam("file") MultipartFile multipartFile) throws Exception {
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String extname="."+getExtensionName(fileName);
// uuid作为文件名,防止生成的临时文件重复
String fileid= UUID.randomUUID().toString();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String filepath=dateFormat.format(new java.util.Date())+ File.separator+fileid+ File.separator;
SRFFILE ibzfile=new SRFFILE();
ibzfile.setSRFFILEId(fileid);
ibzfile.setSRFFILEName(fileName);
ibzfile.setFileext(extname);
ibzfile.setFilesize((int)multipartFile.getSize());
ibzfile.setFilepath(filepath+fileName);
boolean flag = srfFileService.save(fileid,ibzfile);
if(!flag){
throw new Exception("文件上传发生异常,存储文件记录失败!");
}
String dirPath=FILEPATH+filepath;
File dir=new File(dirPath);
if(!dir.exists()){
dir.mkdirs();
}
File file = new File(dir,fileName);
FileCopyUtils.copy(multipartFile.getInputStream(), Files.newOutputStream(file.toPath()));
SRFFILEItem fileItem=new SRFFILEItem(fileid,fileName,file.length(),extname);
return ResponseEntity.ok().body(fileItem);
}
/**
* 文件下载
* @param id
* @param response
* @throws Exception
*/
@GetMapping(value = ${r'"${ibiz.file.downloadpath:"'}+defaultdownloadpath+"}")
@ResponseStatus(HttpStatus.OK)
public void download(@PathVariable String id, HttpServletResponse response) throws Exception {
File file= getFile(id);
String fileName=file.getName();
try {
fileName=new String(fileName.getBytes("utf-8"),"iso8859-1");//防止中文乱码
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setHeader("Content-Disposition", "attachment;filename="+fileName);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(file));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
}
catch (Exception e) {
//throw e;
}
finally {
if (bis != null) {
try {
bis.close();
}
catch (IOException e) {
}
}
if (bos != null) {
try {
bos.close();
}
catch (IOException e) {
}
}
}
}
/**
* 获取file
* @param id
* @return
* @throws Exception
*/
private File getFile(String id) throws Exception {
SRFFILE ibzfile=srfFileService.get(id);
if(ibzfile==null)
throw new Exception("获取文件失败");
String filepath=ibzfile.getFilepath();
filepath=filepath.replace("\\",File.separator);
filepath=filepath.replace("/",File.separator);
File file=new File(FILEPATH+filepath);
if(!file.exists())
throw new Exception("获取文件失败");
return file;
}
/**
* 获取文件扩展名
* @param filename
* @return
*/
private String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 上传文件对象
*/
@Data
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
public class SRFFILEItem
{
private String fileid;
private String filename;
private long filesize;
private String extname;
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.feign;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.domain.SRFFILE;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
public interface SRFFileFeignClient {
@RequestMapping(method = RequestMethod.POST, value = "/web/srffiles/{srffile_id}/save")
boolean save(@PathVariable("srffile_id") String fileId, @RequestBody SRFFILE srffile) ;
@RequestMapping(method = RequestMethod.GET, value = "/web/srffiles/{srffile_id}")
SRFFILE get(@PathVariable("srffile_id") String fileId) ;
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.service;
import ${pub.getPKGCodeName()}.util.feign.FeignRequestInterceptor;
import ${pub.getPKGCodeName()}.util.feign.suport.SearchContextFeignEncode;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${app.getPKGCodeName()}Application;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.domain.SRFFILE;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.rt.feign.SRFFileFeignClient;
import feign.Client;
import feign.Contract;
import feign.Feign;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;
import org.springframework.stereotype.Component;
/**
* 文件上传
*/
@Component
public class SRFFileService {
SRFFileFeignClient client;
@Autowired
public SRFFileService(Decoder decoder, Encoder encoder, Client client, Contract contract, FeignRequestInterceptor feignRequestInterceptor,
${app.getPKGCodeName()}Application.${app.getPSSysServiceAPI().getCodeName()}ClientProperties webClientProperties) {
if (webClientProperties.getServiceId()!=null) {
Feign.Builder nameBuilder = Feign.builder()
.client(client)
.encoder(new SearchContextFeignEncode(encoder))
.decoder(decoder)
.contract(contract)
.requestInterceptor(feignRequestInterceptor)
;
this.client = nameBuilder.target(SRFFileFeignClient.class,"http://" + webClientProperties.getServiceId() + "/") ;
} else if (webClientProperties.getServiceUrl()!=null) {
if (client instanceof LoadBalancerFeignClient) {
client = ((LoadBalancerFeignClient) client).getDelegate();
}
Feign.Builder nameBuilder = Feign.builder()
.client(client)
.encoder(new SearchContextFeignEncode(encoder))
.decoder(decoder)
.contract(contract)
.requestInterceptor(feignRequestInterceptor)
;
this.client = nameBuilder.target(SRFFileFeignClient.class, "http://" + webClientProperties.getServiceUrl() + "/") ;
}
}
/**
* 保存file记录
* @param fileId
* @param ibzfile
* @return
*/
public boolean save(String fileId, SRFFILE ibzfile) {
return client.save(fileId, ibzfile);
}
/**
* 获取file记录
* @param fileId
* @return
*/
public SRFFILE get(String fileId) {
return client.get(fileId);
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.cas;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
@Configuration
@EnableConfigurationProperties({CasServerConfig.class, CasServiceConfig.class})
public class CasConfiguration {
@Autowired
private CasServerConfig casServerConfig;
@Autowired
private CasServiceConfig casServiceConfig;
@Bean
public ServiceProperties serviceProperties() {
ServiceProperties serviceProperties = new ServiceProperties();
serviceProperties.setService(this.casServiceConfig.getHost() + this.casServiceConfig.getLogin());
serviceProperties.setSendRenew(this.casServiceConfig.getSendRenew());
return serviceProperties;
}
@Bean
public CasAuthenticationFilter casAuthenticationFilter(AuthenticationManager authenticationManager ,ServiceProperties serviceProperties) {
CasAuthenticationFilter casAuthenticationFilter = new CasAuthenticationFilter();
casAuthenticationFilter.setAuthenticationManager(authenticationManager);
casAuthenticationFilter.setServiceProperties(serviceProperties);
casAuthenticationFilter.setFilterProcessesUrl(this.casServiceConfig.getLogin());
casAuthenticationFilter.setContinueChainBeforeSuccessfulAuthentication(false);
casAuthenticationFilter.setAuthenticationSuccessHandler(
new SimpleUrlAuthenticationSuccessHandler("/")
);
return casAuthenticationFilter;
}
@Bean
public CasAuthenticationEntryPoint casAuthenticationEntryPoint(ServiceProperties serviceProperties) {
CasAuthenticationEntryPoint entryPoint = new CasAuthenticationEntryPoint();
entryPoint.setLoginUrl(this.casServerConfig.getLogin());
entryPoint.setServiceProperties(serviceProperties);
return entryPoint;
}
@Bean
public Cas20ServiceTicketValidator cas20ServiceTicketValidator() {
return new Cas20ServiceTicketValidator(this.casServerConfig.getHost());
}
/**用户自定义的AuthenticationUserDetailsService*/
@Bean
public AuthenticationUserDetailsService<CasAssertionAuthenticationToken> casUserDetailsService(){
return new CasUserDetailsService();
}
@Bean
public CasAuthenticationProvider casAuthenticationProvider(
ServiceProperties serviceProperties, Cas20ServiceTicketValidator ticketValidator) {
CasAuthenticationProvider provider = new CasAuthenticationProvider();
provider.setKey("casProvider");
provider.setServiceProperties(serviceProperties);
provider.setTicketValidator(ticketValidator);
provider.setAuthenticationUserDetailsService(casUserDetailsService());
return provider;
}
@Bean
public LogoutFilter logoutFilter() {
String logoutRedirectPath = this.casServerConfig.getLogout() + "?service=" +
this.casServiceConfig.getHost();
LogoutFilter logoutFilter = new LogoutFilter(logoutRedirectPath, new SecurityContextLogoutHandler());
logoutFilter.setFilterProcessesUrl(this.casServiceConfig.getLogout());
return logoutFilter;
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.cas;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "security.cas.server")
public class CasServerConfig {
private String host;
private String login;
private String logout;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.cas;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "security.cas.service")
public class CasServiceConfig {
private String host;
private String login;
private String logout;
private Boolean sendRenew = false;
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.cas;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import ${pub.getPKGCodeName()}.util.security.userdetail.LoginUser;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.userdetail.LoginUserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
/**
* 用于加载用户信息 实现UserDetailsService接口,或者实现AuthenticationUserDetailsService接口
*/
public class CasUserDetailsService implements AuthenticationUserDetailsService<CasAssertionAuthenticationToken> {
@Autowired
UserDetailsService userDetailsService ;
@Override
public UserDetails loadUserDetails(CasAssertionAuthenticationToken token) throws UsernameNotFoundException {
//获取用户信息
UserDetails userDetails = userDetailsService.loadUserByUsername(token.getName()) ;
return userDetails;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.config;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.cas.CasServerConfig;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.filter.LoginFilter;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.filter.TokenAuthenticationFilter;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token.TokenManager;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token.UnauthorizedEntryPoint;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.userdetail.LoginUserDetailService;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.web.cors.CorsUtils;
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled=true)
@Order(SecurityProperties.BASIC_AUTH_ORDER)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
UserDetailsService userDetails(){
return new LoginUserDetailService();
}
@Value("${r'${server.devmode:true}'}")
private boolean devmode;
@Autowired
private CasAuthenticationEntryPoint casAuthenticationEntryPoint;
@Autowired
private CasAuthenticationProvider casAuthenticationProvider;
@Autowired
private CasAuthenticationFilter casAuthenticationFilter;
@Autowired
private LogoutFilter logoutFilter;
@Autowired
private CasServerConfig casServerConfig;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable();
http.csrf().disable();
if(devmode){
http.csrf().disable()
.authorizeRequests()
.anyRequest().permitAll()
.and().logout().permitAll();
}else{
http.authorizeRequests()
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.antMatchers("/static/**").permitAll() // 不拦截静态资源
.antMatchers("/api/**").permitAll() // 不拦截对外API
.anyRequest().authenticated(); // 所有资源都需要登陆后才可以访问。
http.logout().permitAll(); // 不拦截注销
http.exceptionHandling().authenticationEntryPoint(casAuthenticationEntryPoint);
SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter();
singleSignOutFilter.setCasServerUrlPrefix(this.casServerConfig.getHost());
http.addFilter(casAuthenticationFilter)
.addFilterBefore(logoutFilter, LogoutFilter.class)
.addFilterBefore(singleSignOutFilter, CasAuthenticationFilter.class);
http.antMatcher("/**");
}
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(casAuthenticationProvider);
}
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean() ;
}
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener(){
ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> servletListenerRegistrationBean =
new ServletListenerRegistrationBean<>();
servletListenerRegistrationBean.setListener(new SingleSignOutHttpSessionListener());
return servletListenerRegistrationBean;
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.filter;
import com.fasterxml.jackson.databind.ObjectMapper;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token.TokenManager;
import ${pub.getPKGCodeName()}.util.security.userdetail.LoginUser;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
public class LoginFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;
private TokenManager tokenManager;
public LoginFilter(AuthenticationManager authenticationManager, TokenManager tokenManager) {
this.authenticationManager = authenticationManager;
this.tokenManager = tokenManager;
this.setPostOnly(false);
this.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/login"));
}
@Override
public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res)
throws AuthenticationException {
String strUserName = req.getParameter("username") ;
String strPassword = req.getParameter("password") ;
return authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(strUserName, strPassword, new ArrayList<>()));
}
@Override
protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, FilterChain chain,
Authentication auth) throws IOException, ServletException {
LoginUser user = (LoginUser) auth.getPrincipal();
String token = tokenManager.generateToken(user);
ObjectMapper mapper = new ObjectMapper();
res.setStatus(HttpStatus.OK.value());
res.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
mapper.writeValue(res.getWriter(), token);
}
@Override
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
AuthenticationException e) throws IOException, ServletException {
response.setStatus(HttpStatus.OK.value());
ObjectMapper mapper = new ObjectMapper();
if (e instanceof BadCredentialsException) {
} else if (e instanceof UsernameNotFoundException) {
} else if (e instanceof AuthenticationCredentialsNotFoundException) {
} else if (e instanceof ProviderNotFoundException) {
} else {
}
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
mapper.writeValue(response.getWriter(), "登陆失败");
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.filter;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token.TokenManager;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.util.StringUtils;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
public class TokenAuthenticationFilter extends BasicAuthenticationFilter {
TokenManager tokenManager ;
private String tokenHeader;
public TokenAuthenticationFilter(AuthenticationManager authManager, TokenManager tokenManager,String tokenHeader) {
super(authManager);
this.tokenManager = tokenManager;
this.tokenHeader = tokenHeader ;
}
@Override
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
throws IOException, ServletException {
String headerToken = req.getHeader(tokenHeader);
if (headerToken == null) {
chain.doFilter(req, res);
return;
}
if (headerToken.startsWith("Bearer ")) {
String strToken = headerToken.substring(7);
try {
UsernamePasswordAuthenticationToken authentication = tokenManager.parseToken(strToken);
if (authentication != null) {
SecurityContextHolder.getContext().setAuthentication(authentication);
}
} catch (ExpiredJwtException e) {
}
}
chain.doFilter(req, res);
}
}
<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.permission.${de.getPSSystemModule().codeName?lower_case};
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.PageRequest;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${de.getPSSystemModule().codeName?lower_case}.service.${item.getCodeName()}Service;
import ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.${de.getPSSystemModule().codeName?lower_case}.domain.${item.getCodeName()};
@Component("${item.getCodeName()?lower_case}_pms")
public class ${item.getCodeName()}Permission {
<#assign keyCNLC = "_id">
<#assign itemCodeName = item.getCodeName()>
<#assign itemCodeNameLC = itemCodeName?lower_case>
@Autowired
${item.getCodeName()}Service ${item.getCodeName()?lower_case}service;
<#-- 主实体 start -->
<#if item.isMajor()>
<#assign parentParams = "">
<#assign idParams = "">
<#assign idParams = idParams + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC + ", String action" >
<#if item.getAllPSAppDEMethods()??>
public boolean check(String action){
return true ;
}
public boolean check(${idParams}){
return true ;
}
</#if>
</#if>
<#-- 主实体 end -->
<#-- 关系接口 start -->
<#if item.getPSAppDERSPathCount() gt 0>
<#list 0..1000 as x>
<#if x gte item.getPSAppDERSPathCount()>
<#break>
<#else>
<#assign parentParams = "">
<#assign byParams = "By">
<#assign idParams = "">
<#assign noIdParams = "">
<#list item.getPSAppDERSPath(x) as rs>
<#assign rsMainAppDe = rs.getMajorPSAppDataEntity()>
<#assign rsMainDe = rsMainAppDe.getPSDataEntity()>
<#assign rsMainAppDeCN = rsMainAppDe.codeName >
<#assign rsMainAppDeCNLC = rsMainAppDeCN?lower_case >
<#assign rsMainDePKCN = rsMainDe.getKeyPSDEField().codeName >
<#assign rsMainDePKCNLC = rsMainDePKCN?lower_case >
<#assign rsMainDePKDataType = rsMainDe.getKeyPSDEField().stdDataType >
<#if x != 0>
<#assign parentParams += ", ">
</#if>
<#assign parentParams += "" + srfjavatype(rsMainDePKDataType) + " " + rsMainAppDeCNLC + keyCNLC >
<#assign byParams += rsMainAppDeCN >
<#if parentParams != "" >
<#assign idParams = parentParams + ", ">
<#assign noIdParams = parentParams + ", ">
</#if>
</#list>
<#assign idParams = idParams + " " + srfjavatype(de.getKeyPSDEField().stdDataType) + " " + itemCodeNameLC + keyCNLC +", String action">
<#assign noIdParams = noIdParams + " String action">
<#if item.getAllPSAppDEMethods()??>
public boolean check${byParams}(${idParams}){
return true ;
}
public boolean check${byParams}(${noIdParams}){
return true ;
}
</#if>
</#if>
</#list>
</#if>
<#-- 关系接口 end -->
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Clock;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.DefaultClock;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.*;
public class TokenManager {
private static final long serialVersionUID = -3301605591108950415L;
private Clock clock = DefaultClock.INSTANCE;
@Value("${r'${ibiz.jwt.secret:ibzsecret}'}")
private String secret;
@Value("${r'${ibiz.jwt.expiration:7200000}'}")
private Long expiration;
@Value("${r'${ibiz.jwt.header:Authorization}'}")
private String tokenHeader;
public UsernamePasswordAuthenticationToken parseToken(String strToken){
Claims claims = Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(strToken)
.getBody();
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("authorities"));
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(claims.getSubject(), null, authorities);
return token ;
}
public String generateToken(UserDetails userDetails) {
Map<String, Object> claims = new HashMap<>();
final Date createdDate = clock.now();
final Date expirationDate = calculateExpirationDate(createdDate);
Collection<? extends GrantedAuthority> authorities = userDetails.getAuthorities();
StringBuffer as = new StringBuffer();
for (GrantedAuthority authority : authorities) {
as.append(authority.getAuthority())
.append(",");
}
claims.put("authorities",as) ;
return Jwts.builder()
.setClaims(claims)
.setSubject(userDetails.getUsername())
.setIssuedAt(createdDate)
.setExpiration(expirationDate)
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
}
private Date calculateExpirationDate(Date createdDate) {
return new Date(createdDate.getTime() + expiration);
}
public String refreshToken(String strToken) {
return "" ;
}
public Boolean validateToken(String strToken) {
return true ;
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.token;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class UnauthorizedEntryPoint implements AuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
ObjectMapper mapper = new ObjectMapper();
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
mapper.writeValue(response.getWriter(), "401未授权!");
}
}
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.userdetail;
import org.springframework.security.core.GrantedAuthority;
import java.util.Collection;
public class LoginUser extends org.springframework.security.core.userdetails.User {
private String userId ;
private String orgUserId ;
private String orgId ;
private String orgName ;
private String orgDeptId ;
private String orgDeptName ;
private boolean isSuperUser ;
public LoginUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
super(username, password, authorities);
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
package ${pub.getPKGCodeName()}.${app.getPKGCodeName()?lower_case}.security.userdetail;
import ${pub.getPKGCodeName()}.util.security.userdetail.LoginUser;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import java.util.ArrayList;
import java.util.List;
public class LoginUserDetailService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
List<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>() ;
SimpleGrantedAuthority userAuthority = new SimpleGrantedAuthority("USER");
authorities.add(userAuthority);
if(username.equals("admin")){
SimpleGrantedAuthority adminAuthority = new SimpleGrantedAuthority("ADMIN");
authorities.add(adminAuthority);
}
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder() ;
LoginUser user = new LoginUser(username,passwordEncoder.encode("123456"),authorities) ;
return user;
}
}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
<#assign httpPort = "8080">
<#assign nacosUrl = "172.16.102.211:8848" >
<#assign casUrl = "http://passportcs.ibizlab.cn" >
<#assign nodehost = "localhost">
<#assign devmode = "true" >
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepApp()??>
<#assign sysr = sysrun.getPSDevSlnMSDepApp()/>
<#if sysr.getPSDCMSPlatformNode()??>
<#if sysr.getPSDCMSPlatformNode().getSSHIPAddr()??>
<#assign nodehost = sysr.getPSDCMSPlatformNode().getSSHIPAddr()>
</#if>
<#if sysr.getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")??>
<#assign nacosUrl = sysr.getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")>
<#assign casUrl = sysr.getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("cas","http://passportcs.ibizlab.cn")>
</#if>
</#if>
<#-- 微服务部署APP -->
<#if sysr.getHttpPort()??>
<#assign httpPort = sysr.getHttpPort()?c>
</#if>
<#if sysr.getUserParam("devmode","true")??>
<#assign devmode = sysr.getUserParam("devmode","true")>
</#if>
</#if>
</#if>
<#assign isWFAPP = false>
<#if app.getAppMode()?? && app.getAppMode() == "WFAPP" && app.getAllPSAppWFs()??>
<#assign isWFAPP = true>
</#if>
server:
devmode: ${devmode}
port: ${httpPort}
servlet:
session:
cookie:
name: ${sys.getCodeName()?lower_case}${app.getPKGCodeName()?lower_case}
spring:
application:
name: ${sys.getCodeName()?lower_case}${app.getPKGCodeName()?lower_case}
cloud:
nacos:
discovery:
server-addr: ${nacosUrl}
security:
cas:
server:
host: ${casUrl}
login: ${r'${security.cas.server.host}'}/login
logout: ${r'${security.cas.server.host}'}/logout
service:
host: http://${nodehost}:${r'${server.port}'}
login: /login/cas
logout: /logout
feign:
sentinel:
enabled: true
# Logger Config
logging:
level:
${pub.getPKGCodeName()}: debug
app:
web:
url: http://${nodehost}:${r'${server.port}'}
wfstarturl: /#/%s/null/editview
# wfviewurl: /#/dewfdataredirectview
wfviewurl: /#/appwfdataredirectview
proxyviewurl: /#/appdataredirectview
<#if app.getPSSysServiceAPI()??>
service:
${app.getPSSysServiceAPI().getCodeName()?lower_case}:
service-id: ${app.getPSSysServiceAPI().getServiceCodeName()?lower_case}
</#if>
ibiz:
appid: ${app.getDeployId()}
appname: ${sys.getCodeName()?lower_case}${app.getPKGCodeName()?lower_case}
applogicname: ${sys.getLogicName()}${app.getName()}
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
spring:
profiles:
include: ${app.getPKGCodeName()?lower_case}, sys
<#ibiztemplate>
TARGET=PSSYSAPP
</#ibiztemplate>
Read Me
\ No newline at end of file
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-app</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Application</name>
<description>${pub.getCodeName()?lower_case?cap_first} Application</description>
<packaging>pom</packaging>
<#-- modules -->
<#if sys.getAllPSApps()??>
<modules>
<#list sys.getAllPSApps() as app>
<module>${pub.getCodeName()?lower_case}-app-${app.getPKGCodeName()?lower_case}</module>
</#list>
</modules>
</#if>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-cas</artifactId>
</dependency>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-util</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-boot</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Boot</name>
<description>${pub.getCodeName()?lower_case?cap_first} Boot</description>
<dependencies>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-core</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-mybatis</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<#if sys.getAllPSSysServiceAPIs()??>
<#list sys.getAllPSSysServiceAPIs() as sysapi>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-service-${sysapi.getCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-service-usr-${sysapi.getCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#list>
</#if>
<#if sys.getAllPSSubSysServiceAPIs()??>
<#list sys.getAllPSSubSysServiceAPIs() as subapi>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-client-${subapi.getCodeName()?lower_case}</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</#list>
</#if>
<dependency>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<artifactId>${pub.getCodeName()?lower_case}-usr</artifactId>
<version>${r'${project.version}'}</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${r'${basedir}'}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${pub.codeName?lower_case}</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>${pub.getPKGCodeName()}.${pub.codeName?cap_first}Application</mainClass>
<#-- <outputDirectory>../</outputDirectory> -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
package ${pub.getPKGCodeName()};
import java.util.List;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.fasterxml.jackson.databind.ObjectMapper;
import ${pub.getPKGCodeName()}.util.web.SearchContextHandlerMethodArgumentResolver;
import ${pub.getPKGCodeName()}.util.serialize.DomainSerializerProvider;
import ${pub.getPKGCodeName()}.util.helper.UniqueNameGenerator;
@SpringBootApplication(exclude = {
})
@Import({
// ${pub.getPKGCodeName()}
})
@EnableDiscoveryClient
@Configuration
@ComponentScan(nameGenerator = UniqueNameGenerator.class)
@EnableTransactionManagement
public class ${pub.codeName?cap_first}Application extends WebMvcConfigurerAdapter {
public static void main(String[] args) {
SpringApplicationBuilder builder=new SpringApplicationBuilder(${pub.codeName?cap_first}Application.class);
builder.run(args);
}
@Bean
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter(ObjectMapper objectMapper) {
objectMapper.setSerializerProvider(new DomainSerializerProvider()) ;
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
return converter;
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new SearchContextHandlerMethodArgumentResolver());
}
}
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign httpPort = "8080">
<#assign nacosUrl = "172.16.102.211:8848" >
<#if sysrun?? >
<#if sysrun.getPSDevSlnMSDepAPI()??>
<#-- 微服务部署API -->
<#if sysrun.getPSDevSlnMSDepAPI().getHttpPort()??>
<#assign httpPort = sysrun.getPSDevSlnMSDepAPI().getHttpPort()?c>
</#if>
<#if sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")??>
<#assign nacosUrl = sysrun.getPSDevSlnMSDepAPI().getPSDCMSPlatformNode().getPSDCMSPlatform().getUserParam("nacos","172.16.102.211:8848")>
</#if>
</#if>
</#if>
server:
port: ${httpPort}
spring:
application:
name: ${item.getCodeName()?lower_case}
cloud:
<#-- 后期需要修改为节点获取 -->
nacos:
discovery:
server-addr: ${nacosUrl}
<#if sysrun.getPSDBDevInst()??>
<#assign dbinst = sysrun.getPSDBDevInst()>
datasource:
password: '${dbinst.getPassword()}'
username: ${dbinst.getUserName()}
url: ${dbinst.getConnUrl()}
driver-class-name: <#if (dbinst.getDBType()=='MYSQL5')>com.mysql.jdbc.Driver<#elseif (dbinst.getDBType()=='DB2')>com.ibm.db2.jcc.DB2Driver<#elseif (dbinst.getDBType()=='ORACLE')>oracle.jdbc.driver.OracleDriver<#elseif (dbinst.getDBType()=='SQLSERVER')>com.microsoft.sqlserver.jdbc.SQLServerDriver<#elseif (dbinst.getDBType()=='POSTGRESQL')>org.postgresql.Driver<#elseif (dbinst.getDBType()=='PPAS')>com.edb.Driver</#if>
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
</#if>
feign:
sentinel:
enabled: true
# Logger Config
logging:
level:
${pub.getPKGCodeName()}: debug
<#if sys.getAllPSSubSysServiceAPIs()??>
client:
service:
<#list sys.getAllPSSubSysServiceAPIs() as subsysapi>
${subsysapi.getCodeName()?lower_case}:
service-id: ${subsysapi.getServiceCodeName()?lower_case}
</#list>
</#if>
<#if (sys.getAllPSWorkflows()?? && srflist(sys.getAllPSWorkflows())?size gt 0) || pub.getUserTag() != "IBIZUNIWF">
<#assign wfrootpath = "">
<#if sys.getAllPSSysServiceAPIs()??>
<#list sys.getAllPSSysServiceAPIs() as sysapi>
<#if sysapi.getUserTag() == "WFSERVICE">
<#assign wfrootpath = sysapi.getCodeName()?lower_case>
</#if>
</#list>
</#if>
ibiz:
wfrootpath: ${wfrootpath}
</#if>
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
spring:
profiles:
include: dev, core, mybatis, sys
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPI
</#ibiztemplate>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>${pub.getCodeName()?lower_case}-client</artifactId>
<groupId>${pub.getPKGCodeName()?lower_case}</groupId>
<version>${pub.getVersionString()?default("V0.0.1_alpha")}</version>
</parent>
<artifactId>${pub.getCodeName()?lower_case}-client-${item.codeName?lower_case}</artifactId>
<name>${pub.getCodeName()?lower_case?cap_first} Client External</name>
<description>${pub.getCodeName()?lower_case?cap_first} Client External</description>
<dependencies>
</dependencies>
</project>
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.client.${item.getCodeName()?lower_case}.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@ConditionalOnClass(${item.getCodeName()}ClientConfiguration.class)
@ConditionalOnWebApplication
@EnableConfigurationProperties(${item.codeName}ClientProperties.class)
@Import({
FeignClientsConfiguration.class
})
public class ${item.getCodeName()}AutoConfiguration {
}
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.client.${item.getCodeName()?lower_case}.config;
public class ${item.getCodeName()}ClientConfiguration {
}
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPI
</#ibiztemplate>
package ${pub.getPKGCodeName()}.client.${item.getCodeName()?lower_case}.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
@ConfigurationProperties(prefix = "client.service.${item.getCodeName()?lower_case?replace('_','.')}")
@Data
public class ${item.getCodeName()}ClientProperties {
private String tokenUrl ;
private String clientId ;
private String clientSecret ;
private String serviceUrl ;
private String serviceId ;
}
<#ibiztemplate>
TARGET=PSSUBSYSSERVICEAPIDE
</#ibiztemplate>
package ${pub.getPKGCodeName()}.client.${item.getPSSubSysServiceAPI().codeName?lower_case}.feign;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import ${pub.getPKGCodeName()}.core.client.model.I${item.codeName};
import ${pub.getPKGCodeName()}.client.${item.getPSSubSysServiceAPI().codeName?lower_case}.model.${item.codeName}Impl;
import ${pub.getPKGCodeName()}.util.SearchContext;
<#if item.getPSSubSysServiceAPI().getServicePath()??>
<#if item.getPSSubSysServiceAPI().getServicePath() != '' >
<#assign fullpath= item.getPSSubSysServiceAPI().getServicePath() + "/" + srfpluralize(item.getCodeName()?lower_case) >
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
<#else>
<#assign fullpath="/" + item.getPSSubSysServiceAPI().getCodeName()?lower_case + "/" + srfpluralize(item.getCodeName()?lower_case) >
</#if>
/**
* 实体[${item.codeName}] 服务对象接口
*/
public interface ${item.codeName}FeignClient {
<#if item.getPSSubSysServiceAPIDEMethods()??>
<#list item.getPSSubSysServiceAPIDEMethods() as apiMethod>
<#assign req_param_type=(apiMethod.getRequestParamType()!'')>
<#assign req_param=(apiMethod.getRequestField()!'')>
<#assign retval_type=(apiMethod.getRetvalType())!''>
<#assign return_type='void'>
<#if return_type?? && return_type!='' && retval_type !='VOID' && retval_type='ENTITY' ><#comment>由于无法获取到返回值类型,暂时通过请求参数类型确定返回值类型</#comment>
<#assign return_type=item.codeName>
</#if>
<#if apiMethod.getActionType()=='DEACTION'><#comment>实体行为</#comment>
<#-- public ${return_type} ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
<#if apiMethod.getCodeName() == 'Get'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case});
<#elseif apiMethod.getCodeName() == 'Remove'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
public Boolean ${apiMethod.getCodeName()?uncap_first}(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case});
<#elseif apiMethod.getCodeName() == 'Create'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@RequestBody ${item.codeName}Impl ${item.codeName?lower_case});
<#elseif apiMethod.getCodeName() == 'Update'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case},@RequestBody ${item.codeName}Impl ${item.codeName?lower_case});
<#elseif apiMethod.getCodeName() == 'CreateBatch'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@RequestBody List<${item.codeName}Impl> ${srfpluralize(item.getCodeName()?lower_case)});
<#elseif apiMethod.getCodeName() == 'UpdateBatch'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@RequestBody List<${item.codeName}Impl> ${srfpluralize(item.getCodeName()?lower_case)});
<#elseif apiMethod.getCodeName() == 'RemoveBatch'>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@RequestBody List<${item.codeName}Impl> ${srfpluralize(item.getCodeName()?lower_case)});
<#else>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/{${item.getKeyDEField().getCodeName()?lower_case}}/${apiMethod.getCodeName()?lower_case}")
public ${item.codeName}Impl ${apiMethod.getCodeName()?uncap_first}(@PathVariable("${item.getKeyDEField().getCodeName()?lower_case}") ${srfjavatype(item.getKeyDEField().stdDataType)} ${item.getKeyDEField().getCodeName()?lower_case},@RequestBody ${item.codeName}Impl ${item.codeName?lower_case});
</#if>
<#elseif apiMethod.getActionType()=='SELECT'><#comment>简单查询</#comment>
<#-- public List<${item.codeName}> ${srfmethodname(apiMethod.getCodeName())}(<#if req_param_type?? && req_param_type=='ENTITY'><#if apiMethod.getPSDEName()??>${apiMethod.getPSDEName()} entity</#if></#if>); -->
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
public Page<${item.codeName}Impl> ${apiMethod.getCodeName()?uncap_first}();
<#elseif apiMethod.getActionType()=='FETCH'><#comment>数据集合</#comment>
@RequestMapping(method = RequestMethod.<#if apiMethod.getRequestMethod()??>${apiMethod.getRequestMethod()}<#else>POST</#if>, value = "${fullpath}/${apiMethod.getCodeName()?lower_case}")
public Page<${item.codeName}Impl> ${apiMethod.getCodeName()?uncap_first}(SearchContext context);
<#elseif apiMethod.getActionType()=='USER'><#comment>用户自定义</#comment>
public void ${apiMethod.getCodeName()?uncap_first}();
</#if>
</#list>
</#if>
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册