@@ -0,0 +1,155 @@ | |||||
package com.ffii.lioner.modules.lioner.commonField.entity; | |||||
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.NotNull; | |||||
/** @author Vin Luk */ | |||||
@Entity | |||||
@Table(name = "common_field") | |||||
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) | |||||
public class CommonField extends BaseEntity<Long>{ | |||||
//FNA | |||||
@NotNull | |||||
@Column | |||||
private Long clientId; | |||||
@Column | |||||
private String name; | |||||
@Column | |||||
private String dateOfBirth; | |||||
@Column | |||||
private String idCard; | |||||
@Column | |||||
private String occupation; | |||||
//IDA | |||||
@Column | |||||
private String firstName; | |||||
@Column | |||||
private String givenName; | |||||
@Column | |||||
private String genderMale; | |||||
@Column | |||||
private String genderFemale; | |||||
@Column | |||||
private String ddDateOfBirth; | |||||
@Column | |||||
private String mmDateOfBirth; | |||||
@Column | |||||
private String yyyyDateOfBirth; | |||||
public Long getClientId() { | |||||
return clientId; | |||||
} | |||||
public void setClientId(Long clientId) { | |||||
this.clientId = clientId; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
public String getDateOfBirth() { | |||||
return dateOfBirth; | |||||
} | |||||
public void setDateOfBirth(String dateOfBirth) { | |||||
this.dateOfBirth = dateOfBirth; | |||||
} | |||||
public String getIdCard() { | |||||
return idCard; | |||||
} | |||||
public void setIdCard(String idCard) { | |||||
this.idCard = idCard; | |||||
} | |||||
public String getOccupation() { | |||||
return occupation; | |||||
} | |||||
public void setOccupation(String occupation) { | |||||
this.occupation = occupation; | |||||
} | |||||
public String getFirstName() { | |||||
return firstName; | |||||
} | |||||
public void setFirstName(String firstName) { | |||||
this.firstName = firstName; | |||||
} | |||||
public String getGivenName() { | |||||
return givenName; | |||||
} | |||||
public void setGivenName(String givenName) { | |||||
this.givenName = givenName; | |||||
} | |||||
public String getGenderMale() { | |||||
return genderMale; | |||||
} | |||||
public void setGenderMale(String genderMale) { | |||||
this.genderMale = genderMale; | |||||
} | |||||
public String getGenderFemale() { | |||||
return genderFemale; | |||||
} | |||||
public void setGenderFemale(String genderFemale) { | |||||
this.genderFemale = genderFemale; | |||||
} | |||||
public String getDdDateOfBirth() { | |||||
return ddDateOfBirth; | |||||
} | |||||
public void setDdDateOfBirth(String ddDateOfBirth) { | |||||
this.ddDateOfBirth = ddDateOfBirth; | |||||
} | |||||
public String getMmDateOfBirth() { | |||||
return mmDateOfBirth; | |||||
} | |||||
public void setMmDateOfBirth(String mmDateOfBirth) { | |||||
this.mmDateOfBirth = mmDateOfBirth; | |||||
} | |||||
public String getYyyyDateOfBirth() { | |||||
return yyyyDateOfBirth; | |||||
} | |||||
public void setYyyyDateOfBirth(String yyyyDateOfBirth) { | |||||
this.yyyyDateOfBirth = yyyyDateOfBirth; | |||||
} | |||||
} | |||||
@@ -0,0 +1,6 @@ | |||||
package com.ffii.lioner.modules.lioner.commonField.entity; | |||||
import com.ffii.core.support.AbstractRepository; | |||||
public interface CommonFieldRepository extends AbstractRepository<CommonField, Long> { | |||||
} |
@@ -0,0 +1,138 @@ | |||||
package com.ffii.lioner.modules.lioner.commonField.req; | |||||
import java.util.List; | |||||
import jakarta.validation.constraints.Size; | |||||
import java.time.LocalDate; | |||||
public class UpdateCommonFieldReq { | |||||
private Long id; | |||||
@Size(max = 500) | |||||
String fullname; | |||||
@Size(max = 255) | |||||
String lastname; | |||||
@Size(max = 255) | |||||
String firstname; | |||||
@Size(max = 50) | |||||
String title; | |||||
@Size(max = 500) | |||||
String email; | |||||
@Size(max = 50) | |||||
String phone1; | |||||
@Size(max = 50) | |||||
String phone2; | |||||
String remarks; | |||||
LocalDate joinDate; | |||||
Integer caseManagerId; | |||||
Integer consultantId; | |||||
public Long getId() { | |||||
return id; | |||||
} | |||||
public void setId(Long id) { | |||||
this.id = id; | |||||
} | |||||
public String getFullname() { | |||||
return fullname; | |||||
} | |||||
public void setFullname(String fullname) { | |||||
this.fullname = fullname; | |||||
} | |||||
public String getLastname() { | |||||
return lastname; | |||||
} | |||||
public void setLastname(String lastname) { | |||||
this.lastname = lastname; | |||||
} | |||||
public String getFirstname() { | |||||
return firstname; | |||||
} | |||||
public void setFirstname(String firstname) { | |||||
this.firstname = firstname; | |||||
} | |||||
public String getTitle() { | |||||
return title; | |||||
} | |||||
public void setTitle(String title) { | |||||
this.title = title; | |||||
} | |||||
public String getEmail() { | |||||
return email; | |||||
} | |||||
public void setEmail(String email) { | |||||
this.email = email; | |||||
} | |||||
public String getPhone1() { | |||||
return phone1; | |||||
} | |||||
public void setPhone1(String phone1) { | |||||
this.phone1 = phone1; | |||||
} | |||||
public String getPhone2() { | |||||
return phone2; | |||||
} | |||||
public void setPhone2(String phone2) { | |||||
this.phone2 = phone2; | |||||
} | |||||
public String getRemarks() { | |||||
return remarks; | |||||
} | |||||
public void setRemarks(String remarks) { | |||||
this.remarks = remarks; | |||||
} | |||||
public LocalDate getJoinDate() { | |||||
return joinDate; | |||||
} | |||||
public void setJoinDate(LocalDate joinDate) { | |||||
this.joinDate = joinDate; | |||||
} | |||||
public Integer getCaseManagerId() { | |||||
return caseManagerId; | |||||
} | |||||
public void setCaseManagerId(Integer caseManagerId) { | |||||
this.caseManagerId = caseManagerId; | |||||
} | |||||
public Integer getConsultantId() { | |||||
return consultantId; | |||||
} | |||||
public void setConsultantId(Integer consultantId) { | |||||
this.consultantId = consultantId; | |||||
} | |||||
} |
@@ -0,0 +1,155 @@ | |||||
package com.ffii.lioner.modules.lioner.commonField.service; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import org.springframework.stereotype.Service; | |||||
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.commonField.entity.CommonField; | |||||
import com.ffii.lioner.modules.lioner.commonField.entity.CommonFieldRepository; | |||||
import com.ffii.lioner.modules.lioner.commonField.req.UpdateCommonFieldReq; | |||||
@Service | |||||
public class CommonFieldService extends AbstractBaseEntityService<CommonField, Long, CommonFieldRepository> { | |||||
private AuditLogService auditLogService; | |||||
public CommonFieldService(JdbcDao jdbcDao, CommonFieldRepository repository, AuditLogService auditLogService) { | |||||
super(jdbcDao, repository); | |||||
this.auditLogService = auditLogService; | |||||
} | |||||
public Map<String,Object> getAuditLogObject(Map<String,Object> req){ | |||||
StringBuilder sql = new StringBuilder("SELECT" | |||||
+ " e.id, " | |||||
+ " e.created, " | |||||
+ " e.createdBy AS createdById, " | |||||
+ " u1.name AS createdBy, " | |||||
+ " e.version, " | |||||
+ " e.modified, " | |||||
+ " e.modifiedBy AS modifiedById, " | |||||
+ " e.deleted, " | |||||
+ " u2.name AS modifiedBy, " | |||||
+ " e.name, " | |||||
+ " e.nameCht, " | |||||
+ " e.description, " | |||||
+ " e.region, " | |||||
+ " e.organization, " | |||||
+ " e.eventType, " | |||||
+ " e.frequency, " | |||||
+ " e.series, " | |||||
+ " e.startDate, " | |||||
+ " e.eventFrom, " | |||||
+ " e.eventTo, " | |||||
+ " e.applicationDeadline, " | |||||
+ " e.nextApplicationDate, " | |||||
+ " e.announcementDate, " | |||||
+ " e.awardDate, " | |||||
+ " e.reminderFlag, " | |||||
+ " e.reminderThreshold, " | |||||
+ " e.reminderInterval, " | |||||
+ " e.reminderLimit " | |||||
+ " FROM event e " | |||||
+ " LEFT JOIN `user` u1 ON u1.id = e.createdBy " | |||||
+ " LEFT JOIN `user` u2 ON u2.id = e.modifiedBy " | |||||
+ " WHERE e.id = :id " | |||||
); | |||||
return jdbcDao.queryForMap(sql.toString(), req).get(); | |||||
} | |||||
public List<Map<String,Object>> list(Map<String, Object> args){ | |||||
StringBuilder sql = new StringBuilder("SELECT" | |||||
+ " common_field.* " | |||||
+ " FROM common_field " | |||||
+ " WHERE deleted = FALSE " | |||||
// StringBuilder sql = new StringBuilder("SELECT" | |||||
// + " DISTINCT e.id, " | |||||
// + " e.name AS name, " | |||||
// + " e.applicationDeadline, " | |||||
// + " e.startDate, " | |||||
// + " e.eventFrom " | |||||
// + " FROM event e " | |||||
// + " LEFT JOIN event_sub_division esd ON e.id = esd.eventId " | |||||
// + " LEFT JOIN sub_division sd ON esd.subDivisionId = sd.id " | |||||
// + " LEFT JOIN division d ON d.id = sd.divisionId " | |||||
// + " LEFT JOIN `user` u ON u.id = e.createdBy " | |||||
// + " WHERE e.deleted = FALSE " | |||||
// + " AND esd.deleted = FALSE " | |||||
); | |||||
if (args != null) { | |||||
if (args.containsKey("fullname")) | |||||
sql.append(" AND fullname LIKE :fullname "); | |||||
if (args.containsKey("lastname")) | |||||
sql.append(" AND lastname LIKE :lastname "); | |||||
if (args.containsKey("firstname")) | |||||
sql.append(" AND firstname LIKE :firstname "); | |||||
if (args.containsKey("phone1")) | |||||
sql.append(" AND phone1 LIKE :phone1 "); | |||||
if (args.containsKey("phone2")) | |||||
sql.append(" AND phone2 LIKE :phone2 "); | |||||
if (args.containsKey("email")) | |||||
sql.append(" AND email LIKE :email "); | |||||
if (args.containsKey("remarks")) | |||||
sql.append(" AND remarks LIKE :remarks "); | |||||
if (args.containsKey("joinDateFrom")) | |||||
sql.append(" AND joinDate >= :joinDateFrom "); | |||||
if (args.containsKey("joinDateTo")) | |||||
sql.append(" AND joinDate <= :joinDateTo "); | |||||
// if (args.containsKey("type")) | |||||
// sql.append(" AND eventType LIKE :type "); | |||||
// if (args.containsKey("divisionIdList")) | |||||
// sql.append(" AND sd.divisionId IN (:divisionIdList) "); | |||||
// if (args.containsKey("subDivisionIdList")) | |||||
// sql.append(" AND sd.id IN (:subDivisionIdList) "); | |||||
// if (args.containsKey("keyword")){ | |||||
// sql.append(" AND ( createdBy LIKE :keyword "); | |||||
// sql.append(" OR u.username LIKE :keyword "); | |||||
// sql.append(" OR u.fullname LIKE :keyword "); | |||||
// sql.append(" OR u.email LIKE :keyword "); | |||||
// sql.append(" OR sd.name LIKE :keyword "); | |||||
// sql.append(" OR d.name LIKE :keyword "); | |||||
// sql.append(" OR e.name LIKE :keyword) "); | |||||
} | |||||
// } | |||||
// sql.append(" ORDER BY id desc "); | |||||
return jdbcDao.queryForList(sql.toString(), args); | |||||
} | |||||
public Integer getIdByName(String name) { | |||||
StringBuilder sql = new StringBuilder("SELECT" | |||||
+ " e.id " | |||||
+ " FROM event e " | |||||
+ " WHERE e.deleted = FALSE" | |||||
+ " AND e.name = :name " | |||||
); | |||||
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); | |||||
} | |||||
public Map<String, Object> saveOrUpdate(UpdateCommonFieldReq req) { | |||||
CommonField instance; | |||||
// List<SubDivision> onUsingIdList = new ArrayList<SubDivision>(); | |||||
if(req.getId()>0){ | |||||
instance = find(req.getId()).get(); | |||||
// onUsingIdList = this.getSelectedSubDivisionList(req.getId()); | |||||
} | |||||
else{ | |||||
instance = new CommonField(); | |||||
} | |||||
BeanUtils.copyProperties(req,instance); | |||||
instance = save(instance); | |||||
return Map.of( | |||||
"id", instance.getId() | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,100 @@ | |||||
package com.ffii.lioner.modules.lioner.commonField.web; | |||||
import java.io.IOException; | |||||
import java.time.LocalDate; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.concurrent.TimeUnit; | |||||
import org.apache.commons.logging.Log; | |||||
import org.apache.commons.logging.LogFactory; | |||||
import org.springframework.core.io.ByteArrayResource; | |||||
import org.springframework.core.io.Resource; | |||||
import org.springframework.http.CacheControl; | |||||
import org.springframework.http.HttpStatus; | |||||
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.DeleteMapping; | |||||
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.RequestParam; | |||||
import org.springframework.web.bind.annotation.ResponseStatus; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import com.ffii.lioner.modules.lioner.commonField.req.UpdateCommonFieldReq; | |||||
import com.ffii.lioner.modules.lioner.commonField.service.CommonFieldService; | |||||
import aj.org.objectweb.asm.Type; | |||||
import com.ffii.lioner.modules.common.service.ExcelReportService; | |||||
import com.ffii.core.exception.NotFoundException; | |||||
import com.ffii.core.response.DataRes; | |||||
import com.ffii.core.response.RecordsRes; | |||||
import com.ffii.core.utils.CriteriaArgsBuilder; | |||||
import com.ffii.core.utils.Params; | |||||
import jakarta.servlet.http.HttpServletRequest; | |||||
import jakarta.validation.Valid; | |||||
@RestController | |||||
@RequestMapping("/commonField") | |||||
public class CommonFieldController{ | |||||
private final Log logger = LogFactory.getLog(getClass()); | |||||
private CommonFieldService commonFieldService; | |||||
private ExcelReportService excelReportService; | |||||
public CommonFieldController(CommonFieldService commonFieldService, ExcelReportService excelReportService) { | |||||
this.commonFieldService = commonFieldService; | |||||
this.excelReportService = excelReportService; | |||||
} | |||||
@GetMapping("/{id}") | |||||
public Map<String, Object> get(@PathVariable Long id) { | |||||
return Map.of( | |||||
Params.DATA, commonFieldService.find(id).orElseThrow(NotFoundException::new) | |||||
// "eventDivision", commonFieldService.getEventDivision(Map.of("id",id)) | |||||
); | |||||
} | |||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class, readOnly = false) | |||||
@PostMapping("/save") | |||||
public Map<String, Object> saveOrUpdate(@RequestBody @Valid UpdateCommonFieldReq req) { | |||||
return Map.of( | |||||
Params.DATA,commonFieldService.saveOrUpdate(req) | |||||
); | |||||
} | |||||
@Transactional(isolation = Isolation.SERIALIZABLE, rollbackFor = Exception.class, readOnly = false) | |||||
@DeleteMapping("/{id}") | |||||
@ResponseStatus(HttpStatus.NO_CONTENT) | |||||
public void delete(@PathVariable Long id) { | |||||
commonFieldService.markDelete(commonFieldService.find(id).get()); | |||||
// commonFieldService.markDeleteWithAuditLog(commonFieldService.find(id).get()); | |||||
} | |||||
@GetMapping | |||||
public RecordsRes<Map<String, Object>> list(HttpServletRequest request) throws ServletRequestBindingException { | |||||
return new RecordsRes<>(commonFieldService.list( | |||||
CriteriaArgsBuilder.withRequest(request) | |||||
.addStringLike("fullname") | |||||
.addStringLike("lastname") | |||||
.addStringLike("firstname") | |||||
// .addStringLike("title") | |||||
.addStringLike("email") | |||||
.addStringLike("phone1") | |||||
.addStringLike("phone2") | |||||
.addDate("joinDateFrom") | |||||
.addDate("joinDateTo") | |||||
.addStringLike("remarks") | |||||
.build())); | |||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
server: | |||||
servlet: | |||||
contextPath: /api | |||||
encoding: | |||||
charset: UTF-8 | |||||
enabled: true | |||||
force: true | |||||
port: 8090 | |||||
error: | |||||
include-message: always | |||||
tomcat: | |||||
connection-timeout: 300000 | |||||
ssl: # <--- This 'ssl' is correctly indented under 'server' | |||||
enabled: true # <--- CORRECTED: Use colon, not equals, and remove "server.ssl." prefix | |||||
key-store: classpath:keystore.p12 | |||||
key-store-type: PKCS12 | |||||
key-store-password: Mms1234 | |||||
key-alias: lionerapp | |||||
key-password: Mms1234 | |||||
spring: | |||||
datasource: | |||||
jdbc-url: jdbc:mysql://localhost:3306/lionerdb?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8 | |||||
username: root | |||||
password: cFDp7988vc+$] | |||||
servlet: | |||||
multipart: | |||||
max-file-size: 500MB | |||||
max-request-size: 600MB | |||||
jpa: | |||||
hibernate: | |||||
naming: | |||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl | |||||
database-platform: org.hibernate.dialect.MySQL8Dialect | |||||
properties: | |||||
hibernate: | |||||
dialect: | |||||
storage_engine: innodb | |||||
messages: | |||||
basename: i18n/messages | |||||
use-code-as-default-message: true | |||||
fallback-to-system-locale: false | |||||
logging: | |||||
config: 'classpath:log4j2.yml' |
@@ -11,7 +11,7 @@ server: | |||||
tomcat: | tomcat: | ||||
connection-timeout: 300000 | connection-timeout: 300000 | ||||
ssl: # <--- This 'ssl' is correctly indented under 'server' | ssl: # <--- This 'ssl' is correctly indented under 'server' | ||||
enabled: true # <--- CORRECTED: Use colon, not equals, and remove "server.ssl." prefix | |||||
enabled: false # <--- CORRECTED: Use colon, not equals, and remove "server.ssl." prefix | |||||
key-store: classpath:keystore.p12 | key-store: classpath:keystore.p12 | ||||
key-store-type: PKCS12 | key-store-type: PKCS12 | ||||
key-store-password: Mms1234 | key-store-password: Mms1234 | ||||
@@ -0,0 +1,28 @@ | |||||
--liquibase formatted sql | |||||
--changeset Vin:add cliecommon_fieldnt table | |||||
CREATE TABLE `common_field` ( | |||||
`id` int(11) NOT NULL AUTO_INCREMENT, | |||||
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`createdBy` varchar(30) DEFAULT NULL, | |||||
`version` int NOT NULL DEFAULT '0', | |||||
`modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||||
`modifiedBy` varchar(30) DEFAULT NULL, | |||||
`deleted` tinyint(1) NOT NULL DEFAULT '0', | |||||
`clientId` bigint NOT NULL, | |||||
`name` VARCHAR(200), | |||||
`dateOfBirth` VARCHAR(200), | |||||
`idCard` VARCHAR(100), | |||||
`occupation` VARCHAR(100), | |||||
`firstName` VARCHAR(100), | |||||
`givenName` VARCHAR(100), | |||||
`genderMale` VARCHAR(30), | |||||
`genderFemale` VARCHAR(30), | |||||
`ddDateOfBirth` VARCHAR(10), | |||||
`mmDateOfBirth` VARCHAR(10), | |||||
`yyyyDateOfBirth` VARCHAR(10), | |||||
PRIMARY KEY (`id`) | |||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |