refactor: 패키지 변경 적용

dev
minuk926 3 years ago
parent a936f4833d
commit c07cc6911c

@ -0,0 +1,51 @@
package com.xit.biz.ctgy.controller;
import com.xit.biz.ctgy.dto.MinCivBoard680Dto;
import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct;
import com.xit.biz.ctgy.service.IBoardService;
import com.xit.core.api.IRestResponse;
import com.xit.core.api.RestResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "MinCivBoard680Controller", description = "게시글 관리")
@RestController
@RequestMapping("/api/v1/ctgy/board")
@Validated
@RequiredArgsConstructor
public class BoardController {
private final IBoardService service;
private final MinCivBoard680Mapstruct mapstruct = Mappers.getMapper(MinCivBoard680Mapstruct.class);
// TODO :: 파라메터 정의 필요
@Operation(summary = "게시글 목록 조회" , description = "게시글 목록 조회")
@Parameters({
@Parameter(in = ParameterIn.QUERY, name = "ciTitle", description = "제목", required = false, example = " "),
@Parameter(in = ParameterIn.QUERY, name = "ciName", description = "이름", required = false, example = " "),
@Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"),
@Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10")
})
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> findMinCivBoard680s(
@Parameter(hidden = true)
final MinCivBoard680Dto dto,
@Parameter(hidden = true)
final Pageable pageable) {
return RestResponse.of(service.findAll(mapstruct.toEntity(dto), pageable));
}
}

@ -0,0 +1,64 @@
package com.xit.biz.ctgy.controller;
import com.xit.biz.ctgy.dto.MinUserinfoDto;
import com.xit.biz.ctgy.dto.struct.MinUserinfoMapstruct;
import com.xit.biz.ctgy.service.IMinUserService;
import com.xit.core.annotation.Secured;
import com.xit.core.annotation.SecurityPolicy;
import com.xit.core.api.IRestResponse;
import com.xit.core.api.RestResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "MinUserinfoController", description = "사용자 관리")
@RestController
@RequestMapping("/api/v1/ctgy/user")
@Validated
@RequiredArgsConstructor
public class MinUserController {
private final IMinUserService service;
private final MinUserinfoMapstruct mapstruct = Mappers.getMapper(MinUserinfoMapstruct.class);
// TODO :: 파라메터 정의 필요
@Operation(summary = "사용자 목록 조회" , description = "사용자 목록 조회")
@Parameters({
@Parameter(in = ParameterIn.QUERY, name = "userid", description = "사용자ID", required = false, example = " "),
@Parameter(in = ParameterIn.QUERY, name = "name", description = "이름", required = false, example = " "),
@Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"),
@Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10")
})
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<? extends IRestResponse> findMinUserinfos(
@Parameter(hidden = true)
@ModelAttribute("minUserinfoDto")
final MinUserinfoDto minUserinfoDto,
@Parameter(hidden = true)
final Pageable pageable) {
return RestResponse.of(service.findMinUsers(mapstruct.toEntity(minUserinfoDto), pageable));
}
@Operation(summary = "사용자 정보 조회" , description = "사용자 정보 조회")
@GetMapping("/info")
@Secured(policy = SecurityPolicy.TOKEN)
@Transactional(readOnly = true)
public ResponseEntity<? extends IRestResponse> getUserInfo() {
return RestResponse.of(service.findMyUserWithoutAuthorities());
}
}

@ -0,0 +1,23 @@
package com.xit.biz.ctgy.repository;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.core.oauth2.utils.SecurityUtil;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
public interface IMinUserRepository extends JpaRepository<MinUserinfo, String> {
Optional<MinUserinfo> findByUserid(String userid);
@Query(value = "SELECT TRAFFIC.ECL_ENCRYPT(?1) AS passwd FROM DUAL C", nativeQuery = true)
//@Query(value = "SELECT ECL_ENCRYPT(?1) AS passwd", nativeQuery = true)
String queryGetPasswdEncode(@Param("passwd") String passwd);
@Query(value = "SELECT ECL_DECRYPT(MU.passwd) AS passwd FROM min_userinfo MU WHERE MU.userid = ?1", nativeQuery = true)
String queryGetPasswd(@Param("userid") String userid);
MinUserinfo findMinUserinfoByUserid(String userid);
}

@ -0,0 +1,11 @@
package com.xit.biz.ctgy.service;
import com.xit.biz.ctgy.entity.MinCivBoard680;
import com.xit.core.support.jpa.IJpaOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface IBoardService {
Page<MinCivBoard680> findAll(MinCivBoard680 minCivBoard680, Pageable pageable);
}

@ -0,0 +1,15 @@
package com.xit.biz.ctgy.service;
import com.xit.biz.cmm.entity.CmmUser;
import com.xit.biz.ctgy.entity.MinUserinfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.Optional;
public interface IMinUserService {
Page<MinUserinfo> findMinUsers(MinUserinfo minUserinfo, Pageable pageable);
MinUserinfo findMyUserWithoutAuthorities();
}

@ -0,0 +1,48 @@
package com.xit.biz.ctgy.service.impl;
import com.xit.biz.ctgy.entity.MinUserinfo;
import com.xit.biz.ctgy.repository.IMinUserRepository;
import com.xit.biz.ctgy.service.IMinUserService;
import com.xit.core.oauth2.utils.HeaderUtil;
import com.xit.core.support.jpa.JpaUtil;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
@Service
public class MinUserService implements IMinUserService {
private final IMinUserRepository repository;
public MinUserService(IMinUserRepository repository) {
this.repository = repository;
}
@Transactional//(readOnly = true)
public Page<MinUserinfo> findMinUsers(MinUserinfo minUserinfo, Pageable pageable) {
//Sort sort = Sort.by(Sort.Direction.ASC, "codeOrdr");
pageable = JpaUtil.getPagingInfo(pageable);
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll()
.withMatcher("userid", contains())
.withMatcher("name", contains());
Example<MinUserinfo> example = Example.of(minUserinfo, exampleMatcher);
Page<MinUserinfo> page = repository.findAll(example, pageable);
// List<CmmUser> userList = page.getContent();
return page;
}
@Override
@Transactional(readOnly = true)
public MinUserinfo findMyUserWithoutAuthorities() {
//cmmUserRepos
//return Optional.empty(); //cmmUserRepository.findOneWithAuthorities(SecurityUtil.getCurrentMemberId());
return repository.findMinUserinfoByUserid(HeaderUtil.getUserId());
}
}
Loading…
Cancel
Save