Skip to content

Commit 8080a67

Browse files
committed
integrationID bilgisi ile update etme süreci denendi ama fail :(
1 parent 05dba97 commit 8080a67

26 files changed

+98
-1873
lines changed

src/main/java/com/cevheri/blog/domain/PostLike.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cevheri.blog.domain;
22

3+
import com.cevheri.blog.domain.audit.AbstractCRUDEntity;
34
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
45

56
import java.io.Serializable;
@@ -14,7 +15,7 @@
1415
@Entity
1516
@Table(name = "post_like")
1617
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
17-
public class PostLike extends AbstractAuditingEntity
18+
public class PostLike extends AbstractCRUDEntity
1819
implements Serializable {
1920

2021
private static final long serialVersionUID = 1L;

src/main/java/com/cevheri/blog/domain/PostView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cevheri.blog.domain;
22

3+
import com.cevheri.blog.domain.audit.AbstractCRUDEntity;
34
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
45

56
import java.io.Serializable;
@@ -14,7 +15,7 @@
1415
@Entity
1516
@Table(name = "post_view")
1617
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
17-
public class PostView extends AbstractAuditingEntity
18+
public class PostView extends AbstractCRUDEntity
1819
implements Serializable {
1920

2021
private static final long serialVersionUID = 1L;

src/main/java/com/cevheri/blog/domain/ThirdPartyApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.cevheri.blog.domain;
22

3+
import com.cevheri.blog.domain.audit.AbstractCRUDEntity;
34
import com.cevheri.blog.domain.enumeration.ThirdPartyAppName;
45

56
import java.io.Serializable;
@@ -15,7 +16,7 @@
1516
@Entity
1617
@Table(name = "third_party_app")
1718
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
18-
public class ThirdPartyApp extends AbstractAuditingEntity
19+
public class ThirdPartyApp extends AbstractCRUDEntity
1920
implements Serializable {
2021

2122
private static final long serialVersionUID = 1L;

src/main/java/com/cevheri/blog/service/PostService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface PostService {
2525
* @param postDTO the entity to update.
2626
* @return the persisted entity.
2727
*/
28-
PostDTO update(UpdatePostDTO postDTO);
28+
PostDTO update(PostDTO postDTO);
2929

3030
/**
3131
* Partially updates a post.

src/main/java/com/cevheri/blog/service/impl/PostServiceImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import com.cevheri.blog.service.mapper.PostMapper;
1717

1818
import java.util.Optional;
19-
20-
import com.cevheri.blog.web.rest.errors.BadRequestAlertException;
2119
import org.slf4j.Logger;
2220
import org.slf4j.LoggerFactory;
2321
import org.springframework.data.domain.Page;
@@ -75,7 +73,7 @@ public PostDTO save(PostDTO postDTO) {
7573

7674

7775
@Override
78-
public PostDTO update(UpdatePostDTO postDTO) {
76+
public PostDTO update(PostDTO postDTO) {
7977
log.debug("Request to save Post : {}", postDTO);
8078
Post post = postMapper.toEntity(postDTO);
8179
post = postRepository.save(post);
@@ -126,7 +124,7 @@ public Optional<PostDTO> findOne(Long id) {
126124
addPostViews(t);
127125
},
128126
() -> {
129-
throw new BadRequestAlertException("Entity not found", "post", "idnotfound");
127+
throw new RuntimeException("Entity not found");
130128
}
131129
);
132130
PostDTO postDTO = result.get();
@@ -144,7 +142,7 @@ private void addPostViews(PostDTO t) {
144142
private void checkPremiumMembership(PostDTO t) {
145143
if (t.getPaidMemberOnly()) {
146144
if (!SecurityUtils.hasCurrentUserAnyOfAuthorities(AuthoritiesConstants.PREMIUM)) {
147-
throw new BadRequestAlertException("Premium membership only!", "post", "premium_membership_only");
145+
throw new RuntimeException("Premium membership only!");
148146
}
149147
}
150148
}

src/main/java/com/cevheri/blog/web/rest/IntegrationLogResource.java

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -69,76 +69,6 @@ public ResponseEntity<IntegrationLogDTO> createIntegrationLog(@Valid @RequestBod
6969
.body(result);
7070
}
7171

72-
/**
73-
* {@code PUT /integration-logs/:id} : Updates an existing integrationLog.
74-
*
75-
* @param id the id of the integrationLogDTO to save.
76-
* @param integrationLogDTO the integrationLogDTO to update.
77-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated integrationLogDTO,
78-
* or with status {@code 400 (Bad Request)} if the integrationLogDTO is not valid,
79-
* or with status {@code 500 (Internal Server Error)} if the integrationLogDTO couldn't be updated.
80-
* @throws URISyntaxException if the Location URI syntax is incorrect.
81-
*/
82-
@PutMapping("/integration-logs/{id}")
83-
public ResponseEntity<IntegrationLogDTO> updateIntegrationLog(
84-
@PathVariable(value = "id", required = false) final Long id,
85-
@Valid @RequestBody IntegrationLogDTO integrationLogDTO
86-
) throws URISyntaxException {
87-
log.debug("REST request to update IntegrationLog : {}, {}", id, integrationLogDTO);
88-
if (integrationLogDTO.getId() == null) {
89-
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
90-
}
91-
if (!Objects.equals(id, integrationLogDTO.getId())) {
92-
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
93-
}
94-
95-
if (!integrationLogRepository.existsById(id)) {
96-
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
97-
}
98-
99-
IntegrationLogDTO result = integrationLogService.update(integrationLogDTO);
100-
return ResponseEntity
101-
.ok()
102-
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, integrationLogDTO.getId().toString()))
103-
.body(result);
104-
}
105-
106-
/**
107-
* {@code PATCH /integration-logs/:id} : Partial updates given fields of an existing integrationLog, field will ignore if it is null
108-
*
109-
* @param id the id of the integrationLogDTO to save.
110-
* @param integrationLogDTO the integrationLogDTO to update.
111-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated integrationLogDTO,
112-
* or with status {@code 400 (Bad Request)} if the integrationLogDTO is not valid,
113-
* or with status {@code 404 (Not Found)} if the integrationLogDTO is not found,
114-
* or with status {@code 500 (Internal Server Error)} if the integrationLogDTO couldn't be updated.
115-
* @throws URISyntaxException if the Location URI syntax is incorrect.
116-
*/
117-
@PatchMapping(value = "/integration-logs/{id}", consumes = { "application/json", "application/merge-patch+json" })
118-
public ResponseEntity<IntegrationLogDTO> partialUpdateIntegrationLog(
119-
@PathVariable(value = "id", required = false) final Long id,
120-
@NotNull @RequestBody IntegrationLogDTO integrationLogDTO
121-
) throws URISyntaxException {
122-
log.debug("REST request to partial update IntegrationLog partially : {}, {}", id, integrationLogDTO);
123-
if (integrationLogDTO.getId() == null) {
124-
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
125-
}
126-
if (!Objects.equals(id, integrationLogDTO.getId())) {
127-
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
128-
}
129-
130-
if (!integrationLogRepository.existsById(id)) {
131-
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
132-
}
133-
134-
Optional<IntegrationLogDTO> result = integrationLogService.partialUpdate(integrationLogDTO);
135-
136-
return ResponseUtil.wrapOrNotFound(
137-
result,
138-
HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, integrationLogDTO.getId().toString())
139-
);
140-
}
141-
14272
/**
14373
* {@code GET /integration-logs} : get all the integrationLogs.
14474
*
@@ -166,19 +96,4 @@ public ResponseEntity<IntegrationLogDTO> getIntegrationLog(@PathVariable Long id
16696
return ResponseUtil.wrapOrNotFound(integrationLogDTO);
16797
}
16898

169-
/**
170-
* {@code DELETE /integration-logs/:id} : delete the "id" integrationLog.
171-
*
172-
* @param id the id of the integrationLogDTO to delete.
173-
* @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}.
174-
*/
175-
@DeleteMapping("/integration-logs/{id}")
176-
public ResponseEntity<Void> deleteIntegrationLog(@PathVariable Long id) {
177-
log.debug("REST request to delete IntegrationLog : {}", id);
178-
integrationLogService.delete(id);
179-
return ResponseEntity
180-
.noContent()
181-
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString()))
182-
.build();
183-
}
18499
}

