Tutorialspoint

bbnnb

fun main(args: Array<String>) { 
    println("Hello, World!") 
}

serviceUtils

package com.dat.digipay.digiposgateway.backoffice.gateway;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dat.digipay.digiposgateway.backoffice.domain.*;
import com.dat.digipay.digiposgateway.backoffice.repository.*;
import com.dat.digipay.digiposgateway.backoffice.repository.search.*;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Date;
import java.util.Map;

//import javax.transaction.Transactional;





import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//import java.io.*;
import org.jpos.iso.*;
import org.jpos.util.*;
import org.jpos.iso.channel.*;
import org.jpos.iso.packager.*;

/**
 * A class to test interactions with the MySQL database using the UserDao class.
 *
 * @author Philippe MONSAN
 */
@Service
@Transactional
public class ServiceUtils {
  
  static Logger logger = LoggerFactory.getLogger(ServiceUtils.class); 

  public Message createMessage(DpService dpService, MessageType messageType, String transactionid, Device device, Meansofpayment meansofpayment, Beneficiary beneficiary, double amount, String isoMessage, SecurityEndpoint securityEndpoint){
	  
	  MessageStatus messageStatus = messageStatusDao.getOne(1L);
	  String comment = "";
	  
	  Message message = new Message();
	  message.setNumber(transactionid);
	  message.setClientTransactionNumber(transactionid);
	  message.setRegistrationDate(Instant.now());
	  message.setIsoMessage(isoMessage);
	  message.setAmount(amount);
	  //message.setFeesSupported(feesSupported);
	  //message.setChangeFeesSupported(changeFeesSupported);
	  //message.setTransactionFees(transactionFees);
	  //message.setTransactionChangeFees(transactionChangeFees);
	  message.setActive(true);
	  message.setMessageDate(Instant.now());	  
	  message.setComment(comment);
	  
	  
	  //message.setClientApplication(clientApplication);
	  message.setDevice(device);
	  message.setMessageStatus(messageStatus);
	  message.setMeansofpayment(meansofPayment);
	  message.setBeneficiary(beneficiary);
	  message.setMessageType(messageType);
	  message.setSecurityEndpoint(securityEndpoint);
	  //message.setMessageEndpoint(messageEndpoint);
	  message.setDpService(dpService);
		
	  message = messageDao.save(message);
	  
	  return message;
  }  
  
  /*
  entity Message(t_message) {
	number String,
	clientTransactionNumber String maxlength(20),
	otpNotification OtpNotification required,
	otp String,
	otpChecked Boolean required,
	fingerprintChecked Boolean required,
	faceChecked Boolean required,
	voiceChecked Boolean required,
	registrationDate Instant,
	messageDate Instant,
	otpCheckedDate Instant,
	isoMessage String,
	amount Double,
	feesSupported Boolean required,
    changeFeesSupported Boolean required,
	transactionFees Double min(0),
    transactionChangeFees Double min(0),
	active Boolean required,
	modificationDate Instant,
	sendDate Instant,
	comment String maxlength(255)
}

relationship ManyToOne {
	Message{clientApplication} to ClientApplication,
	Message{device} to Device,
	Message{messageStatus} to MessageStatus,
	Message{meansofpayment} to Meansofpayment,
	Message{beneficiary} to Beneficiary,
	Message{messageType} to MessageType,
	Message{securityEndpoint} to SecurityEndpoint,
	Message{messageEndpoint} to MessageEndpoint,
	Message{service} to DpService
}*/
   
