Skip to content

Commit

Permalink
service: Apply ktlint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Verma <[email protected]>
  • Loading branch information
shank03 committed Sep 18, 2023
1 parent caf8e2a commit 2490f27
Show file tree
Hide file tree
Showing 33 changed files with 283 additions and 164 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mnnit/moticlubs/OpenAPIDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.swagger.v3.oas.annotations.servers.Server
@SecurityScheme(
type = SecuritySchemeType.HTTP,
name = "Firebase Auth",
scheme = "Bearer"
scheme = "Bearer",
)
@OpenAPIDefinition(
info = Info(
Expand All @@ -20,7 +20,7 @@ import io.swagger.v3.oas.annotations.servers.Server
contact = Contact(
name = "CC-Club MNNIT",
url = "https://github.com/CC-MNNIT",
email = "[email protected]"
email = "[email protected]",
),
),
servers = [
Expand All @@ -33,6 +33,6 @@ import io.swagger.v3.oas.annotations.servers.Server
description = "Production",
),
],
security = [SecurityRequirement(name = "Firebase Auth")]
security = [SecurityRequirement(name = "Firebase Auth")],
)
class OpenAPIDefinition
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,29 @@ import com.mnnit.moticlubs.dto.request.MembersDTO
import com.mnnit.moticlubs.dto.request.UpdateChannelDTO
import com.mnnit.moticlubs.service.ChannelService
import com.mnnit.moticlubs.service.MemberService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.CHANNEL_ID_CLAIM
import com.mnnit.moticlubs.utils.Constants.CHANNEL_ROUTE
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand All @@ -41,7 +55,7 @@ class ChannelController(
serviceCall = { uid ->
LOGGER.info("getAllChannels")
channelService.getAllChannels(uid)
}
},
)

@GetMapping("/{$CHANNEL_ID_CLAIM}")
Expand All @@ -56,7 +70,7 @@ class ChannelController(
serviceCall = { uid ->
LOGGER.info("getChannelFromChid: chid: $channelId")
channelService.getChannelByChID(uid, channelId)
}
},
)

@GetMapping("/members/{${CHANNEL_ID_CLAIM}}")
Expand All @@ -71,7 +85,7 @@ class ChannelController(
serviceCall = {
LOGGER.info("getMembers: chid: $channelId")
memberService.getMembersByChid(channelId)
}
},
)

