12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.fdkankan.manage.controller;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.common.ResultData;
- import com.fdkankan.manage.entity.JyUserFile;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.service.IJyUserFileService;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author
- * @since 2025-04-10
- */
- @RestController
- @RequestMapping("/service/manage/userFile")
- public class JyUserFileController {
- @Autowired
- IJyUserFileService jyUserFileService;
- @GetMapping("/info")
- public ResultData info(@RequestParam(required = false,defaultValue = "0")Integer imgType){
- return ResultData.ok(jyUserFileService.getByType(imgType));
- }
- @PostMapping("/addOrUpdate")
- public ResultData addOrUpdate(@RequestBody JyUserFile jyUserFile){
- if(StringUtils.isBlank(jyUserFile.getFileUrl()) || jyUserFile.getImgType() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- if(jyUserFile.getId() == null){
- List<JyUserFile> byType = jyUserFileService.getByType(jyUserFile.getImgType());
- if(byType != null && !byType.isEmpty()){
- jyUserFile.setId(byType.get(0).getId());
- }
- }
- return ResultData.ok(jyUserFileService.saveOrUpdate(jyUserFile));
- }
- }
|