  public Message createMessage(String service, String messageTypeLabel, String transactionid, String terminalId, String merchantId, String issuerCode, String meansofpaymentType, String meansofpayment, String beneficiaryType, String beneficiaryAccount, double amount, String isoMessage, SecurityEndpoint securityEndpoint){
	  
	  MeansofpaymentType meansofPaymentType = meansofpaymentTypeDao.findByLabel(meansofpaymentType);
	  DpService dpService = DpServiceDao.findByCode(service);
	  Device device = deviceDao.findByCode(terminalId);
	  
	  BeneficiaryType benefType = beneficiaryTypeDao.findByLabel(beneficiaryType);
	  
	  MessageStatus messageStatus = messageStatusDao.getOne(1L);
	  
	  Meansofpayment meansofPayment = new Meansofpayment();
	  meansofPayment.setActive(true);
	  meansofPayment.setMeansofpaymentType(meansofPaymentType);
	  if ("Cash".equals(meansofpaymentType)){
		  
	  }
	  else
		  if ("MoMo".equals(meansofpaymentType)){
			  meansofPayment.setMomoAccountNumber(meansofpayment);
		  }
		  else 
			  if ("BankAccount".equals(meansofpaymentType)){ 
				  //meansofPayment.setBaccBankCode(baccBankCode);
				  //meansofPayment.setBaccAccountNumber(baccAccountNumber);
				  //meansofPayment.setBaccRibKey(baccRibKey);
			  }
			  else 
				  if ("CB".equals(meansofpaymentType)){ 
					  //meansofPayment.setCardPan(cardPan);
					  //meansofPayment.cardCvv2(cardCvv2);
					  //meansofPayment.setCardValidityDate(cardValidityDate);
				  } 
				  /*else{
					  return null;
				  }*/
	  
	  Beneficiary beneficiary = new Beneficiary();
	  beneficiary.setBeneficiaryType(benefType);
	  if ("Cash".equals(beneficiaryType)){
				  
	  }
	  else
		  if ("MoMo".equals(beneficiaryType)){
			  beneficiary.setMobileMoneyAccountNumber(beneficiaryAccount);
		  }
		  else 
			  if ("BankAccount".equals(beneficiaryType)){ 
				  //beneficiary.setBaccAccountNumber(baccAccountNumber);
				  //beneficiary.setBaccBankCode(baccBankCode);
				  //beneficiary.setBaccRibKey(baccRibKey);
			  }
			  else 
				  if ("CB".equals(beneficiaryType)){ 
					  //beneficiary.setCardPan(cardPan);
					  //beneficiary.cardCvv2(cardCvv2);
					  //beneficiary.setCardValidityDate(cardValidityDate);
				  } 
	  
	  Message message = new Message();
	  message.setNumber(transactionid);
	  message.setActive(true);
	  message.setAmount(amount);
	  message.setMeansofpayment(meansofPayment);
	  message.setBeneficiary(beneficiary);
	  message.setIsoMessage(isoMessage);
	  //message.setMessageType(messageType);
		
	  message.setDevice(device);
	  message.setMessageDate(Instant.now());
	  //message.setDpService(dpService);
	  //message.setClientApplication(clientApplication);
	  //message.setClientTransactionNumber(clientTransactionNumber);
	  //message.setComment(comment);
	  message.setMessageStatus(messageStatus);
	  message.setRegistrationDate(Instant.now());
	  //message.setTransactionFees(transactionFees);
		
	  message = messageDao.save(message);
	  
	  return message;
  }
  
  public MessageSetting getMessageSetting(String messageType, BeneficiaryType beneficiaryType){
	  return new MessageSetting();
  }
  
  public MessageType getMessageType(String messageType){
	  return new MessageType();
  }
  
  public Device getDevice(String deviceCode){
	  return new Device();
  }
  
  public Meansofpayment getMeansofpayment(String meansofpayment){
	  return new Meansofpayment();
  }
  
  public Beneficiary getBeneficiary(String beneficiary){
	  return new Beneficiary();
  }
  
  public Meansofpayment getMerchantMeansofpayment(Merchant merchant){
	  return new Meansofpayment();
  }
  
  public Beneficiary getAcquirerOperationAccount(Partner acquirer){
	  return new Beneficiary();
  }
  
  public Message getMoneyTransfer(String remittancereferencecode, String remittancesecretcode){
	  return new Message();
  }
  
  public Meansofpayment getMoneyTransferMeansofpayment(Beneficiary beneficiary){
	  return new Meansofpayment();
  }
  
