完善字符串类型的体验

This commit is contained in:
BBIT-Kai
2026-04-14 17:50:27 +08:00
parent 44181bcf5a
commit 55a2490e14
8 changed files with 92 additions and 16 deletions
@@ -288,6 +288,19 @@ fun Application.Traceability(config: AppConfig) {
}
call.respond(BaseResponse(message = "批次已发布", data = data))
}
post("/{id}/scan-count/reset") {
val id = parseUuidOrNull(call.parameters["id"])
if (id == null) {
call.respond(HttpStatusCode.BadRequest, BaseResponse(status = false, message = "批次ID无效", data = null))
return@post
}
val data = TraceabilityDao.resetBatchScanCount(id)
if (data == null) {
call.respond(HttpStatusCode.NotFound, BaseResponse(status = false, message = "批次不存在", data = null))
return@post
}
call.respond(BaseResponse(message = "扫码次数已重置", data = data))
}
}
route("/feedback") {
@@ -764,6 +764,16 @@ object TraceabilityDao {
getBatch(batchId)
}
fun resetBatchScanCount(batchId: UUID): TraceBatchDetailResponse? = transaction {
val now = timestampLiteral(nowInstant())
val updated = TraceabilityBatchesTable.update({ TraceabilityBatchesTable.id eq batchId }) {
it[scanCount] = 0
it[updatedAt] = now
}
if (updated == 0) return@transaction null
getBatch(batchId)
}
fun getPublicDetailByCode(
batchCode: String,
increaseScan: Boolean = false,