
8 changed files with 78 additions and 10 deletions
@ -1,9 +1,20 @@ |
|||
package com.yxt.demo.system.api.sys_resources; |
|||
|
|||
import com.yxt.demo.system.utils.ResultBean; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/4/24 14:26 |
|||
* @Description |
|||
*/ |
|||
@Api(value = "") |
|||
public interface SysResourcesFeign { |
|||
|
|||
@ApiOperation(value = "上传") |
|||
@RequestMapping("/upload") |
|||
ResultBean upload(MultipartFile file); |
|||
} |
|||
|
@ -1,9 +1,14 @@ |
|||
package com.yxt.demo.system.biz.sys_resources; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.demo.system.api.sys_resources.SysResources; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/4/24 14:26 |
|||
* @Description |
|||
*/ |
|||
public interface SysResourcesMapper { |
|||
@Mapper |
|||
public interface SysResourcesMapper extends BaseMapper<SysResources> { |
|||
} |
|||
|
@ -1,9 +1,28 @@ |
|||
package com.yxt.demo.system.biz.sys_resources; |
|||
|
|||
import com.yxt.demo.system.api.sys_resources.SysResourcesFeign; |
|||
import com.yxt.demo.system.utils.ResultBean; |
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/4/24 14:26 |
|||
* @Description |
|||
*/ |
|||
public class SysResourcesRest { |
|||
@RestController |
|||
@Api(tags = "自主资源表") |
|||
@RequestMapping("v1/sysResources") |
|||
public class SysResourcesRest implements SysResourcesFeign { |
|||
|
|||
@Autowired |
|||
private SysResourcesService sysResourcesService; |
|||
|
|||
@Override |
|||
public ResultBean upload(MultipartFile file) { |
|||
return sysResourcesService.upload(file); |
|||
} |
|||
} |
|||
|
@ -1,9 +1,39 @@ |
|||
package com.yxt.demo.system.biz.sys_resources; |
|||
|
|||
import com.yxt.demo.system.api.sys_resources.SysResources; |
|||
import com.yxt.demo.system.jdbc.service.MybatisBaseService; |
|||
import com.yxt.demo.system.utils.ResultBean; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.File; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* @Author dimengzhe |
|||
* @Date 2023/4/24 14:26 |
|||
* @Description |
|||
*/ |
|||
public class SysResourcesService { |
|||
@Service |
|||
public class SysResourcesService extends MybatisBaseService<SysResourcesMapper, SysResources> { |
|||
|
|||
@Value("${reggie.path}") |
|||
private String basePath; |
|||
|
|||
public ResultBean upload(MultipartFile file) { |
|||
String filename = file.getOriginalFilename(); |
|||
String substring = filename.substring(filename.lastIndexOf(".")); |
|||
String fileName = UUID.randomUUID().toString() + substring; |
|||
File file1 = new File(basePath); |
|||
if (!file1.exists()){ |
|||
file1.mkdirs(); |
|||
} |
|||
try { |
|||
file.transferTo(new File(basePath+fileName)); |
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue