1DanielLee9

FindSoExtByIndex

Apr 7th, 2021
269
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.jleaf.erp.sls.bo.salesorderext;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.persistence.Query;
  6.  
  7. import org.jleaf.core.AbstractBusinessFunction;
  8. import org.jleaf.core.BusinessFunction;
  9. import org.jleaf.core.CoreException;
  10. import org.jleaf.core.Dto;
  11. import org.jleaf.core.annotation.ErrorList;
  12. import org.jleaf.core.annotation.Info;
  13. import org.jleaf.core.annotation.InfoIn;
  14. import org.jleaf.core.annotation.InfoOut;
  15. import org.jleaf.util.ValidationUtil;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Service;
  20. import org.jleaf.erp.sls.entity.SoExt;
  21. import org.jleaf.erp.sls.dao.SoExtDao;
  22. import org.jleaf.erp.sls.SalesExceptionConstants;
  23.  
  24.  
  25. /**
  26.  * Find SoExt by index
  27.  * @author Sts, Mar 26, 2021
  28.  * @version 1.0
  29.  */
  30.  
  31. @Service
  32. @InfoIn(value = {
  33.     @Info(name = "soId", description = "So id", type = Long.class, required = true)
  34. })
  35. @InfoOut(value = {
  36.     @Info(name = "id", description = "Id", type = Long.class, required = true),
  37.     @Info(name = "tenantId", description = "Tenant id", type = Long.class, required = true),
  38.     @Info(name = "soId", description = "So id", type = Long.class, required = true),
  39.     @Info(name = "flagDropship", description = "Flag dropship", type = String.class, required = true),
  40.     @Info(name = "createUserId", description = "Create user id", type = Long.class, required = true),
  41.     @Info(name = "createDateTime", description = "Create date time", type = String.class, required = true),
  42.     @Info(name = "updateUserId", description = "Update user id", type = Long.class, required = true),
  43.     @Info(name = "updateDateTime", description = "Update date time", type = String.class, required = true),
  44.     @Info(name = "version", description = "Version", type = Long.class, required = true)
  45. })
  46. @ErrorList(errorKeys = {
  47.     SalesExceptionConstants.SO_EXT_NOT_FOUND
  48. })
  49. public class FindSoExtByIndex extends AbstractBusinessFunction implements BusinessFunction {
  50.     Logger log = LoggerFactory.getLogger(getClass());  
  51.  
  52.     @Autowired
  53.     private SoExtDao soExtDao;
  54.  
  55.     @SuppressWarnings("unchecked")
  56.     @Override
  57.     public Dto execute(Dto inputDto) throws Exception {
  58.         log.info("\n\n Input Dto FindSoExtByIndex : "+inputDto+"\n\n");
  59.        
  60.         ValidationUtil.valDtoContainsKey(inputDto, "soId");
  61.  
  62.         Dto outputDto = null;
  63.  
  64.         Long soId = inputDto.getLong("soId");
  65.  
  66.        
  67.         Query query = soExtDao
  68.             .createQuery("SELECT e FROM "+SoExt.ENTITY_NAME+" e WHERE e.soId = :soId");
  69.  
  70.         query.setParameter("soId", soId);
  71.        
  72.        
  73.         List<SoExt> soExtList = query.getResultList();
  74.         if (soExtList.size() != 0) {
  75.             outputDto = new Dto(soExtList.get(0));
  76.         } else {
  77.             throw new CoreException(SalesExceptionConstants.SO_EXT_NOT_FOUND,soId);
  78.         }
  79.        
  80.         return outputDto;
  81.     }
  82.  
  83.     @Override
  84.     public String getDescription() {
  85.         return "Find SoExt by index ";
  86.     }
  87.  
  88. }
  89.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×