修改 小程序码上传、 新增小程序码文件删除接口
This commit is contained in:
parent
028905b8ad
commit
66437771ae
@ -195,7 +195,7 @@ public class FileController {
|
||||
if (qrCodeDO == null) {
|
||||
|
||||
// 生成小程序码
|
||||
File QRCode = socialClientApi.getQRCode("subPages/task/myTask", "deptId=" + deptId).getCheckedData();
|
||||
File QRCode = socialClientApi.getQRCode("subPages/register/register", "deptId=" + deptId).getCheckedData();
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.set("userId", userId);
|
||||
@ -255,6 +255,16 @@ public class FileController {
|
||||
}
|
||||
}
|
||||
|
||||
return success(new QRCodeReqVO());
|
||||
return success(null);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-QRCode")
|
||||
@Operation(summary = "删除小程序码文件")
|
||||
@Parameter(name = "url", description = "文件链接", required = true, example = "1024")
|
||||
public CommonResult<Boolean> deleteQRCode(@RequestParam("url") String url) {
|
||||
|
||||
fileService.deleteQRCode(url);
|
||||
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
@ -43,13 +41,12 @@ public class QRCodeDO extends BaseDO {
|
||||
private Long configId;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
* 文件链接
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 参数值
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private String scene;
|
||||
}
|
||||
|
@ -167,4 +167,10 @@ public interface FileService {
|
||||
* @param id 编号
|
||||
*/
|
||||
void updateQRCodeFile(Long id);
|
||||
|
||||
/**
|
||||
* 删除小程序码文件
|
||||
* @param url 文件链接
|
||||
*/
|
||||
void deleteQRCode(String url);
|
||||
}
|
||||
|
@ -515,4 +515,33 @@ public class FileServiceImpl implements FileService {
|
||||
updateDO.setUpdateTime(LocalDateTime.now());
|
||||
qrCodeDOMapper.updateById(updateDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteQRCode(String url) {
|
||||
|
||||
String path = url.substring(url.lastIndexOf("/") + 1);
|
||||
QRCodeDO qrCodeDO = qrCodeDOMapper.selectOne(QRCodeDO::getUrl, url);
|
||||
|
||||
if (qrCodeDO == null) {
|
||||
throw exception(FILE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 从文件存储器中删除
|
||||
deleteFileClient(qrCodeDO.getConfigId(), path);
|
||||
|
||||
// 删除记录
|
||||
qrCodeDOMapper.deleteById(qrCodeDO.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件存储器删除 文件
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void deleteFileClient(Long configId, String path) {
|
||||
|
||||
// 从文件存储器中删除
|
||||
FileClient client = fileConfigService.getFileClient(configId);
|
||||
Assert.notNull(client, "客户端({}) 不能为空", configId);
|
||||
client.delete(path);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user