Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.5.9
0816c7f40fb103a987855105bc1620a18e0fbaae

# Scala Steward: Reformat with scalafmt 3.8.4
fa5b1430ba2bce3c807146b22887ff85feac440f
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.3"
version = "3.8.4"
runner.dialect = scala213
maxColumn = 120
align.preset = more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ trait ApiJsonCodec {
* @return
*/
def buildFlowResponse[T <: Product]
: stream.Stream[Throwable, T] => Future[Either[ZimError, Source[ByteString, Any]]] = respStream => {
: stream.Stream[Throwable, T] => Future[Either[ZimError, Source[ByteString, Any]]] = respStream => {
val resp = (for {
list <- respStream.runCollect
resp = ResultSet[List[T]](data = list.toList).asJson.noSpaces
Expand All @@ -170,7 +170,7 @@ trait ApiJsonCodec {
* @return
*/
def buildMonoResponse[T <: Product](
returnError: Boolean = false
returnError: Boolean = false
): stream.Stream[Throwable, T] => Future[Either[ZimError, Source[ByteString, Any]]] = respStream => {
val resp = (for {
ret <- respStream.runHead.map(_.getOrElse(null.asInstanceOf[T]))
Expand All @@ -190,9 +190,9 @@ trait ApiJsonCodec {
}

def buildIntMonoResponse(
returnError: Boolean = true,
code: Int = SystemConstant.ERROR,
msg: String = SystemConstant.ERROR_MESSAGE
returnError: Boolean = true,
code: Int = SystemConstant.ERROR,
msg: String = SystemConstant.ERROR_MESSAGE
): stream.Stream[Throwable, Int] => Future[Either[ZimError, Source[ByteString, Any]]] = respStream => {
val resp = (for {
resp <- respStream.runHead.map(_.getOrElse(0))
Expand All @@ -208,9 +208,9 @@ trait ApiJsonCodec {
}

def buildBooleanMonoResponse(
returnError: Boolean = true,
code: Int = SystemConstant.ERROR,
msg: String = SystemConstant.ERROR_MESSAGE
returnError: Boolean = true,
code: Int = SystemConstant.ERROR,
msg: String = SystemConstant.ERROR_MESSAGE
): stream.Stream[Throwable, Boolean] => Future[Either[ZimError, Source[ByteString, Any]]] = respStream => {
val resp = (for {
resp <- respStream.runHead.map(_.getOrElse(false))
Expand All @@ -226,7 +226,7 @@ trait ApiJsonCodec {
}

def buildPagesResponse[T <: Product]
: IO[Throwable, ResultPageSet[T]] => Future[Either[ZimError, Source[ByteString, Any]]] =
: IO[Throwable, ResultPageSet[T]] => Future[Either[ZimError, Source[ByteString, Any]]] =
respIO => {
val resp: ZIO[Any, Throwable, Publisher[ByteString]] = (for {
resp <- respIO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,13 @@ trait UserEndpoint extends ApiErrorMapping {
.errorOut(errorOut)
.errorOutVariants[ZimError](errorOutVar.head, errorOutVar.tail: _*)

lazy val loginEndpoint
: Endpoint[Unit, UserSecurityInfo, ZimError, (CookieValueWithMeta, Source[ByteString, Any]), Any with AkkaStreams] =
lazy val loginEndpoint: Endpoint[
Unit,
UserSecurityInfo,
ZimError,
(CookieValueWithMeta, Source[ByteString, Any]),
Any with AkkaStreams
] =
endpoint.post
.in(userResource / "login")
.in(jsonBody[UserSecurityInfo])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait WsEndpoint {

// TODO typed ws
lazy val wsEndpoint
: PublicEndpoint[Int, Unit, Pipe[TextMessage.Strict, String], Any with AkkaStreams with WebSockets] =
: PublicEndpoint[Int, Unit, Pipe[TextMessage.Strict, String], Any with AkkaStreams with WebSockets] =
endpoint
.in("websocket" / query[Int]("uid"))
.description("Websocket Endpoint")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ trait CookieAuthority {
* @return
*/
def authenticate(
token: UserToken
token: UserToken
)(
authorityFunction: AuthorityFunction
authorityFunction: AuthorityFunction
)(implicit ec: ExecutionContext): Future[Either[Unauthorized, UserSecurityInfo]] =
Future {
val tk = if (token.cookie.trim.contains(" ")) token.cookie.trim.split(" ")(1) else token.cookie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ trait RedisService[F[_]] {
* Boolean
*/
def set[T](k: String, v: T, expireTime: JavaDuration = java.time.Duration.ofMinutes(30))(implicit
encoder: Encoder[T]
encoder: Encoder[T]
): F[Boolean]

/** 根据key获取value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object CatsRedisServiceLive {
}

final case class CatsRedisServiceLive(redis: Resource[IO, RedisCommands[IO, String, String]])(implicit
logger: Logger[IO]
logger: Logger[IO]
) extends RedisService[IO] {

override def getSets(k: String): IO[List[String]] =
Expand All @@ -94,7 +94,7 @@ final case class CatsRedisServiceLive(redis: Resource[IO, RedisCommands[IO, Stri
}

override def set[T](k: String, v: T, expireTime: JavaDuration = java.time.Duration.ofMinutes(30))(implicit
encoder: Encoder[T]
encoder: Encoder[T]
): IO[Boolean] =
logger.info(s"Redis set command: $k, $v, $expireTime") *> redis.use { redis =>
redis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final case class ZioRedisServiceLive(private val rs: Redis) extends RedisService
rs.sAdd(k, m)

override def set[T](k: String, v: T, expireTime: JavaDuration = java.time.Duration.ofMinutes(30))(implicit
encoder: Encoder[T]
encoder: Encoder[T]
): Task[Boolean] =
rs.set[String, String](k, v.asJson.noSpaces, expireTime = Some(expireTime))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ import io.circe.generic.semiauto._
* 消息发送者
*/
final case class AddInfo(
id: Int,
uid: Int,
content: String,
from: Int,
from_group: Int,
`type`: Int,
remark: String,
href: String,
read: Int,
time: ZonedDateTime,
user: User
id: Int,
uid: Int,
content: String,
from: Int,
from_group: Int,
`type`: Int,
remark: String,
href: String,
read: Int,
time: ZonedDateTime,
user: User
)

object AddInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import io.circe.generic.semiauto._
* 时间
*/
final case class ChatHistory(
id: Int,
username: String,
avatar: String,
content: String,
timestamp: Long
id: Int,
username: String,
avatar: String,
content: String,
timestamp: Long
)

object ChatHistory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import zio.schema._
* 群组信息列表
*/
final case class FriendAndGroupInfo(
mine: User,
friend: List[FriendList],
group: List[GroupList]
mine: User,
friend: List[FriendList],
group: List[GroupList]
)

object FriendAndGroupInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ package org.bitlap.zim.domain
* 梦境迷离
*/
class ResultSet[T](
val data: T,
val code: Int = SystemConstant.SUCCESS,
val msg: String = SystemConstant.SUCCESS_MESSAGE
val data: T,
val code: Int = SystemConstant.SUCCESS,
val msg: String = SystemConstant.SUCCESS_MESSAGE
)

object ResultSet {

def apply[T](
data: T = null,
code: Int = SystemConstant.SUCCESS,
msg: String = SystemConstant.SUCCESS_MESSAGE
data: T = null,
code: Int = SystemConstant.SUCCESS,
msg: String = SystemConstant.SUCCESS_MESSAGE
): ResultSet[T] = new ResultSet(data, code, msg)
}
12 changes: 6 additions & 6 deletions modules/zim-domain/src/main/scala/org/bitlap/zim/domain/To.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import io.circe._
* 聊天类型,一般分friend和group两种,group即群聊
*/
final case class To(
id: Int,
username: String,
sign: String,
avatar: String,
status: String,
`type`: String
id: Int,
username: String,
sign: String,
avatar: String,
status: String,
`type`: String
)

object To {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ sealed trait ZimError extends Throwable with Product {
object ZimError {

case class BusinessException(
override val code: Int = SystemConstant.ERROR,
override val msg: String = SystemConstant.ERROR_MESSAGE
override val code: Int = SystemConstant.ERROR,
override val msg: String = SystemConstant.ERROR_MESSAGE
) extends ZimError

case class Unauthorized(
override val code: Int = SystemConstant.ERROR,
override val msg: String = SystemConstant.NOT_LOGIN
override val code: Int = SystemConstant.ERROR,
override val msg: String = SystemConstant.NOT_LOGIN
) extends ZimError
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import io.circe.generic.semiauto._
* 密码
*/
final case class RegisterUserInput(
username: String,
password: String,
email: String
username: String,
password: String,
email: String
)

object RegisterUserInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import io.circe.generic.semiauto._
* 性别
*/
final case class UpdateUserInput(
id: Int,
username: String,
password: Option[String],
oldpwd: Option[String],
sign: String,
sex: String
id: Int,
username: String,
password: Option[String],
oldpwd: Option[String],
sign: String,
sex: String
)

object UpdateUserInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ import scalikejdbc.{WrappedResultSet, _}
* 申请时间
*/
final case class AddMessage(
id: Int,
fromUid: Int,
toUid: Int,
groupId: Int,
remark: String,
agree: Int,
`type`: Int,
time: ZonedDateTime
id: Int,
fromUid: Int,
toUid: Int,
groupId: Int,
remark: String,
agree: Int,
`type`: Int,
time: ZonedDateTime
)

object AddMessage extends BaseModel[AddMessage] {
Expand Down Expand Up @@ -82,12 +82,12 @@ object AddMessage extends BaseModel[AddMessage] {
)

def apply(
fromUid: Int,
toUid: Int,
groupId: Int,
remark: String,
`type`: Int,
time: ZonedDateTime = ZonedDateTime.now()
fromUid: Int,
toUid: Int,
groupId: Int,
remark: String,
`type`: Int,
time: ZonedDateTime = ZonedDateTime.now()
): AddMessage =
AddMessage(0, fromUid, toUid, groupId, remark, 0, `type`, time)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import zio.schema._
* 创建人ID
*/
final case class GroupList(
override val id: Int,
override val groupName: String,
avatar: String,
createId: Int
override val id: Int,
override val groupName: String,
avatar: String,
createId: Int
) extends Group(id, groupName)

object GroupList extends BaseModel[GroupList] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ import scalikejdbc.{WrappedResultSet, _}
* 消息的状态
*/
final case class Receive(
toid: Int,
mid: Int,
username: String,
avatar: String,
`type`: String,
content: String,
cid: Int,
mine: Boolean,
fromid: Int,
timestamp: Long,
status: Int
toid: Int,
mid: Int,
username: String,
avatar: String,
`type`: String,
content: String,
cid: Int,
mine: Boolean,
fromid: Int,
timestamp: Long,
status: Int
)

object Receive extends SQLSyntaxSupport[Receive] {
Expand Down
Loading
Loading