동기화
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.ga.common.code;
|
||||
|
||||
import com.ga.common.annotation.RequirePermission;
|
||||
import com.ga.common.model.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "계정코드")
|
||||
@RestController
|
||||
@RequestMapping("/api/common/account-codes")
|
||||
@RequiredArgsConstructor
|
||||
public class AccountCodeController {
|
||||
|
||||
private final AccountCodeService service;
|
||||
|
||||
/** 활성 계정코드 목록 — 드롭다운/배치 참조용. accountType 파라미터로 DEBIT/CREDIT/BOTH 필터 가능 */
|
||||
@GetMapping
|
||||
public ApiResponse<List<AccountCodeVO>> getActiveCodes(
|
||||
@RequestParam(required = false) String accountType) {
|
||||
return ApiResponse.ok(service.getActiveCodes(accountType));
|
||||
}
|
||||
|
||||
// ----- 시스템관리 -----
|
||||
|
||||
@GetMapping("/all")
|
||||
@RequirePermission(menu = "SYSTEM_CODE", perm = "READ")
|
||||
public ApiResponse<List<AccountCodeVO>> listAll(
|
||||
@RequestParam(required = false) String accountType) {
|
||||
return ApiResponse.ok(service.listAll(accountType));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@RequirePermission(menu = "SYSTEM_CODE", perm = "CREATE")
|
||||
public ApiResponse<Void> create(@RequestBody AccountCodeVO vo) {
|
||||
service.create(vo);
|
||||
return ApiResponse.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/{accountCode}")
|
||||
@RequirePermission(menu = "SYSTEM_CODE", perm = "UPDATE")
|
||||
public ApiResponse<Void> update(@PathVariable String accountCode, @RequestBody AccountCodeVO vo) {
|
||||
vo.setAccountCode(accountCode);
|
||||
service.update(vo);
|
||||
return ApiResponse.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{accountCode}")
|
||||
@RequirePermission(menu = "SYSTEM_CODE", perm = "DELETE")
|
||||
public ApiResponse<Void> delete(@PathVariable String accountCode) {
|
||||
service.delete(accountCode);
|
||||
return ApiResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ga.common.code;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AccountCodeMapper {
|
||||
|
||||
List<AccountCodeVO> selectAll(@Param("accountType") String accountType);
|
||||
List<AccountCodeVO> selectActive(@Param("accountType") String accountType);
|
||||
AccountCodeVO selectOne(@Param("accountCode") String accountCode);
|
||||
int insert(AccountCodeVO vo);
|
||||
int update(AccountCodeVO vo);
|
||||
int delete(@Param("accountCode") String accountCode);
|
||||
int existsByCode(@Param("accountCode") String accountCode);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ga.common.code;
|
||||
|
||||
import com.ga.common.exception.BizException;
|
||||
import com.ga.common.exception.ErrorCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AccountCodeService {
|
||||
|
||||
private final AccountCodeMapper mapper;
|
||||
|
||||
public List<AccountCodeVO> getActiveCodes(String accountType) {
|
||||
return mapper.selectActive(accountType);
|
||||
}
|
||||
|
||||
public AccountCodeVO getCode(String accountCode) {
|
||||
AccountCodeVO vo = mapper.selectOne(accountCode);
|
||||
if (vo == null) throw new BizException(ErrorCode.NOT_FOUND);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public List<AccountCodeVO> listAll(String accountType) {
|
||||
return mapper.selectAll(accountType);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void create(AccountCodeVO vo) {
|
||||
if (mapper.existsByCode(vo.getAccountCode()) > 0) {
|
||||
throw new BizException(ErrorCode.DUPLICATE_DATA);
|
||||
}
|
||||
mapper.insert(vo);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void update(AccountCodeVO vo) {
|
||||
getCode(vo.getAccountCode());
|
||||
mapper.update(vo);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void delete(String accountCode) {
|
||||
getCode(accountCode);
|
||||
mapper.delete(accountCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ga.common.code;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AccountCodeVO {
|
||||
private String accountCode;
|
||||
private String accountName;
|
||||
private String accountType; // DEBIT / CREDIT / BOTH
|
||||
private String isActive;
|
||||
private Integer sortOrder;
|
||||
private String description;
|
||||
private LocalDateTime createdAt;
|
||||
private Long createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private Long updatedBy;
|
||||
}
|
||||
Reference in New Issue
Block a user