  public String generateIsoMessage(DpService dpService, Device device, Merchant merchant, Meansofpayment meansofpayment, Beneficiary beneficiary){
	  
	  String isoMessage;
	  if (dpService.getIsoMessage() == null){
		  return null;
	  }
		
		ISO87APackager packager = new ISO87APackager();
		ISOMsg m = new ISOMsg();
		m.setMTI (dpService.getIsoMessage().getMessageCode());
		//m.set (2, meansofpayment);
		//m.set (3, "20021");
		//m.set (4, amount + "");
		//m.set (11, "000001");
		//m.set (32, issuerCode);
		//m.set (41, this.terminalid);
		m.set (42, merchant.getCode());
		//m.set (60, "jPOS 6");
		//m.set (70, "301");
		logISOMsg(m);
		m.setPackager (packager);
		byte[] binaryImage = m.pack();
		isoMessage = new String(binaryImage);
	  
	  return isoMessage;
  }
  
  @Autowired
  private DeviceRepository deviceDao;
  
  @Autowired
  private DpServiceRepository dpServiceDao;
  
  @Autowired
  private IsoSettingRepository isoSettingDao;
  
  @Autowired
  private IsoMessageRepository isoMessageDao;
  
  @Autowired
  private IsoMessageFieldRepository isoMessageFieldDao;
  
  @Autowired
  private MessageRepository messageDao;
  
  @Autowired
  private MessageStatusRepository messageStatusDao;
  
  @Autowired
  private MeansofpaymentRepository meansofpaymentDao;
  
  @Autowired
  private MeansofpaymentTypeRepository meansofpaymentTypeDao;
  
  @Autowired
  private BeneficiaryTypeRepository beneficiaryTypeDao;
  
  @Autowired
  private IsoServerRepository isoServerDao;
  
  @Autowired
  private DpServiceRepository DpServiceDao;
} 

llll

fun main(args: Array<String>) { 
    val numbers: IntArray = intArrayOf(1, 2, 3, 4, 5) 
     
    println("Hey!! I am array Example"+numbers[2]) 
     
}

Compile and Execute Kotlin Online

fun main(args: Array<String>) {
    println("Hello, World!")
}

main.kt

fun main(args: Array<String>){
//    val a: Int = 10000 
//    val d: Double = 100.00 
//    val f: Float = 100.00f 
//    val l: Long = 1000000004 
//    val s: Short = 10 
//    val b: Byte = 1
        println("Hello world");
//    println("Your Int Value is "+a); 
//    println("Your Double  Value is "+d); 
//    println("Your Float Value is "+f); 
//    println("Your Long Value is "+l); 
//    println("Your Short Value is "+s); 
//    println("Your Byte Value is "+b);
}

If-Else

fun main(args: Array<String>) {
    val a:Int = 5
    val b:Int = 2
    var max: Int
    
    if(a>b){
        max =a
    }else{
        max = b
    }
    print("Maximun of a or b is "+ max)
}

Rami

fun main(args: Array<String>) {
    println("Hello, World!")
    int v= 10
    print(v)
}

Kotlin Collections

fun main(args: Array<String>) { 
   val numbers: MutableList<Int> = mutableListOf(1, 2, 3) //mutable List 
   val readOnlyView: List<Int> = numbers                  // immutable list 
   println("my mutable list--"+numbers)        // prints "[1, 2, 3]" 
   numbers.add(4) 
   println("my mutable list after addition --"+numbers)        // prints "[1, 2, 3, 4]" 
   println(readOnlyView)     
   readOnlyView.clear()    // ⇒ does not compile  
// gives error  
}

pokus

sealed class MyExample { 
  class OP1 : MyExample() // MyExmaple class can be of two types only 
  class OP2 : MyExample() 
} 
fun main(args: Array<String>) { 
  val obj: MyExample = MyExample.OP2()  
  val output = when (obj) { // defining the object of the class depending on the inuputs  
    is MyExample.OP1 -> "Option One has been chosen" 
    is MyExample.OP2 -> "option Two has been chosen" 
  } 
  println(output) 
}

1 2 3 4 5 6 7 ... 11 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.