package com.java110.acct.cmd.payment; import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; import com.java110.dto.PropertyWhiteListFlowDto; import com.java110.dto.payment.PaymentKeyDto; import com.java110.intf.IImportPropertyWhiteListfFlowServiceSMO; import com.java110.intf.acct.IPaymentKeyV1InnerServiceSMO; import com.java110.utils.exception.CmdException; import com.java110.utils.util.BeanConvertUtil; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import java.text.ParseException; import java.util.List; @Java110Cmd(serviceCode = "payment.propertyWhiteListFlowCmd") public class PropertyWhiteListFlowCmd extends Cmd{ @Autowired private IImportPropertyWhiteListfFlowServiceSMO importPropertyWhiteListfFlowServiceSMO; @Override public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException, ParseException { } @Override public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException, ParseException { if(!reqJson.containsKey("row")){ reqJson.put("row",1); } PropertyWhiteListFlowDto white = BeanConvertUtil.covertBean(reqJson, PropertyWhiteListFlowDto.class); int count = importPropertyWhiteListfFlowServiceSMO.countPropertyWhiteListFlow(white); if(count == 0){ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, null); ResponseEntity responseEntity = new ResponseEntity(resultVo.toString(), HttpStatus.OK); cmdDataFlowContext.setResponseEntity(responseEntity); } else{ List dtoList = importPropertyWhiteListfFlowServiceSMO.queryPropertyWhiteListFlow(white); ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, dtoList); ResponseEntity responseEntity = new ResponseEntity(resultVo.toString(), HttpStatus.OK); cmdDataFlowContext.setResponseEntity(responseEntity); } } }