자유게시판 모델 수정

This commit is contained in:
byung eun park 2019-11-06 21:48:10 +09:00
parent f1e7bc69f2
commit 634ea93108
10 changed files with 137 additions and 9 deletions

View File

@ -84,6 +84,14 @@
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.vladmihalcea/hibernate-types-52 -->
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>2.7.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -43,13 +43,13 @@ public class LeagueController {
} }
@PutMapping(value = "/league/{leagueId}") @PutMapping(value = "/league/{leagueId}")
public ResponseEntity<?> updateLeague(@PathVariable Long leagueId, LeagueEntity leagueEntity) throws Exception { public ResponseEntity<?> modify(@PathVariable Long leagueId, LeagueEntity leagueEntity) throws Exception {
LeagueEntity leagueEntity1 = this.leagueService.modify(leagueEntity); LeagueEntity leagueEntity1 = this.leagueService.modify(leagueEntity);
return ResponseEntity.ok(leagueEntity1); return ResponseEntity.ok(leagueEntity1);
} }
@DeleteMapping(value = "/league/{leagueId}") @DeleteMapping(value = "/league/{leagueId}")
public ResponseEntity<?> deleteLeague(@PathVariable Long leagueId) { public ResponseEntity<?> removeById(@PathVariable Long leagueId) {
Long res = this.leagueService.removeById(leagueId); Long res = this.leagueService.removeById(leagueId);
return ResponseEntity.ok(res); return ResponseEntity.ok(res);
} }

View File

@ -1,11 +1,15 @@
package com.totopia.server.modules.game.entity; package com.totopia.server.modules.game.entity;
import com.totopia.server.commons.data.entity.DateAuditEntity; import com.totopia.server.commons.data.entity.DateAuditEntity;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import javax.persistence.*; import javax.persistence.*;
import java.util.Map; import java.util.Map;
@ -17,6 +21,9 @@ import java.util.Map;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
@TypeDefs({
@TypeDef(name = "json", typeClass = JsonStringType.class)
})
public class SportsEventResultEntity extends DateAuditEntity { public class SportsEventResultEntity extends DateAuditEntity {
@Id @Id
@ -42,7 +49,8 @@ public class SportsEventResultEntity extends DateAuditEntity {
@Column(name = "away_final_score") @Column(name = "away_final_score")
private Short awayFinalScore; private Short awayFinalScore;
@Column(name = "score_Info", columnDefinition = "json") @Type(type = "json")
@Column(name = "score_info", columnDefinition = "json")
private Map<String, Object> scoreInfo; private Map<String, Object> scoreInfo;
} }

View File

@ -0,0 +1,61 @@
package com.totopia.server.modules.info.controller;
import com.totopia.server.commons.data.payload.ApiResponse;
import com.totopia.server.modules.info.entity.FreeBoardEntity;
import com.totopia.server.modules.info.service.FreeBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
public class FreeBoardController {
@Autowired
private FreeBoardService freeBoardService;
@PostMapping(value = "/free-board")
@ResponseStatus(code = HttpStatus.CREATED)
public ResponseEntity<?> save(@Valid @RequestBody FreeBoardEntity freeBoardEntity) throws Exception{
this.freeBoardService.save(freeBoardEntity);
return ResponseEntity.ok().body(new ApiResponse(true, "FreeBoard registered successfully"));
}
@GetMapping(value = "/free-board")
public Page<FreeBoardEntity> all(
@SortDefault.SortDefaults({
@SortDefault(
sort = "createdAt",
direction = Sort.Direction.DESC) })
Pageable pageable) {
return this.freeBoardService.getAllByPageable(pageable);
}
//
// @GetMapping(value = "/users/{userId}")
// public UserEntity findByUserId(@PathVariable Long userId) {
// return this.userService.getUserById(userId);
// }
@GetMapping(value = "/free-board/{boardId}")
public FreeBoardEntity findById(
@PathVariable Long boardId) {
return this.freeBoardService.getBoardById(boardId);
}
@PutMapping(value = "/free-board/{boardId}")
public ResponseEntity<?> modify(@PathVariable Long boardId, FreeBoardEntity freeBoardEntity) throws Exception {
FreeBoardEntity board = this.freeBoardService.modify(freeBoardEntity);
return ResponseEntity.ok(board);
}
@DeleteMapping(value = "/free-board/{boardId}")
public ResponseEntity<?> removeById(@PathVariable Long boardId) {
Long res = this.freeBoardService.removeById(boardId);
return ResponseEntity.ok(res);
}
}

View File

@ -36,4 +36,7 @@ public class FreeBoardEntity extends UserDateAuditEntity {
@Column(name = "attach_id", nullable = true) @Column(name = "attach_id", nullable = true)
private Long attachFile; private Long attachFile;
@Transient
private Long owner;
} }

