-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat : 부서별 asset 리스트 구현
- Loading branch information
Showing
16 changed files
with
208 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 27 additions & 1 deletion
28
...main/java/com/kbds/itamserveradmin/domain/department/controller/DepartmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
package com.kbds.itamserveradmin.domain.department.controller; | ||
|
||
import com.kbds.itamserveradmin.domain.department.dto.DeptAssetRes; | ||
import com.kbds.itamserveradmin.domain.department.dto.DeptInfoRes; | ||
import com.kbds.itamserveradmin.domain.department.service.DepartmentService; | ||
import com.kbds.itamserveradmin.domain.user.dto.UserInfoRes; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Controller | ||
import java.util.List; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RequestMapping("/kbitam") | ||
@CrossOrigin(origins ="*", allowedHeaders = "*") | ||
public class DepartmentController { | ||
private final DepartmentService departmentService; | ||
|
||
@GetMapping("/dept") | ||
public ResponseEntity<List<DeptInfoRes>> getDeptInfo(@RequestParam("corpName") String corpName) { | ||
return ResponseEntity.ok(departmentService.DeptInfo(corpName)); | ||
} | ||
@GetMapping("/dept/asset") | ||
public ResponseEntity<List<DeptAssetRes>> getDeptAsset(@Param("deptId") String deptId, @Param("userId") String userId){ | ||
return ResponseEntity.ok(departmentService.getDeptAsset(deptId,userId)); | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/kbds/itamserveradmin/domain/department/dto/DeptAssetRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.kbds.itamserveradmin.domain.department.dto; | ||
|
||
import com.kbds.itamserveradmin.domain.assetRequest.entity.RequestStatus; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.coyote.Request; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class DeptAssetRes { | ||
private String AssetName; | ||
private String ContNumOfType; | ||
private String ContPeriodType; | ||
private String ContSupplyType; | ||
private String AssetSpd; | ||
private RequestStatus AssetReqStatus; | ||
private String AssetImgUrl; | ||
private String ContId; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/kbds/itamserveradmin/domain/department/dto/DeptInfoRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.kbds.itamserveradmin.domain.department.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class DeptInfoRes { | ||
private String DeptId; | ||
private String DeptName; | ||
} |
6 changes: 6 additions & 0 deletions
6
...java/com/kbds/itamserveradmin/domain/department/repository/DepartmentAssetRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
package com.kbds.itamserveradmin.domain.department.repository; | ||
|
||
import com.kbds.itamserveradmin.domain.contract.entity.Contract; | ||
import com.kbds.itamserveradmin.domain.department.entity.Department; | ||
import com.kbds.itamserveradmin.domain.department.entity.DepartmentAsset; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface DepartmentAssetRepository extends JpaRepository<DepartmentAsset,String> { | ||
// List<DepartmentAsset> findBy (Iterable<String> strings); | ||
@Query("select da.contract from DepartmentAsset da where da.department =:department") | ||
List<Contract> findContractByDept(@Param("department") Department department); | ||
} |
9 changes: 9 additions & 0 deletions
9
...main/java/com/kbds/itamserveradmin/domain/department/repository/DepartmentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
package com.kbds.itamserveradmin.domain.department.repository; | ||
|
||
import com.kbds.itamserveradmin.domain.corporation.entity.Corporation; | ||
import com.kbds.itamserveradmin.domain.department.dto.DeptInfoRes; | ||
import com.kbds.itamserveradmin.domain.department.entity.Department; | ||
import com.kbds.itamserveradmin.domain.department.entity.DepartmentAsset; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface DepartmentRepository extends JpaRepository<Department,String> { | ||
@Query("select NEW com.kbds.itamserveradmin.domain.department.dto.DeptInfoRes(d.deptId, d.deptName) from Department d where d.corporation =:corporation") | ||
List<DeptInfoRes> findNameByCorp(@Param("corporation") Corporation corporation); | ||
|
||
Department findDepartmentByDeptId(String deptId); | ||
} |
10 changes: 8 additions & 2 deletions
10
src/main/java/com/kbds/itamserveradmin/domain/department/service/DepartmentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package com.kbds.itamserveradmin.domain.department.service; | ||
|
||
import com.kbds.itamserveradmin.domain.department.dto.DeptAssetRes; | ||
import com.kbds.itamserveradmin.domain.department.dto.DeptInfoRes; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class DepartmentService { | ||
import java.util.List; | ||
|
||
|
||
public interface DepartmentService { | ||
public List<DeptInfoRes> DeptInfo(String corpName); | ||
public List<DeptAssetRes> getDeptAsset(String deptId,String userId); | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
src/main/java/com/kbds/itamserveradmin/domain/department/service/DepartmentServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.kbds.itamserveradmin.domain.department.service; | ||
|
||
import com.kbds.itamserveradmin.domain.asset.entity.Asset; | ||
import com.kbds.itamserveradmin.domain.asset.repository.AssetRepository; | ||
import com.kbds.itamserveradmin.domain.assetRequest.entity.AssetRequest; | ||
import com.kbds.itamserveradmin.domain.assetRequest.entity.RequestStatus; | ||
import com.kbds.itamserveradmin.domain.assetRequest.repository.AssetRequestRepository; | ||
import com.kbds.itamserveradmin.domain.contract.entity.Contract; | ||
import com.kbds.itamserveradmin.domain.contract.repository.ContractRepository; | ||
import com.kbds.itamserveradmin.domain.corporation.entity.Corporation; | ||
import com.kbds.itamserveradmin.domain.corporation.repository.CorporationRepository; | ||
import com.kbds.itamserveradmin.domain.department.dto.DeptAssetRes; | ||
import com.kbds.itamserveradmin.domain.department.dto.DeptInfoRes; | ||
import com.kbds.itamserveradmin.domain.department.entity.Department; | ||
import com.kbds.itamserveradmin.domain.department.repository.DepartmentAssetRepository; | ||
import com.kbds.itamserveradmin.domain.department.repository.DepartmentRepository; | ||
import com.kbds.itamserveradmin.domain.user.entity.User; | ||
import com.kbds.itamserveradmin.domain.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Service | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class DepartmentServiceImpl implements DepartmentService{ | ||
|
||
private final DepartmentRepository departmentRepository; | ||
private final CorporationRepository corporationRepository; | ||
private final UserRepository userRepository; | ||
private final DepartmentAssetRepository departmentAssetRepository; | ||
private final AssetRepository assetRepository; | ||
private final AssetRequestRepository assetRequestRepository; | ||
|
||
@Override | ||
public List<DeptInfoRes> DeptInfo(String corpName) { | ||
Corporation corporation = corporationRepository.findCorporationByCorpName(corpName); | ||
List<DeptInfoRes> departList = departmentRepository.findNameByCorp(corporation); | ||
return departList; | ||
} | ||
|
||
@Override | ||
public List<DeptAssetRes> getDeptAsset(String deptId, String userId) { | ||
Department department = departmentRepository.findDepartmentByDeptId(deptId); | ||
List<Contract> ContractList = departmentAssetRepository.findContractByDept(department); | ||
User user = userRepository.findUserByUserId(userId); | ||
|
||
Map<Character, String> supplyTypes = Map.of( | ||
'1', "패키지", | ||
'2', "Low Volume", | ||
'3', "High Volume", | ||
'4', "SaaS" | ||
); | ||
|
||
Map<Character, String> periodTypes = Map.of( | ||
'1', "구독", | ||
'2', "영구" | ||
); | ||
|
||
Map<Character, String> userTypes = Map.of( | ||
'1', "동시 사용자수", | ||
'2', "사이트", | ||
'3', "코어", | ||
'4', "1pc1copy", | ||
'5', "서버접속" | ||
); | ||
|
||
|
||
List<DeptAssetRes> deptAssetResList = new ArrayList<>(); | ||
for(Contract cont : ContractList){ | ||
Asset asset = assetRepository.findAssetByAstId(cont.getAst().getAstId()); | ||
AssetRequest assetRequest = assetRequestRepository.findAssetRequestByContractAndAstRequestUser(cont,user); | ||
|
||
String contLicTag= cont.getContLicTag(); | ||
char supplyChar = contLicTag.charAt(0); | ||
char periodChar = contLicTag.charAt(1); | ||
char userChar = contLicTag.charAt(2); | ||
|
||
if (assetRequest==null){ | ||
DeptAssetRes deptAssetRes = DeptAssetRes.builder(). | ||
AssetName(asset.getAstName()).AssetReqStatus(RequestStatus.NOT_IN_USE).AssetSpd(asset.getAstSpd()).AssetImgUrl(asset.getAstImgUrl()).ContId(cont.getContId()). | ||
ContNumOfType(supplyTypes.get(supplyChar)).ContPeriodType(periodTypes.get(periodChar)).ContSupplyType(userTypes.get(userChar)).build(); | ||
deptAssetResList.add(deptAssetRes); | ||
} | ||
else { | ||
DeptAssetRes deptAssetRes = DeptAssetRes.builder(). | ||
AssetName(asset.getAstName()).AssetReqStatus(assetRequest.getAstReqStatus()).AssetSpd(asset.getAstSpd()).AssetImgUrl(asset.getAstImgUrl()).ContId(cont.getContId()). | ||
ContNumOfType(supplyTypes.get(supplyChar)).ContPeriodType(periodTypes.get(periodChar)).ContSupplyType(userTypes.get(userChar)).build(); | ||
deptAssetResList.add(deptAssetRes); | ||
} | ||
|
||
} | ||
return deptAssetResList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters