Skip to content

Commit 64b8f5a

Browse files
authored
Merge pull request #1060 from terrestris/textual-contents
feat: introduce textual contents
2 parents aa79359 + 8f65829 commit 64b8f5a

File tree

9 files changed

+186
-1
lines changed

9 files changed

+186
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE TABLE IF NOT EXISTS shogun.textualcontents (
2+
id bigint PRIMARY KEY,
3+
created timestamp without time zone NULL,
4+
modified timestamp without time zone NULL,
5+
markdown text NOT NULL,
6+
title text NOT NULL,
7+
category text NOT NULL
8+
);
9+
10+
CREATE TABLE IF NOT EXISTS shogun_rev.textualcontents_rev (
11+
id bigint,
12+
rev integer REFERENCES shogun_rev.revinfo (rev),
13+
revtype smallint,
14+
created timestamp without time zone NULL,
15+
modified timestamp without time zone NULL,
16+
markdown text NULL,
17+
title text NULL,
18+
category text NULL,
19+
PRIMARY KEY (id, rev)
20+
);
21+
22+
alter table shogun_rev.textualcontents_rev add column if not exists created_mod bool;
23+
alter table shogun_rev.textualcontents_rev add column if not exists modified_mod bool;
24+
alter table shogun_rev.textualcontents_rev add column if not exists markdown_mod bool;
25+
alter table shogun_rev.textualcontents_rev add column if not exists title_mod bool;
26+
alter table shogun_rev.textualcontents_rev add column if not exists category_mod bool;

shogun-config/src/main/java/de/terrestris/shogun/config/DefaultWebSecurityConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ default void customHttpConfiguration(HttpSecurity http) throws Exception {
5858
"/files",
5959
"/files/*",
6060
"/imagefiles",
61-
"/imagefiles/*"
61+
"/imagefiles/*",
62+
"/textualcontents",
63+
"/textualcontents/*"
6264
)
6365
.permitAll()
6466
// Enable anonymous access to graphql (secured via permission evaluators)

shogun-config/src/main/resources/application-base.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ controller:
134134
enabled: true
135135
roles:
136136
enabled: true
137+
textualcontents:
138+
enabled: true
137139

138140
upload:
139141
file:

shogun-config/src/main/resources/ehcache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@
9191
<cache alias="layers" uses-template="default" />
9292
<cache alias="roles" uses-template="default" />
9393
<cache alias="users" uses-template="default" />
94+
<cache alias="textualcontents" uses-template="default" />
9495

9596
</config>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* SHOGun, https://terrestris.github.io/shogun/
2+
*
3+
* Copyright © 2025-present terrestris GmbH & Co. KG
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package de.terrestris.shogun.lib.controller;
18+
19+
import de.terrestris.shogun.lib.model.TextualContent;
20+
import de.terrestris.shogun.lib.service.TextualContentService;
21+
import de.terrestris.shogun.lib.controller.BaseController;
22+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
23+
import io.swagger.v3.oas.annotations.tags.Tag;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
25+
import org.springframework.web.bind.annotation.RequestMapping;
26+
import org.springframework.web.bind.annotation.RestController;
27+
28+
@RestController
29+
30+
@RequestMapping("/textualcontents")
31+
@ConditionalOnExpression("${controller.textualcontents.enabled:true}")
32+
@Tag(
33+
name = "TextualContents",
34+
description = "The endpoints to manage textual contents"
35+
)
36+
@SecurityRequirement(name = "bearer-key")
37+
public class TextualContentController extends BaseController<TextualContentService, TextualContent> { }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* SHOGun, https://terrestris.github.io/shogun/
2+
*
3+
* Copyright © 2025-present terrestris GmbH & Co. KG
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package de.terrestris.shogun.lib.model;
18+
19+
import io.swagger.v3.oas.annotations.media.Schema;
20+
import jakarta.persistence.*;
21+
import lombok.*;
22+
import org.hibernate.annotations.Cache;
23+
import org.hibernate.annotations.CacheConcurrencyStrategy;
24+
import org.hibernate.envers.AuditTable;
25+
import org.hibernate.envers.Audited;
26+
27+
@Entity(name = "textualcontents")
28+
@Table(schema = "shogun")
29+
@Cacheable
30+
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "textualcontents")
31+
@Data
32+
@AllArgsConstructor
33+
@NoArgsConstructor
34+
@ToString(callSuper = true)
35+
@EqualsAndHashCode(callSuper = true)
36+
@Audited
37+
@AuditTable(value = "textualcontents_rev", schema = "shogun_rev")
38+
39+
public class TextualContent extends BaseEntity {
40+
41+
@Column(nullable = false)
42+
@Schema(
43+
description = "The category of the textual content.",
44+
required = true
45+
)
46+
private String category;
47+
48+
@Column(nullable = false)
49+
@Schema(
50+
description = "The title of the textual content.",
51+
required = true
52+
)
53+
private String title;
54+
55+
@Column(nullable = false)
56+
@Schema(
57+
description = "The textual content.",
58+
required = true
59+
)
60+
private String markdown;
61+
62+
}

shogun-lib/src/main/java/de/terrestris/shogun/lib/model/jsonb/application/DefaultApplicationClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,8 @@ public class DefaultApplicationClientConfig implements ApplicationClientConfig {
7676
)
7777
private String printApp;
7878

79+
@Schema(
80+
description = "The texts which are shown in the NewsModal at the start of an application."
81+
)
82+
private ArrayList<Integer> newsTextIds;
7983
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* SHOGun, https://terrestris.github.io/shogun/
2+
*
3+
* Copyright © 2025-present terrestris GmbH & Co. KG
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package de.terrestris.shogun.lib.repository;
18+
19+
import de.terrestris.shogun.lib.model.TextualContent;
20+
import de.terrestris.shogun.lib.repository.BaseCrudRepository;
21+
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
22+
import org.springframework.stereotype.Repository;
23+
24+
public interface TextualContentRepository extends BaseCrudRepository<TextualContent, Long>,
25+
JpaSpecificationExecutor<TextualContent> {
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SHOGun, https://terrestris.github.io/shogun/
2+
*
3+
* Copyright © 2025-present terrestris GmbH & Co. KG
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package de.terrestris.shogun.lib.service;
18+
19+
import de.terrestris.shogun.lib.model.TextualContent;
20+
import de.terrestris.shogun.lib.repository.TextualContentRepository;
21+
import de.terrestris.shogun.lib.service.BaseService;
22+
import org.springframework.stereotype.Service;
23+
24+
@Service
25+
public class TextualContentService extends BaseService<TextualContentRepository, TextualContent> { }

0 commit comments

Comments
 (0)