[STYLE] serviceの無駄な改行やスペースなどの削除
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployeeInfo {
|
||||
List<EmployeeInfo> selectAll();
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Employee レコード削除関連の機能を持つサービス
|
||||
*/
|
||||
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||
@@ -20,12 +18,6 @@ public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idEmployee を元に employee データを削除
|
||||
*
|
||||
* @param idEmployee 削除対象のidEmployee
|
||||
*/
|
||||
public void deleteEmployee(Integer idEmployee) {
|
||||
employeeRepository.deleteById(idEmployee);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.Login;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* ログイン系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class LoginImpl implements Login {
|
||||
@@ -23,15 +21,7 @@ public class LoginImpl implements Login {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* メールアドレス、パスワードでログイン判定を行う
|
||||
*
|
||||
* @param loginInfo ログインを試みるアカウント
|
||||
* @return loginUser のインスタンス
|
||||
*/
|
||||
public LoginUser doLogin(LoginInfo loginInfo) {
|
||||
// ログイン情報を元にログインユーザーを取得
|
||||
return employeeRepository
|
||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||
.orElse(new EmployeeEntity())
|
||||
@@ -39,14 +29,7 @@ public class LoginImpl implements Login {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* メールアドレス、パスワードでログイン判定を行う
|
||||
*
|
||||
* @param loginInfo ログインを試みるアカウント
|
||||
* @return loginUser のインスタンス
|
||||
*/
|
||||
public boolean canLogin(LoginInfo loginInfo) {
|
||||
// ログイン情報を元にログインユーザーを取得
|
||||
return employeeRepository
|
||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||
.isPresent();
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Employee テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||
@@ -23,11 +20,6 @@ public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* employee インスタンスの内容を登録する
|
||||
*
|
||||
* @param employee 登録対象のデータ
|
||||
*/
|
||||
public void registerEmployee(Employee employee) {
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
||||
}
|
||||
|
||||
@@ -1,82 +1,75 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchDepartmentImpl implements SearchDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署情報を全件取得する
|
||||
*
|
||||
* @return 取得した部署情報レコード全件
|
||||
*/
|
||||
public List<Department> selectAll() {
|
||||
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
.where(DepartmentRepository
|
||||
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository
|
||||
.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
* 部分一致検索
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
.where(DepartmentRepository
|
||||
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository
|
||||
.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Department> searchByDepartmentName(SearchConditionDepartment searchConditionDepartment) {
|
||||
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository
|
||||
.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Department> searchByDepartmentId(SearchConditionDepartment searchConditionDepartment) {
|
||||
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository
|
||||
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee テーブル検索系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchEmployeeImpl implements SearchEmployee {
|
||||
@@ -25,44 +23,19 @@ public class SearchEmployeeImpl implements SearchEmployee {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mailAddress を元に Employee Table を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public List<Employee> searchEmployee(String mailAddress) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* mailAddress を元に ログイン者の情報 を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return login者の情報
|
||||
*/
|
||||
public LoginUser searchLoginUser(String mailAddress) {
|
||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* idEmployee を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idEmployee 検索対象の idEmployee
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||
return EmployeeEntity.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||
return EmployeeEntity
|
||||
.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idDepartment を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idDepartment 部署ID
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
@Override
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SearchEmployeeInfoImpl (employee join department) 検索系の機能を集約させるサービスクラスです
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
@@ -26,27 +24,13 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
this.employeeInfoRepository = employeeInfoRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EmployeeInfo (employee join department) のレコードを全件取得
|
||||
*
|
||||
* @return 取得したレコード全件
|
||||
*/
|
||||
public List<EmployeeInfo> selectAll() {
|
||||
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return 検索結果のレコードリスト
|
||||
*/
|
||||
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return EmployeeDepartmentEntity
|
||||
.createEmployeeInfoList(
|
||||
employeeInfoRepository.findAll(Specification
|
||||
@@ -54,9 +38,8 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||
.and(EmployeeInfoRepository.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))
|
||||
)
|
||||
);
|
||||
.and(EmployeeInfoRepository
|
||||
.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* employee の更新系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
@@ -22,29 +20,13 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* employee の情報を元に employee table のレコードを更新する
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新後のデータ
|
||||
*/
|
||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新前のデータと更新対象のデータをマージする
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新対象のデータ
|
||||
* @return マージしたデータ
|
||||
*/
|
||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
||||
return new Employee(
|
||||
updateEmployee.getIdEmployee(),
|
||||
updateEmployee.getNmEmployee(),
|
||||
@@ -52,8 +34,8 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
updateEmployee.getMailAddress(),
|
||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment() : updateEmployee.getIdDepartment()
|
||||
);
|
||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment()
|
||||
: updateEmployee.getIdDepartment());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user