| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO; |
| | | import com.java110.po.userDownloadFile.UserDownloadFilePo; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.PayUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.java110.dto.userDownloadFile.UserDownloadFileDto; |
| | | import com.java110.dto.user.UserDownloadFileDto; |
| | | |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.slf4j.Logger; |
| | |
| | | @Java110Cmd(serviceCode = "userDownloadFile.listUserDownloadFile") |
| | | public class ListUserDownloadFileCmd extends Cmd { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(ListUserDownloadFileCmd.class); |
| | | private static Logger logger = LoggerFactory.getLogger(ListUserDownloadFileCmd.class); |
| | | @Autowired |
| | | private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | | super.validatePageInfo(reqJson); |
| | | // super.validatePageInfo(reqJson); |
| | | // Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区编号"); |
| | | } |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | |
| | | UserDownloadFileDto userDownloadFileDto = BeanConvertUtil.covertBean(reqJson, UserDownloadFileDto.class); |
| | | String userId = cmdDataFlowContext.getReqHeaders().get("user-id"); |
| | | |
| | | int count = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFilesCount(userDownloadFileDto); |
| | | UserDownloadFileDto userDownloadFileDto = BeanConvertUtil.covertBean(reqJson, UserDownloadFileDto.class); |
| | | userDownloadFileDto.setDownloadUserId(userId); |
| | | |
| | | List<UserDownloadFileDto> userDownloadFileDtos = null; |
| | | int count = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFilesCount(userDownloadFileDto); |
| | | |
| | | if (count > 0) { |
| | | userDownloadFileDtos = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFiles(userDownloadFileDto); |
| | | } else { |
| | | userDownloadFileDtos = new ArrayList<>(); |
| | | } |
| | | List<UserDownloadFileDto> userDownloadFileDtos = null; |
| | | |
| | | ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, userDownloadFileDtos); |
| | | String date = DateUtil.getFormatTimeStringB(DateUtil.getCurrentDate()); |
| | | String token = ""; |
| | | if (count > 0) { |
| | | userDownloadFileDtos = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFiles(userDownloadFileDto); |
| | | for (UserDownloadFileDto tmpUserDownloadFileDto : userDownloadFileDtos) { |
| | | token = tmpUserDownloadFileDto.getDownloadId() + date; |
| | | tmpUserDownloadFileDto.setDownloadUrl("/app/file/userfile/download/" + tmpUserDownloadFileDto.getDownloadId() + "/" + PayUtil.md5(token)); |
| | | } |
| | | } else { |
| | | userDownloadFileDtos = new ArrayList<>(); |
| | | } |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); |
| | | ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, userDownloadFileDtos); |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); |
| | | |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | } |