Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -60,18 +60,18 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@PostMapping("/upload-file")
|
||||
@Operation(summary = "上传模板实例文件")
|
||||
public CommonResult<Map<String, String> >upload(MultipartFile file) {
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
try {
|
||||
String fileWhitReturn = fileApi.createFile(file.getBytes(), file.getOriginalFilename());
|
||||
fileMap.put("fileUrl", fileWhitReturn);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return success(fileMap);
|
||||
}
|
||||
// @PostMapping("/upload-file")
|
||||
// @Operation(summary = "上传模板实例文件")
|
||||
// public CommonResult<Map<String, String> >upload(MultipartFile file) {
|
||||
// Map<String, String> fileMap = new HashMap<>();
|
||||
// try {
|
||||
// String fileWhitReturn = fileApi.createFile(file.getBytes(), file.getOriginalFilename());
|
||||
// fileMap.put("fileUrl", fileWhitReturn);
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// return success(fileMap);
|
||||
// }
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模板实例")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:create')")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.business.annotation.FileUploadController;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@@ -11,14 +12,17 @@ import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmRespVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmSaveReqVO;
|
||||
import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmDO;
|
||||
import cn.iocoder.yudao.module.base.service.tmpltp.TmplItmService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "管理后台 - 模板条款")
|
||||
@RestController
|
||||
@@ -28,32 +32,56 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class TmplItmController {
|
||||
private final TmplItmService tmplItmService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模板条款")
|
||||
public CommonResult<TmplItmRespVO> createTmplItm(@Valid @RequestBody TmplItmSaveReqVO createReqVO) {
|
||||
TmplItmRespVO tmplItm = tmplItmService.createTmplItm(createReqVO);
|
||||
return success(tmplItm);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新模板条款")
|
||||
public CommonResult<Boolean> updateTmplItm(@Valid @RequestBody TmplItmSaveReqVO updateReqVO) {
|
||||
tmplItmService.updateTmplItm(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模板条款", description = "")
|
||||
public CommonResult<Boolean> deleteTmplItm(@RequestBody BatchDeleteReqVO req) {
|
||||
return success(tmplItmService.deleteTmplItm(req.getIds()));
|
||||
}
|
||||
|
||||
@GetMapping("/id")
|
||||
@Operation(summary = "根据id获得模板条款")
|
||||
public CommonResult<TmplItmRespVO> getTmplItm(@RequestBody String id) {
|
||||
return success(BeanUtils.toBean(tmplItmService.getById(id), TmplItmRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public CommonResult<List<TmplItmRespVO>> listTmplItm(){
|
||||
return success(BeanUtils.toBean(tmplItmService.list(), TmplItmRespVO.class));
|
||||
public CommonResult<List<TmplItmRespVO>> listTmplItm(Map<String, Object> params) {
|
||||
// 创建查询条件构造器
|
||||
QueryWrapper<TmplItmDO> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
// 遍历Map参数,动态添加查询条件
|
||||
if (params != null && !params.isEmpty()) {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 过滤掉空值和空字符串
|
||||
if (value != null &&
|
||||
!(value instanceof String && StringUtils.isBlank((String) value))) {
|
||||
queryWrapper.eq(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 执行带条件的查询
|
||||
List<TmplItmDO> list = tmplItmService.list(queryWrapper);
|
||||
return success(BeanUtils.toBean(list, TmplItmRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "分页获得模板条款")
|
||||
public CommonResult<PageResult<TmplItmRespVO>> pageTmplItm(@Validated TmpItmPageReqVO pageReqVO) {
|
||||
|
||||
@@ -129,8 +129,14 @@ public class TmplTpController extends AbstractFileUploadController implements Bu
|
||||
@PutMapping("/updateStatus")
|
||||
@Operation(summary = "更新模板字段状态")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')")
|
||||
public CommonResult<Boolean> updateStatus(@RequestBody TmplTpSaveReqVO updateReqVO) {
|
||||
tmplTpService.updateStatus(updateReqVO.getId(), updateReqVO.getSts());
|
||||
public CommonResult<Boolean> updateStatus(@RequestBody Map<String,Object> params) {
|
||||
if (params == null){
|
||||
throw new RuntimeException("参数不能为空");
|
||||
}
|
||||
if (!params.containsKey("id") || !params.containsKey("status")){
|
||||
throw new RuntimeException("参数id或者状态不能为空");
|
||||
}
|
||||
tmplTpService.updateStatus(Long.valueOf(params.get("id").toString()), params.get("status").toString());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TemplateInstanceSaveReqVO {
|
||||
private String content;
|
||||
|
||||
@Schema(description = "原始文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "原始文件内容不能为空")
|
||||
// @NotEmpty(message = "原始文件内容不能为空")
|
||||
private String originalContent;
|
||||
|
||||
@Schema(description = "文件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
|
||||
@@ -53,4 +53,7 @@ public interface TmplTpMapper extends BaseMapperX<TmplTpDO> {
|
||||
" and bti.deleted = 0\n" +
|
||||
"and btt.id = #{id}")
|
||||
List<Map<String, Object>>getClause(@Param("id") Long id);
|
||||
|
||||
@Select("select * from bse_tmpl_tp where id= #{id}")
|
||||
TmplTpDO getTmplTpById(@Param("id") Long id);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,12 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
public void updateTemplateInstance(TemplateInstanceSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateTemplateInstanceExists(updateReqVO.getId());
|
||||
// TemplateInstanceDO templateInstanceDO = templateInstanceMapper.selectById(updateReqVO.getId());
|
||||
// //获取保存旧文件内容防止被更新
|
||||
// String originalContent = templateInstanceDO.getOriginalContent();
|
||||
// 更新
|
||||
TemplateInstanceDO updateObj = BeanUtils.toBean(updateReqVO, TemplateInstanceDO.class);
|
||||
updateObj.setOriginalContent(null); //重新赋值,防止原始文件被更改
|
||||
templateInstanceMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> imple
|
||||
}
|
||||
|
||||
private boolean validateStatusUpdate(Long id, String status) {
|
||||
TmplTpDO tmplTpDO = this.getById(id);
|
||||
TmplTpDO tmplTpDO = baseMapper.getTmplTpById(id);
|
||||
String currentSts = tmplTpDO.getSts();
|
||||
|
||||
// 获取当前状态对应的枚举实例
|
||||
|
||||
Reference in New Issue
Block a user