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; /** *

* 前端控制器 *

* * @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 byType = jyUserFileService.getByType(jyUserFile.getImgType()); if(byType != null && !byType.isEmpty()){ jyUserFile.setId(byType.get(0).getId()); } } return ResultData.ok(jyUserFileService.saveOrUpdate(jyUserFile)); } }