| @@ -50,6 +50,9 @@ public class Client extends BaseEntity<Long>{ | |||
| @Column | |||
| private LocalDate dob; | |||
| @Column | |||
| private Integer consultantId; | |||
| public String getClientCode() { | |||
| @@ -132,5 +135,12 @@ public class Client extends BaseEntity<Long>{ | |||
| this.dob = dob; | |||
| } | |||
| public Integer getConsultantId() { | |||
| return consultantId; | |||
| } | |||
| public void setConsultantId(Integer consultantId) { | |||
| this.consultantId = consultantId; | |||
| } | |||
| } | |||
| @@ -134,7 +134,7 @@ public class CommonFieldService extends AbstractBaseEntityService<CommonField, L | |||
| } | |||
| public Long getByClientId(long clientId){ | |||
| Long id = getIdByClientId(clientId); | |||
| Long id = getIdByClientId(clientId); | |||
| return id; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.ffii.lioner.modules.lioner.pdf.entity; | |||
| import java.time.LocalDate; | |||
| import java.time.LocalDateTime; | |||
| import com.ffii.core.entity.BaseEntity; | |||
| import jakarta.persistence.Column; | |||
| import jakarta.persistence.Entity; | |||
| import jakarta.persistence.Inheritance; | |||
| import jakarta.persistence.InheritanceType; | |||
| import jakarta.persistence.Table; | |||
| import jakarta.validation.constraints.NotBlank; | |||
| import jakarta.validation.constraints.NotNull; | |||
| @Entity | |||
| @Table(name = "consultant") | |||
| @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) | |||
| public class Consultant extends BaseEntity<Long>{ | |||
| @NotNull | |||
| @Column | |||
| private String name; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| package com.ffii.lioner.modules.lioner.pdf.entity; | |||
| import java.util.List; | |||
| import com.ffii.core.support.AbstractRepository; | |||
| public interface ConsultantRepository extends AbstractRepository<Consultant, Long> { | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.ffii.lioner.modules.lioner.pdf.req; | |||
| public class UpdateConsultantReq { | |||
| private Long id; | |||
| private String name; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,85 @@ | |||
| package com.ffii.lioner.modules.lioner.pdf.service; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import org.springframework.stereotype.Service; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.ffii.core.exception.NotFoundException; | |||
| import com.ffii.core.exception.UnprocessableEntityException; | |||
| import com.ffii.core.support.AbstractBaseEntityService; | |||
| import com.ffii.core.support.JdbcDao; | |||
| import com.ffii.core.utils.BeanUtils; | |||
| import com.ffii.lioner.modules.common.service.AuditLogService; | |||
| import com.ffii.lioner.modules.lioner.pdf.entity.Consultant; | |||
| import com.ffii.lioner.modules.lioner.pdf.req.UpdateConsultantReq; | |||
| import com.ffii.lioner.modules.lioner.pdf.entity.ConsultantRepository; | |||
| @Service | |||
| public class ConsultantService extends AbstractBaseEntityService<Consultant, Long, ConsultantRepository> { | |||
| private AuditLogService auditLogService; | |||
| public ConsultantService(JdbcDao jdbcDao, ConsultantRepository repository, AuditLogService auditLogService) { | |||
| super(jdbcDao, repository); | |||
| this.auditLogService = auditLogService; | |||
| } | |||
| public Map<String, Object> saveOrUpdate(UpdateConsultantReq req) { | |||
| Consultant instance; | |||
| // List<SubDivision> onUsingIdList = new ArrayList<SubDivision>(); | |||
| if(req.getId() == null) | |||
| req.setId(-1L); | |||
| if (req.getId() > 0){ | |||
| instance = find(req.getId()).get(); | |||
| // onUsingIdList = this.getSelectedSubDivisionList(req.getId()); | |||
| } | |||
| else { | |||
| instance = new Consultant(); | |||
| } | |||
| BeanUtils.copyProperties(req,instance); | |||
| instance = save(instance); | |||
| return Map.of( | |||
| "id", instance.getId() | |||
| ); | |||
| } | |||
| public List<Map<String,Object>> list(Map<String, Object> args){ | |||
| StringBuilder sql = new StringBuilder("SELECT" | |||
| + " c.id, " | |||
| + " c.name, " | |||
| + " c.created, " | |||
| + " c.modified " | |||
| + " FROM consultant c " | |||
| + " WHERE c.deleted = FALSE " | |||
| ); | |||
| if (args != null) { | |||
| if (args.containsKey("name")) | |||
| sql.append(" AND c.name LIKE :name "); | |||
| if (args.containsKey("createDateFrom")) | |||
| sql.append(" AND c.created >= :createDateFrom "); | |||
| if (args.containsKey("createDateTo")) | |||
| sql.append(" AND c.created <= :createDateTo "); | |||
| } | |||
| sql.append(" ORDER BY c.id asc "); | |||
| return jdbcDao.queryForList(sql.toString(), args); | |||
| } | |||
| public Map<String, Object> loadConsultant(Long id) { | |||
| String sql = "SELECT" | |||
| + " c.id, " | |||
| + " c.name " | |||
| + " FROM consultant c " | |||
| + " WHERE c.deleted = FALSE " | |||
| + " AND c.id = :id " | |||
| ; | |||
| return jdbcDao.queryForMap(sql, Map.of("id", id)).orElseThrow(NotFoundException::new); | |||
| } | |||
| } | |||
| @@ -445,7 +445,6 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "part2_1a_amount", commonField.getFna_b1_a_amount()); | |||
| setValueIfPresent(form, "part2_1c_amount", commonField.getFna_b1_d_amount()); | |||
| setValueIfPresent(form, "part2_1e_desc", commonField.getFna_b1_b()); | |||
| setValueIfPresent(form, "part2_1f_desc", commonField.getFna_b1_f_other()); | |||
| /* Page1 End */ | |||
| /* Page2 Start */ | |||
| @@ -470,6 +469,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form, "address2", commonField.getAddress2()); | |||
| setValueIfPresent(form, "contact", commonField.getContactNo()); | |||
| setValueIfPresent(form, "email", commonField.getEmail()); | |||
| setValueIfPresent(form, "occupation", commonField.getOccupation()); | |||
| setValueIfPresent(form, "1amount", commonField.getFna_b1_d_amount()); | |||
| setValueIfPresent(form, "cb1f", commonField.getFna_b1_f_other()); | |||
| @@ -548,7 +548,13 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| //only do for check box | |||
| if ("Btn".equals(sourceField.getFieldType()) || "Ch".equals(sourceField.getFieldType()) | |||
| && targetField != null && sourceFieldValue != null) { | |||
| targetField.setValue(sourceFieldValue); | |||
| try{ | |||
| targetField.setValue(sourceFieldValue); | |||
| }catch (Exception e){ | |||
| logger.info("sourceFieldName error:" + sourceFieldName); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -711,7 +717,8 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| setValueIfPresent(form2, "part2_1d_1", commonField.getFna_b1b_1()); | |||
| setValueIfPresent(form2, "part2_1d_2", commonField.getFna_b1b_2()); | |||
| setValueIfPresent(form2, "part2_1d_3", commonField.getFna_b1b_3()); | |||
| setValueIfPresent(form2, "part2_1e", commonField.getFna_b1_b()); | |||
| setValueIfPresent(form2, "part2_1f", commonField.getFna_b1_f()); | |||
| setValueIfPresent(form2, "part2_2_a", commonField.getFna_b2_a()); | |||
| @@ -1259,7 +1266,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito | |||
| case "part2_1d_2" -> commonField.setFna_b1b_2(fieldValue); | |||
| case "part2_1d_3" -> commonField.setFna_b1b_3(fieldValue); | |||
| case "part2_1e_desc" -> commonField.setFna_b1_b(fieldValue); | |||
| case "part2_1e" -> commonField.setFna_b1_b(fieldValue); | |||
| case "part2_1f" -> commonField.setFna_b1_f(fieldValue); | |||
| case "part2_1f_desc" -> commonField.setFna_b1_f_other(fieldValue); | |||
| @@ -0,0 +1,84 @@ | |||
| package com.ffii.lioner.modules.lioner.pdf.web; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.transaction.annotation.Isolation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.web.bind.ServletRequestBindingException; | |||
| import org.springframework.web.bind.annotation.CrossOrigin; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import com.ffii.core.response.RecordsRes; | |||
| import com.ffii.core.utils.CriteriaArgsBuilder; | |||
| import com.ffii.core.utils.Params; | |||
| import com.ffii.lioner.modules.lioner.client.req.UpdateClientReq; | |||
| import com.ffii.lioner.modules.lioner.pdf.req.UpdateConsultantReq; | |||
| import com.ffii.lioner.modules.lioner.pdf.service.ConsultantService; | |||
| import jakarta.servlet.http.HttpServletRequest; | |||
| import jakarta.validation.Valid; | |||
| @RestController | |||
| @RequestMapping("/consultant") | |||
| @CrossOrigin(origins = "", allowedHeaders = "") | |||
| public class ConsultantController { | |||
| private ConsultantService consultantService; | |||
| private static final Logger logger = LoggerFactory.getLogger(ConsultantController.class); | |||
| public ConsultantController(ConsultantService consultantService) { | |||
| this.consultantService = consultantService; | |||
| } | |||
| // @GetMapping("/{id}") | |||
| // public List<Map<String, Object>> get(@PathVariable Long id) { | |||
| // return Map.of( | |||
| // Params.DATA, consultantService.findByConsultantId(id).orElseThrow(NotFoundException::new) | |||
| // ); | |||
| // } | |||
| @GetMapping | |||
| public RecordsRes<Map<String, Object>> list(HttpServletRequest request) throws ServletRequestBindingException { | |||
| return new RecordsRes<>(consultantService.list( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .addStringLike("name") | |||
| .addDate("createDateFrom") | |||
| .addDate("createDateTo") | |||
| .addStringLike("remarks") | |||
| .build())); | |||
| } | |||
| @GetMapping("/{id}") | |||
| public Map<String, Object> get(@PathVariable Long id) { | |||
| return consultantService.loadConsultant(id); | |||
| } | |||
| @Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class, readOnly = false) | |||
| @PostMapping("/save") | |||
| public Map<String, Object> saveOrUpdate(@RequestBody @Valid UpdateConsultantReq req) { | |||
| logger.info("saveOrUpdate"); | |||
| return Map.of( | |||
| Params.DATA,consultantService.saveOrUpdate(req) | |||
| ); | |||
| } | |||
| @GetMapping("/combo") | |||
| public RecordsRes<Map<String, Object>> getCombo(HttpServletRequest request) throws ServletRequestBindingException { | |||
| return new RecordsRes<>(consultantService.list( | |||
| CriteriaArgsBuilder.withRequest(request) | |||
| .build())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| --liquibase formatted sql | |||
| --changeset vin:add consultant table | |||
| CREATE TABLE `consultant` ( | |||
| `id` int NOT NULL AUTO_INCREMENT, | |||
| `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||
| `createdBy` int DEFAULT NULL, | |||
| `version` int NOT NULL DEFAULT '0', | |||
| `modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||
| `modifiedBy` int DEFAULT NULL, | |||
| `deleted` tinyint(1) NOT NULL DEFAULT '0', | |||
| `name` VARCHAR(500) NOT NULL, | |||
| PRIMARY KEY (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |||