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

ibizdev提交

上级 1ec8ec0c
*2020-4-29*
初始化文件
<template>
<codelist v-if="tag" :tag="tag" :value="value" :codelistType="codelistType" :renderMode="renderMode" :valueSeparator="valueSeparator" :textSeparator="textSeparator"></codelist>
<app-upload-file-info v-else-if="Object.is(this.editorType,'PICTURE') || Object.is(this.editorType,'PICTURE_ONE') || Object.is(this.editorType,'FILEUPLOADER')" :value="value" :name="name"></app-upload-file-info>
<span class="app-span" v-else >{{text}}</span>
</template>
......@@ -18,6 +19,14 @@ export default class DropDownList extends Vue {
*/
@Prop() public value?: any;
/**
* 当前表单项名称
*
* @type {*}
* @memberof AppSpan
*/
@Prop() public name?: any;
/**
* 代码表标识
*
......@@ -99,15 +108,6 @@ export default class DropDownList extends Vue {
public load(){
if(!this.value || this.tag){
return; //代码表走codelist组件
} else if(Object.is(this.editorType,'PICTURE') || Object.is(this.editorType,'PICTURE_ONE') || Object.is(this.editorType,'FILEUPLOADER')){
let files: any[] = JSON.parse(this.value);
let names: any[] = [];
if(files.length && files.length > 0){
files.forEach((item:any) => {
names.push(item.name);
});
this.text = names.join(',');
}
}else{
this.text = this.value;
}
......
......@@ -15,5 +15,6 @@ export default {
permissionid: '系统资源标识',
createdate: '建立时间',
updatedate: '更新时间',
permissiontype: '资源类型',
},
};
\ No newline at end of file
......@@ -14,5 +14,6 @@ export default {
permissionid: '系统资源标识',
createdate: '建立时间',
updatedate: '更新时间',
permissiontype: '资源类型',
},
};
\ No newline at end of file
......@@ -21,7 +21,8 @@
</i-col>
<i-col v-show="detailsModel.sys_permissionid.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='sys_permissionid' :itemRules="this.rules.sys_permissionid" class='' :caption="$t('entities.sys_permission.main_form.details.sys_permissionid')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.sys_permissionid.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span :value="data.sys_permissionid" style=""></app-span>
<app-span name='sys_permissionid'
:value="data.sys_permissionid" style=""></app-span>
</app-form-item>
</i-col>
......
......@@ -34,7 +34,8 @@
</i-col>
<i-col v-show="detailsModel.type.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='type' :itemRules="this.rules.type" class='' :caption="$t('entities.sys_role_permission.main_form.details.type')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.type.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span :value="data.type" tag='CLPermissionType' codelistType='STATIC' style=""></app-span>
<app-span name='type'
:value="data.type" tag='CLPermissionType' codelistType='STATIC' style=""></app-span>
</app-form-item>
</i-col>
......@@ -65,7 +66,8 @@
</i-col>
<i-col v-show="detailsModel.sys_role_permissionid.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='sys_role_permissionid' :itemRules="this.rules.sys_role_permissionid" class='' :caption="$t('entities.sys_role_permission.main_form.details.sys_role_permissionid')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.sys_role_permissionid.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span :value="data.sys_role_permissionid" style=""></app-span>
<app-span name='sys_role_permissionid'
:value="data.sys_role_permissionid" style=""></app-span>
</app-form-item>
</i-col>
......
......@@ -21,7 +21,8 @@
</i-col>
<i-col v-show="detailsModel.sys_roleid.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='sys_roleid' :itemRules="this.rules.sys_roleid" class='' :caption="$t('entities.sys_role.main_form.details.sys_roleid')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.sys_roleid.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span :value="data.sys_roleid" style=""></app-span>
<app-span name='sys_roleid'
:value="data.sys_roleid" style=""></app-span>
</app-form-item>
</i-col>
......
......@@ -21,7 +21,8 @@
</i-col>
<i-col v-show="detailsModel.sys_user_roleid.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='sys_user_roleid' :itemRules="this.rules.sys_user_roleid" class='' :caption="$t('entities.sys_user_role.main_form.details.sys_user_roleid')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.sys_user_roleid.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span :value="data.sys_user_roleid" style=""></app-span>
<app-span name='sys_user_roleid'
:value="data.sys_user_roleid" style=""></app-span>
</app-form-item>
</i-col>
......
......@@ -135,6 +135,13 @@ public class SYS_PSDEOPPRIV extends EntityMP implements Serializable {
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
private Timestamp updatedate;
/**
* 资源类型
*/
@TableField(value = "permissiontype")
@JSONField(name = "permissiontype")
@JsonProperty("permissiontype")
private String permissiontype;
......@@ -215,6 +222,13 @@ public class SYS_PSDEOPPRIV extends EntityMP implements Serializable {
this.permissionid = permissionid ;
this.modify("permissionid",permissionid);
}
/**
* 设置 [资源类型]
*/
public void setPermissiontype(String permissiontype){
this.permissiontype = permissiontype ;
this.modify("permissiontype",permissiontype);
}
}
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[权限/资源] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_PERMISSIONServiceImpl")
public class SYS_PERMISSIONServiceImpl extends ServiceImpl<SYS_PERMISSIONMapper, SYS_PERMISSION> implements ISYS_PERMISSIONService {
@Autowired
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[系统菜单项] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_PSAPPMENUITEMServiceImpl")
public class SYS_PSAPPMENUITEMServiceImpl extends ServiceImpl<SYS_PSAPPMENUITEMMapper, SYS_PSAPPMENUITEM> implements ISYS_PSAPPMENUITEMService {
private int batchSize = 500;
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[实体数据操作标识] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_PSDEOPPRIVServiceImpl")
public class SYS_PSDEOPPRIVServiceImpl extends ServiceImpl<SYS_PSDEOPPRIVMapper, SYS_PSDEOPPRIV> implements ISYS_PSDEOPPRIVService {
private int batchSize = 500;
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[实体] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_PSSYSTEMServiceImpl")
public class SYS_PSSYSTEMServiceImpl extends ServiceImpl<SYS_PSSYSTEMMapper, SYS_PSSYSTEM> implements ISYS_PSSYSTEMService {
private int batchSize = 500;
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[系统角色] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_ROLEServiceImpl")
public class SYS_ROLEServiceImpl extends ServiceImpl<SYS_ROLEMapper, SYS_ROLE> implements ISYS_ROLEService {
@Autowired
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[角色权限关系] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_ROLE_PERMISSIONServiceImpl")
public class SYS_ROLE_PERMISSIONServiceImpl extends ServiceImpl<SYS_ROLE_PERMISSIONMapper, SYS_ROLE_PERMISSION> implements ISYS_ROLE_PERMISSIONService {
private int batchSize = 500;
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[系统用户] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_USERServiceImpl")
public class SYS_USERServiceImpl extends ServiceImpl<SYS_USERMapper, SYS_USER> implements ISYS_USERService {
@Autowired
......
......@@ -39,7 +39,7 @@ import com.alibaba.fastjson.JSONObject;
* 实体[用户角色关系] 服务对象接口实现
*/
@Slf4j
@Service
@Service("SYS_USER_ROLEServiceImpl")
public class SYS_USER_ROLEServiceImpl extends ServiceImpl<SYS_USER_ROLEMapper, SYS_USER_ROLE> implements ISYS_USER_ROLEService {
private int batchSize = 500;
......
[
{
"predefineddatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"entities":[
{
"dename":"SYS_ROLE_PERMISSION",
"delogicname":"角色权限关系",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -15,8 +16,7 @@
"delogicname":"权限/资源",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -24,8 +24,7 @@
"delogicname":"用户角色关系",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -33,8 +32,7 @@
"delogicname":"系统用户",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -42,8 +40,7 @@
"delogicname":"系统角色",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -51,8 +48,7 @@
"delogicname":"系统菜单项",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
,
{
......@@ -60,8 +56,9 @@
"delogicname":"实体数据操作标识",
"sysmoudle":{"id":"UAA","name":"uaa"},
"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"}]
"deaction":[{"id":"CREATE","name":"新建","type":"BUILTIN"},{"id":"UPDATE","name":"编辑","type":"BUILTIN"},{"id":"READ","name":"读取","type":"BUILTIN"},{"id":"DELETE","name":"删除","type":"BUILTIN"},{"id":"CUSTOM","name":"自定义行为","type":"USERCUSTOM"}]
}
]
}
......@@ -2,7 +2,7 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<!--输出实体[SYS_PSDEOPPRIV]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-sys_psdeoppriv-42-1">
<changeSet author="a_A_5d9d78509" id="tab-sys_psdeoppriv-51-1">
<createTable tableName="IBZPSDEOPPRIV">
<column name="SYS_PSDEOPPRIVID" remarks="" type="VARCHAR(200)">
<constraints primaryKey="true" primaryKeyName="PK_SYS_PSDEOPPRIV_SYS_PSDEOPPR"/>
......@@ -33,6 +33,8 @@
</column>
<column name="UPDATEDATE" remarks="" type="DATETIME">
</column>
<column name="PERMISSIONTYPE" remarks="" type="VARCHAR(100)">
</column>
</createTable>
</changeSet>
<!--输出实体[SYS_USER]数据结构 -->
......
......@@ -25,7 +25,7 @@
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`PERMISSIONID`, t1.`PSDATAENTITYID`, t1.`PSDATAENTITYNAME`, t1.`PSDEDATARANGEID`, t1.`PSDEDATARANGENAME`, t1.`PSDEDATASETID`, t1.`PSDEDATASETNAME`, t1.`PSSYSMODULEID`, t1.`PSSYSMODULENAME`, t1.`PSSYSTEMID`, t1.`SYS_PSDEOPPRIVID`, t1.`SYS_PSDEOPPRIVNAME`, t1.`UPDATEDATE` FROM `IBZPSDEOPPRIV` t1
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`PERMISSIONID`, t1.`PERMISSIONTYPE`, t1.`PSDATAENTITYID`, t1.`PSDATAENTITYNAME`, t1.`PSDEDATARANGEID`, t1.`PSDEDATARANGENAME`, t1.`PSDEDATASETID`, t1.`PSDEDATASETNAME`, t1.`PSSYSMODULEID`, t1.`PSSYSMODULENAME`, t1.`PSSYSTEMID`, t1.`SYS_PSDEOPPRIVID`, t1.`SYS_PSDEOPPRIVNAME`, t1.`UPDATEDATE` FROM `IBZPSDEOPPRIV` t1
]]>
</sql>
......
......@@ -137,6 +137,14 @@ public class SYS_PSDEOPPRIVDTO extends DTOBase implements Serializable {
@JsonProperty("updatedate")
private Timestamp updatedate;
/**
* 属性 [PERMISSIONTYPE]
*
*/
@JSONField(name = "permissiontype")
@JsonProperty("permissiontype")
private String permissiontype;
/**
* 设置 [SYS_PSDEOPPRIVNAME]
......@@ -226,6 +234,14 @@ public class SYS_PSDEOPPRIVDTO extends DTOBase implements Serializable {
this.modify("permissionid",permissionid);
}
/**
* 设置 [PERMISSIONTYPE]
*/
public void setPermissiontype(String permissiontype){
this.permissiontype = permissiontype ;
this.modify("permissiontype",permissiontype);
}
}
package cn.ibizlab.util.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 FileItem
{
private String id;
private String name;
private long size;
private String ext;
}
package cn.ibizlab.util.rest;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@Slf4j
public class FileController
{
@Autowired
private FileService fileService;
@PostMapping(value = "${ibiz.uploadpath.path: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 = "${ibiz.file.downloadpath:"+defaultdownloadpath+"}")
@ResponseStatus(HttpStatus.OK)
public void download(@PathVariable String id, HttpServletResponse response){
File file= fileService.getFile(id);
response.setHeader("Content-Disposition", "attachment;filename="+getFileName(file.getName()));
this.sendRespose(response, file);
}
protected void sendRespose(HttpServletResponse response, File file){
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) {
}
}
}
}
protected String getFileName(String fileName){
try {
return new String(fileName.getBytes("utf-8"),"iso8859-1");//防止中文乱码
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return fileName;
}
}
\ No newline at end of file
package cn.ibizlab.util.service;
import cn.ibizlab.util.domain.FileItem;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
public interface FileService
{
FileItem saveFile(MultipartFile multipartFile);
File getFile(String fileid);
}
\ No newline at end of file
package cn.ibizlab.util.service;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.errors.InternalServerErrorException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;
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
@Service
public class SimpleFileService implements FileService {
@Value("${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);
} catch (IOException e) {
throw new InternalServerErrorException("文件上传失败");
}
return item;
}
@Override
public File getFile(String fileid) {
String dirpath = this.fileRoot+"ibztuit"+File.separator+fileid;
File parent = new File(dirpath);
if (parent.exists() && parent.isDirectory() && parent.listFiles().length > 0) {
return parent.listFiles()[0];
}
throw new InternalServerErrorException("文件未找到");
}
/**
* 获取文件扩展名
* @param filename
* @return
*/
public static 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
......@@ -104,7 +104,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"));
}
}
......
......@@ -60,3 +60,7 @@ logging:
ribbon:
ReadTimeout: 60000
ConnectTimeout: 60000
#系统是否开启权限验证
ibiz:
enablePermissionValid: false
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册