src/main/java/com/cevheri/blog/web/rest/PostCommentResource.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -102,64 +102,7 @@ public ResponseEntity<PostCommentDTO> updatePostComment(
102102
.body(result);
103103
}
104104

105-
/**
106-
* {@code PATCH /post-comments/:id} : Partial updates given fields of an existing postComment, field will ignore if it is null
107-
*
108-
* @param id the id of the postCommentDTO to save.
109-
* @param postCommentDTO the postCommentDTO to update.
110-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated postCommentDTO,
111-
* or with status {@code 400 (Bad Request)} if the postCommentDTO is not valid,
112-
* or with status {@code 404 (Not Found)} if the postCommentDTO is not found,
113-
* or with status {@code 500 (Internal Server Error)} if the postCommentDTO couldn't be updated.
114-
* @throws URISyntaxException if the Location URI syntax is incorrect.
115-
*/
116-
@PatchMapping(value = "/post-comments/{id}", consumes = { "application/json", "application/merge-patch+json" })
117-
public ResponseEntity<PostCommentDTO> partialUpdatePostComment(
118-
@PathVariable(value = "id", required = false) final Long id,
119-
@NotNull @RequestBody PostCommentDTO postCommentDTO
120-
) throws URISyntaxException {
121-
log.debug("REST request to partial update PostComment partially : {}, {}", id, postCommentDTO);
122-
if (postCommentDTO.getId() == null) {
123-
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
124-
}
125-
if (!Objects.equals(id, postCommentDTO.getId())) {
126-
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
127-
}
128-
129-
if (!postCommentRepository.existsById(id)) {
130-
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
131-
}
132105

133-
Optional<PostCommentDTO> result = postCommentService.partialUpdate(postCommentDTO);
134-
135-
return ResponseUtil.wrapOrNotFound(
136-
result,
137-
HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, postCommentDTO.getId().toString())
138-
);
139-
}
140-
141-
/**
142-
* {@code GET /post-comments} : get all the postComments.
143-
*
144-
* @param pageable the pagination information.
145-
* @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many).
146-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of postComments in body.
147-
*/
148-
@GetMapping("/post-comments")
149-
public ResponseEntity<List<PostCommentDTO>> getAllPostComments(
150-
@org.springdoc.api.annotations.ParameterObject Pageable pageable,
151-
@RequestParam(required = false, defaultValue = "false") boolean eagerload
152-
) {
153-
log.debug("REST request to get a page of PostComments");
154-
Page<PostCommentDTO> page;
155-
if (eagerload) {
156-
page = postCommentService.findAllWithEagerRelationships(1L, pageable);
157-
} else {
158-
page = postCommentService.findAll(1L, pageable);
159-
}
160-
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
161-
return ResponseEntity.ok().headers(headers).body(page.getContent());
162-
}
163106
/**
164107
* {@code GET /post-comments/:postId } : get all the postComments By postId.
165108
*

src/main/java/com/cevheri/blog/web/rest/PostLikeResource.java

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -66,76 +66,6 @@ public ResponseEntity<PostLikeDTO> createPostLike(@RequestBody PostLikeDTO postL
6666
.body(result);
6767
}
6868

69-
/**
70-
* {@code PUT /post-likes/:id} : Updates an existing postLike.
71-
*
72-
* @param id the id of the postLikeDTO to save.
73-
* @param postLikeDTO the postLikeDTO to update.
74-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated postLikeDTO,
75-
* or with status {@code 400 (Bad Request)} if the postLikeDTO is not valid,
76-
* or with status {@code 500 (Internal Server Error)} if the postLikeDTO couldn't be updated.
77-
* @throws URISyntaxException if the Location URI syntax is incorrect.
78-
*/
79-
@PutMapping("/post-likes/{id}")
80-
public ResponseEntity<PostLikeDTO> updatePostLike(
81-
@PathVariable(value = "id", required = false) final Long id,
82-
@RequestBody PostLikeDTO postLikeDTO
83-
) throws URISyntaxException {
84-
log.debug("REST request to update PostLike : {}, {}", id, postLikeDTO);
85-
if (postLikeDTO.getId() == null) {
86-
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
87-
}
88-
if (!Objects.equals(id, postLikeDTO.getId())) {
89-
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
90-
}
91-
92-
if (!postLikeRepository.existsById(id)) {
93-
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
94-
}
95-
96-
PostLikeDTO result = postLikeService.update(postLikeDTO);
97-
return ResponseEntity
98-
.ok()
99-
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, postLikeDTO.getId().toString()))
100-
.body(result);
101-
}
102-
103-
/**
104-
* {@code PATCH /post-likes/:id} : Partial updates given fields of an existing postLike, field will ignore if it is null
105-
*
106-
* @param id the id of the postLikeDTO to save.
107-
* @param postLikeDTO the postLikeDTO to update.
108-
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated postLikeDTO,
109-
* or with status {@code 400 (Bad Request)} if the postLikeDTO is not valid,
110-
* or with status {@code 404 (Not Found)} if the postLikeDTO is not found,
111-
* or with status {@code 500 (Internal Server Error)} if the postLikeDTO couldn't be updated.
112-
* @throws URISyntaxException if the Location URI syntax is incorrect.
113-
*/
114-
@PatchMapping(value = "/post-likes/{id}", consumes = { "application/json", "application/merge-patch+json" })
115-
public ResponseEntity<PostLikeDTO> partialUpdatePostLike(
116-
@PathVariable(value = "id", required = false) final Long id,
117-
@RequestBody PostLikeDTO postLikeDTO
118-
) throws URISyntaxException {
119-
log.debug("REST request to partial update PostLike partially : {}, {}", id, postLikeDTO);
120-
if (postLikeDTO.getId() == null) {
121-
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
122-
}
123-
if (!Objects.equals(id, postLikeDTO.getId())) {
124-
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
125-
}
126-
127-
if (!postLikeRepository.existsById(id)) {
128-
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
129-
}
130-
131-
Optional<PostLikeDTO> result = postLikeService.partialUpdate(postLikeDTO);
132-
133-
return ResponseUtil.wrapOrNotFound(
134-
result,
135-
HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, postLikeDTO.getId().toString())
136-
);
137-
}
138-
13969
/**
14070
* {@code GET /post-likes} : get all the postLikes.
14171
*

src/main/java/com/cevheri/blog/web/rest/PostResource.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,23 @@ public ResponseEntity<?> updatePost(
115115
return new ResponseEntity<>("Unauthorized", HttpStatus.UNAUTHORIZED);
116116
}
117117

118+
convertToPostDto(updatePostDTO, postDTO);
118119

119-
PostDTO result = postService.update(updatePostDTO);
120+
PostDTO result = postService.update(postDTO.get());
120121
return ResponseEntity
121122
.ok()
122123
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, updatePostDTO.getId().toString()))
123124
.body(result);
124125
}
125126

127+
private void convertToPostDto(UpdatePostDTO updatePostDTO, Optional<PostDTO> postDTO) {
128+
postDTO.get().setContent(updatePostDTO.getContent());
129+
postDTO.get().setTitle(updatePostDTO.getTitle());
130+
postDTO.get().setPaidMemberOnly(updatePostDTO.getPaidMemberOnly());
131+
postDTO.get().setPublishThirdPartyApp(updatePostDTO.getPublishThirdPartyApp());
132+
postDTO.get().setTags(updatePostDTO.getTags());
133+
}
134+
126135
/**
127136
* {@code PATCH /posts/:id} : Partial updates given fields of an existing post, field will ignore if it is null
128137
*

0 commit comments

Comments
 (0)