Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.sls.bo.salesorderext;
- import java.util.List;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.util.ValidationUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.jleaf.erp.sls.entity.SoExt;
- import org.jleaf.erp.sls.dao.SoExtDao;
- import org.jleaf.erp.sls.SalesExceptionConstants;
- /**
- * Find SoExt by index
- * @author Sts, Mar 26, 2021
- * @version 1.0
- */
- @Service
- @InfoIn(value = {
- @Info(name = "soId", description = "So id", type = Long.class, required = true)
- })
- @InfoOut(value = {
- @Info(name = "id", description = "Id", type = Long.class, required = true),
- @Info(name = "tenantId", description = "Tenant id", type = Long.class, required = true),
- @Info(name = "soId", description = "So id", type = Long.class, required = true),
- @Info(name = "flagDropship", description = "Flag dropship", type = String.class, required = true),
- @Info(name = "createUserId", description = "Create user id", type = Long.class, required = true),
- @Info(name = "createDateTime", description = "Create date time", type = String.class, required = true),
- @Info(name = "updateUserId", description = "Update user id", type = Long.class, required = true),
- @Info(name = "updateDateTime", description = "Update date time", type = String.class, required = true),
- @Info(name = "version", description = "Version", type = Long.class, required = true)
- })
- @ErrorList(errorKeys = {
- SalesExceptionConstants.SO_EXT_NOT_FOUND
- })
- public class FindSoExtByIndex extends AbstractBusinessFunction implements BusinessFunction {
- Logger log = LoggerFactory.getLogger(getClass());
- @Autowired
- private SoExtDao soExtDao;
- @SuppressWarnings("unchecked")
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- log.info("\n\n Input Dto FindSoExtByIndex : "+inputDto+"\n\n");
- ValidationUtil.valDtoContainsKey(inputDto, "soId");
- Dto outputDto = null;
- Long soId = inputDto.getLong("soId");
- Query query = soExtDao
- .createQuery("SELECT e FROM "+SoExt.ENTITY_NAME+" e WHERE e.soId = :soId");
- query.setParameter("soId", soId);
- List<SoExt> soExtList = query.getResultList();
- if (soExtList.size() != 0) {
- outputDto = new Dto(soExtList.get(0));
- } else {
- throw new CoreException(SalesExceptionConstants.SO_EXT_NOT_FOUND,soId);
- }
- return outputDto;
- }
- @Override
- public String getDescription() {
- return "Find SoExt by index ";
- }
- }
RAW Paste Data