View File

@ -0,0 +1,7 @@
package com.totopia.server.modules.info.repository;
import com.totopia.server.modules.info.entity.FreeBoardEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface FreeBoardRepository extends JpaRepository<FreeBoardEntity, Long> {
}

View File

@ -0,0 +1,41 @@
package com.totopia.server.modules.info.service;
import com.totopia.server.modules.info.entity.FreeBoardEntity;
import com.totopia.server.modules.info.repository.FreeBoardRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class FreeBoardService {
@Autowired
private FreeBoardRepository freeBoardRepository;
public void save(FreeBoardEntity freeBoardEntity) throws Exception {
freeBoardEntity.setCreatedBy(freeBoardEntity.getOwner());
this.freeBoardRepository.save(freeBoardEntity);
}
public Page<FreeBoardEntity> getAllByPageable(Pageable pageable) {
return this.freeBoardRepository.findAll(pageable);
}
public FreeBoardEntity modify(FreeBoardEntity freeBoardEntity) {
freeBoardEntity.setUpdatedBy(1L);
freeBoardEntity.setUpdatedAt(new Date());
return this.freeBoardRepository.save(freeBoardEntity);
}
public Long removeById(Long boardId) {
this.freeBoardRepository.deleteById(boardId);
return boardId;
}
public FreeBoardEntity getBoardById(Long boardId) {
return this.freeBoardRepository.findById(boardId).orElseThrow(null);
}
}

View File

@ -48,11 +48,11 @@ public class UserEntity extends DateAuditEntity {
private Boolean block = false; private Boolean block = false;
@Basic @Basic
@Column(name = "ref_enable", nullable = false) @Column(name = "ref_enable", nullable = true)
private Boolean refEnable = false; private Boolean refEnable = false;
@Basic @Basic
@Column(name = "ref_id", nullable = false) @Column(name = "ref_id", nullable = true)
private Long ref; private Long ref;
@Basic @Basic

View File

@ -32,7 +32,7 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
// Page<UserEntity> findAllByIsAdminTrue(Pageable pageable) throws Exception; // Page<UserEntity> findAllByIsAdminTrue(Pageable pageable) throws Exception;
// 패스워드 리셋이 트루인 유저 리스 // 패스워드 리셋이 트루인 유저 리스
Page<UserEntity> findAllByRequireResetTrue(Pageable pageable) throws Exception; // Page<UserEntity> findAllByRequireResetTrue(Pageable pageable) throws Exception;
// // 어드민이 펄스이며, 활동중인 현재 회원 리스트 // // 어드민이 펄스이며, 활동중인 현재 회원 리스트
// Page<UserEntity> findAllByIsAdminFalseAndActivationEquals(String activation, // Page<UserEntity> findAllByIsAdminFalseAndActivationEquals(String activation,

View File

@ -86,9 +86,9 @@ public class UserRepositoryTest {
public void findAllByIsAdminTrue() { public void findAllByIsAdminTrue() {
} }
@Test // @Test
public void findAllByRequireResetTrue() { // public void findAllByRequireResetTrue() {
} // }
@Test @Test
public void findAllByIsAdminFalseAndActivationEquals() { public void findAllByIsAdminFalseAndActivationEquals() {