@PostMapping("/members")
Expand Down Expand Up @@ -115,7 +129,7 @@ class ChannelController(
@Operation(summary = "Updates the name of channel")
fun updateChannel(
@RequestBody dto: UpdateChannelDTO,
@PathVariable channelId: Long
@PathVariable channelId: Long,
): Mono<ResponseEntity<Channel>> = pathAuthorization
.clubAuthorization(dto.cid)
.flatMap {
Expand All @@ -129,7 +143,7 @@ class ChannelController(
@Operation(summary = "Deletes the channel and the posts in it")
fun deleteChannel(
@RequestParam clubId: Long,
@PathVariable channelId: Long
@PathVariable channelId: Long,
): Mono<ResponseEntity<Void>> = pathAuthorization
.clubAuthorization(clubId)
.flatMap {
Expand Down
19 changes: 15 additions & 4 deletions src/main/kotlin/com/mnnit/moticlubs/controller/ClubController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ package com.mnnit.moticlubs.controller
import com.mnnit.moticlubs.dao.Club
import com.mnnit.moticlubs.dto.request.UpdateClubDTO
import com.mnnit.moticlubs.service.ClubService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.CLUBS_ROUTE
import com.mnnit.moticlubs.utils.Constants.CLUB_ID_CLAIM
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand All @@ -37,14 +48,14 @@ class ClubController(
serviceCall = {
LOGGER.info("getClubs")
clubService.getAllClubs()
}
},
)

@PutMapping("/{$CLUB_ID_CLAIM}")
@Operation(summary = "Updates club avatar, description and summary")
fun updateClub(
@RequestBody dto: UpdateClubDTO,
@PathVariable clubId: Long
@PathVariable clubId: Long,
): Mono<ResponseEntity<Club>> = pathAuthorization
.clubAuthorization(clubId)
.flatMap {
Expand Down
26 changes: 20 additions & 6 deletions src/main/kotlin/com/mnnit/moticlubs/controller/PostController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,30 @@ package com.mnnit.moticlubs.controller
import com.mnnit.moticlubs.dao.Post
import com.mnnit.moticlubs.dto.request.UpdatePostDTO
import com.mnnit.moticlubs.service.PostService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.POSTS_ROUTE
import com.mnnit.moticlubs.utils.Constants.POST_ID_CLAIM
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.data.domain.PageRequest
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand Down Expand Up @@ -41,14 +55,14 @@ class PostController(
serviceCall = {
LOGGER.info("getPostsByChannel: chid: $channelId; page: $page; items: $items")
postService.getPostsByChannel(channelId, PageRequest.of(maxOf(page - 1, 0), items))
}
},
)

@PostMapping
@Operation(summary = "Saves post and notify users")
fun savePost(
@RequestBody post: Post,
@RequestParam clubId: Long
@RequestParam clubId: Long,
): Mono<ResponseEntity<Post>> = pathAuthorization
.clubAuthorization(clubId)
.flatMap {
Expand All @@ -63,7 +77,7 @@ class PostController(
fun updatePost(
@RequestBody dto: UpdatePostDTO,
@PathVariable postId: Long,
@RequestParam clubId: Long
@RequestParam clubId: Long,
): Mono<ResponseEntity<Post>> = pathAuthorization
.clubAuthorization(clubId)
.flatMap {
Expand All @@ -77,7 +91,7 @@ class PostController(
@Operation(summary = "Deletes post")
fun deletePost(
@PathVariable postId: Long,
@RequestParam clubId: Long
@RequestParam clubId: Long,
): Mono<ResponseEntity<Void>> = pathAuthorization
.clubAuthorization(clubId)
.flatMap {
Expand Down
18 changes: 15 additions & 3 deletions src/main/kotlin/com/mnnit/moticlubs/controller/ReplyController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,27 @@ package com.mnnit.moticlubs.controller

import com.mnnit.moticlubs.dao.Reply
import com.mnnit.moticlubs.service.ReplyService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.REPLY_ROUTE
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.data.domain.PageRequest
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand Down Expand Up @@ -39,7 +51,7 @@ class ReplyController(
serviceCall = {
LOGGER.info("getReplies: pid: $postId; page: $page; items: $items")
replyService.getRepliesByPid(postId, PageRequest.of(maxOf(page - 1, 0), items))
}
},
)

@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand Down Expand Up @@ -54,7 +60,7 @@ class SuperAdminController(
name = dto.name,
description = dto.description,
summary = dto.summary,
)
),
)
}
.invalidateStamp { ResponseStamp.CLUB }
Expand Down
19 changes: 15 additions & 4 deletions src/main/kotlin/com/mnnit/moticlubs/controller/UrlController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ package com.mnnit.moticlubs.controller
import com.mnnit.moticlubs.dao.Url
import com.mnnit.moticlubs.dto.request.SaveUrlsDTO
import com.mnnit.moticlubs.service.UrlService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.URL_ROUTE
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand All @@ -37,7 +48,7 @@ class UrlController(
serviceCall = {
LOGGER.info("getUrls: cid: $clubId")
urlService.getUrlsByCid(clubId)
}
},
)

@PostMapping
Expand All @@ -49,7 +60,7 @@ class UrlController(
LOGGER.info("updateUrls: cid: $clubId")
urlService.saveUrl(
clubId,
dto.urls.map { url -> Url(url.urlid, clubId, url.name, url.color, url.url) }
dto.urls.map { url -> Url(url.urlid, clubId, url.name, url.color, url.url) },
)
}
.invalidateStamp { ResponseStamp.URL.withKey("$clubId") }
Expand Down
22 changes: 16 additions & 6 deletions src/main/kotlin/com/mnnit/moticlubs/controller/UserController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,28 @@ import com.mnnit.moticlubs.dto.request.UpdateContactDTO
import com.mnnit.moticlubs.dto.response.AdminUserDTO
import com.mnnit.moticlubs.service.FCMService
import com.mnnit.moticlubs.service.UserService
import com.mnnit.moticlubs.utils.*
import com.mnnit.moticlubs.utils.Constants.BASE_PATH
import com.mnnit.moticlubs.utils.Constants.STAMP_HEADER
import com.mnnit.moticlubs.utils.Constants.USER_ID_CLAIM
import com.mnnit.moticlubs.utils.Constants.USER_ROUTE
import com.mnnit.moticlubs.utils.ResponseStamp
import com.mnnit.moticlubs.utils.ResponseStamp.invalidateStamp
import com.mnnit.moticlubs.utils.ServiceLogger
import com.mnnit.moticlubs.utils.apiWrapper
import com.mnnit.moticlubs.utils.invalidateStamp
import com.mnnit.moticlubs.utils.wrapError
import com.mnnit.moticlubs.web.security.PathAuthorization
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.ResponseEntity
import org.springframework.http.server.reactive.ServerHttpRequest
import org.springframework.web.bind.annotation.*
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

@RestController
Expand Down Expand Up @@ -47,7 +57,7 @@ class UserController(
serviceCall = {
LOGGER.info("getSelf: uid: $it, ${serverRequest.path.value()}")
userService.getUserByUid(it)
}
},
)

@GetMapping("/{$USER_ID_CLAIM}")
Expand All @@ -62,7 +72,7 @@ class UserController(
serviceCall = {
LOGGER.info("getUser: uid: $userId")
userService.getUserByUid(userId)
}
},
)

@GetMapping("/all")
Expand All @@ -76,7 +86,7 @@ class UserController(
serviceCall = {
LOGGER.info("getAll")
userService.getAllUsers()
}
},
)

@GetMapping("/admins")
Expand All @@ -90,7 +100,7 @@ class UserController(
serviceCall = {
LOGGER.info("getAdmins")
userService.getAllAdminUsers()
}
},
)

@PostMapping
Expand Down
Loading

0 comments on commit 2490f27

Please sign in to comment.