release:增加获取作者信息接口和上传文件接口

release-2024-08-08
wangqing 4 months ago
parent 4601bcf00f
commit c11c536f54

@ -6,10 +6,12 @@ import api.PageResult;
import api.Result;
import com.luoo.music.pojo.Essay;
import com.luoo.music.service.EssayService;
import com.luoo.music.service.S3Service;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* Controller
@ -23,7 +25,8 @@ public class CMSEssayController {
@Autowired
private EssayService essayService;
@Autowired
private S3Service s3Service;
@ApiOperation(value = "1.获取专栏文章列表",notes = "获取专栏文章列表,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说")
@GetMapping("/search/{category}/{page}/{size}")
@ -80,7 +83,13 @@ public class CMSEssayController {
return Result.success(essay);
}
@ApiOperation(value = "上传文件", notes = "上传文件")
@PostMapping("/upload")
public Result batchUpload(@ApiParam(value = "文件", required = true) @RequestParam("file") MultipartFile file) {
return s3Service.upload(file, Boolean.FALSE);
}
}

@ -79,5 +79,13 @@ public class SimpleUserController {
}
return userInfo;
}
@ApiOperation(value = "获取专栏作者列表")
@GetMapping("/authors")
public Result<List<UserInfo>> getAuthors() {
List<UserInfo> authors = userInfoService.getAuthors();
authors = authors.stream().map(userInfo -> {userInfo.setAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());return userInfo;}).collect(Collectors.toList());
return Result.success(authors);
}
}

@ -46,4 +46,6 @@ public interface UserInfoDao extends JpaRepository<UserInfo, String>, JpaSpecifi
public Integer countByUserNameAndUserNameNotNullAndIdNot(String userName, String id);
public Integer countByUserNameAndUserNameNotNull(String userName);
public List<UserInfo> findAllByIsAuthor(int isAuthor);
}

@ -207,5 +207,10 @@ public class UserInfo implements Serializable {
*/
private Integer point;
/**
* 0- 1-
*/
private Integer isAuthor;
}

@ -775,4 +775,7 @@ public class UserInfoService {
}
}
public List<UserInfo> getAuthors() {
return userInfoDao.findAllByIsAuthor(1);
}
}

@ -0,0 +1,2 @@
alter table tb_user_info
add is_author int default 0 not null comment '是否是作者1表示是0表示不是';
Loading…
Cancel
Save