| | |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import lombok.SneakyThrows; |
| | | import org.springblade.core.oss.model.BladeFile; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springblade.modules.modules.entity.FunctionEntity; |
| | | import org.springblade.modules.modules.service.IFunctionService; |
| | | import org.springblade.modules.modules.vo.FunctionVO; |
| | | import org.springblade.modules.resource.builder.oss.OssBuilder; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class FunctionController extends BladeController { |
| | | |
| | | private final IFunctionService modulesFunctionService; |
| | | /** |
| | | * 对象存储构建类 |
| | | */ |
| | | private final OssBuilder ossBuilder; |
| | | |
| | | /** |
| | | * 功能表 详情 |
| | |
| | | @GetMapping("/all") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入modulesFunction") |
| | | public R getAll(FunctionEntity function) { |
| | | List<FunctionEntity> functionEntities = modulesFunctionService.getAll(function); |
| | | public R getAll(FunctionVO function) { |
| | | List<FunctionVO> functionEntities = modulesFunctionService.getAll(function); |
| | | return R.data(functionEntities); |
| | | } |
| | | |
| | |
| | | return R.status(modulesFunctionService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 上传文件并保存至附件表 |
| | | * |
| | | * @param file 文件 |
| | | * @return ObjectStat |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach") |
| | | public R putFileAttach(@RequestParam MultipartFile file,FunctionEntity functionEntity) { |
| | | String fileName = file.getOriginalFilename(); |
| | | FunctionEntity one = modulesFunctionService.getOne(Condition.getQueryWrapper(functionEntity)); |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | HashMap<String,String> map = new HashMap<>(); |
| | | map.put("label",bladeFile.getName()); |
| | | map.put("value",bladeFile.getLink()); |
| | | List list = new ArrayList(); |
| | | if (ObjectUtil.isNotEmpty(one.getFileUrl())){ |
| | | one.getFileUrl().add(map); |
| | | }else { |
| | | list.add(map); |
| | | one.setFileUrl(list); |
| | | } |
| | | return R.data(bladeFile); |
| | | } |
| | | |
| | | |
| | | } |