Skip to content

Commit ada0573

Browse files
committed
creating and implementing the business logic in Service
1 parent 6ecd9f1 commit ada0573

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

government-service/src/main/java/com/csaba79coder/bestprotocol/model/representative/service/RepresentativeService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.csaba79coder.bestprotocol.model.representative.service;
22

3+
import com.csaba79coder.bestprotocol.model.representative.entity.Representative;
34
import com.csaba79coder.bestprotocol.model.representative.persistence.RepresentativeRepository;
45
import com.csaba79coder.bestprotocol.util.mapper.Mapper;
5-
import com.csaba79coder.model.NewRepresentativeModel;
66
import com.csaba79coder.model.RepresentativeModel;
77
import lombok.RequiredArgsConstructor;
88
import org.springframework.stereotype.Service;
9+
import org.springframework.web.multipart.MultipartFile;
910

1011
import java.util.List;
1112
import java.util.stream.Collectors;
@@ -16,8 +17,10 @@ public class RepresentativeService {
1617

1718
private final RepresentativeRepository representativeRepository;
1819

19-
public RepresentativeModel addNewRepresentative(NewRepresentativeModel body) {
20-
return Mapper.mapRepresentativeEntityToModel(representativeRepository.save(Mapper.mapNewRepresentativeModelToEntity(body)));
20+
public RepresentativeModel addNewRepresentative(String name, String jobTitle, String address, String phoneNumber, String email, MultipartFile image, String note) {
21+
Representative entity = new Representative();
22+
entity = Mapper.mapFieldIntoEntity(name, jobTitle, address, phoneNumber, email, image, note);
23+
return Mapper.mapRepresentativeEntityToModel(representativeRepository.save(entity));
2124
}
2225

2326
public List<RepresentativeModel> renderAllRepresentatives() {

0 commit comments

Comments
 (0)