| @@ -0,0 +1,53 @@ | |||
| package com.ffii.tsms.modules.data.service | |||
| import com.ffii.core.support.AbstractBaseEntityService | |||
| import com.ffii.core.support.JdbcDao | |||
| import com.ffii.tsms.modules.data.entity.Customer | |||
| import com.ffii.tsms.modules.data.entity.CustomerType | |||
| import com.ffii.tsms.modules.data.entity.CustomerRepository | |||
| import com.ffii.tsms.modules.data.entity.CustomerTypeRepository | |||
| import com.ffii.tsms.modules.data.web.models.SaveCustomerResponse | |||
| import com.ffii.tsms.modules.project.web.models.SaveCustomerRequest | |||
| import org.springframework.beans.BeanUtils | |||
| import org.springframework.stereotype.Service | |||
| import java.util.Optional | |||
| @Service | |||
| open class DashboardService( | |||
| private val customerRepository: CustomerRepository, | |||
| private val customerTypeRepository: CustomerTypeRepository, | |||
| private val customerSubsidiaryService: CustomerSubsidiaryService, | |||
| private val customerContactService: CustomerContactService, | |||
| private val jdbcDao: JdbcDao | |||
| ) { | |||
| fun CustomerSubsidiary(args: Map<String, Any>): List<Map<String, Any>> { | |||
| val sql = StringBuilder("select" | |||
| + " c.id as customerId," | |||
| + " c.name as customerName," | |||
| + " c.code as customerCode," | |||
| + " c.address as customerAddress," | |||
| + " c.district as cutomerDistrict," | |||
| + " c.brNo as customerBrNo," | |||
| + " c.typeId as customerTypeId," | |||
| + " s.id as subsidiaryId," | |||
| + " s.name as subsidiaryName," | |||
| + " s.code as subsidiaryCode," | |||
| + " s.address as subsidiaryAddress," | |||
| + " s.district as subsidiaryDistrict," | |||
| + " s.brNo as subsidiaryBrNo," | |||
| + " s.typeId as subsidiaryTypeId" | |||
| + " from customer c" | |||
| + " left join customer_subsidiary cs on c.id = cs.customerId" | |||
| + " left join subsidiary s on cs.subsidiaryId = s.id" | |||
| + " where c.deleted = 0" | |||
| ) | |||
| if (args != null) { | |||
| if (args.containsKey("customerName")) | |||
| sql.append(" AND c.name = :customerName"); | |||
| if (args.containsKey("customerCode")) | |||
| sql.append(" AND c.code = :customerCode"); | |||
| } | |||
| return jdbcDao.queryForList(sql.toString(), args) | |||
| } | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.ffii.tsms.modules.data.web | |||
| import com.ffii.tsms.modules.data.entity.Customer | |||
| import com.ffii.tsms.modules.data.entity.CustomerType | |||
| import com.ffii.tsms.modules.data.service.CustomerContactService | |||
| import com.ffii.tsms.modules.data.service.CustomerService | |||
| import com.ffii.tsms.modules.data.service.CustomerSubsidiaryService | |||
| import com.ffii.tsms.modules.data.service.DashboardService | |||
| import com.ffii.tsms.modules.data.web.models.CustomerResponse | |||
| import com.ffii.tsms.modules.data.web.models.SaveCustomerResponse | |||
| import com.ffii.tsms.modules.project.web.models.SaveCustomerRequest | |||
| import org.springframework.web.bind.annotation.GetMapping | |||
| import org.springframework.web.bind.annotation.RequestMapping | |||
| import org.springframework.web.bind.annotation.RestController | |||
| import org.springframework.web.bind.annotation.RequestBody | |||
| import org.springframework.web.bind.annotation.PostMapping | |||
| import org.springframework.web.bind.annotation.PathVariable | |||
| import jakarta.validation.Valid | |||
| import org.springframework.http.HttpStatus | |||
| import jakarta.servlet.http.HttpServletRequest | |||
| import org.springframework.web.bind.annotation.DeleteMapping | |||
| import org.springframework.web.bind.annotation.ResponseStatus | |||
| import com.ffii.core.response.RecordsRes | |||
| import com.ffii.core.utils.CriteriaArgsBuilder | |||
| @RestController | |||
| @RequestMapping("/dashboard") | |||
| class DashboardController( | |||
| private val customerService: CustomerService, | |||
| private val customerSubsidiaryService: CustomerSubsidiaryService, | |||
| private val customerContactService: CustomerContactService, | |||
| private val dashboardService: DashboardService | |||
| ) { | |||
| @GetMapping("/searchCustomerSubsidiary") | |||
| fun searchCustomerSubsidiary(request: HttpServletRequest?): List<Map<String, Any>> { | |||
| val customerName = request?.getParameter("customerName") | |||
| val customerCode = request?.getParameter("customerCode") | |||
| val args = mutableMapOf<String, Any>() | |||
| if (customerName != null) { | |||
| args["customerName"] = customerName | |||
| } | |||
| if (customerCode != null) { | |||
| args["customerCode"] = customerCode | |||
| } | |||
| return dashboardService.CustomerSubsidiary(args) | |||
| // return dashboardService.CustomerSubsidiary( | |||
| // CriteriaArgsBuilder.withRequest(request) | |||
| // .build() | |||
| // ) | |||
| } | |||
| } | |||