表单提交信息

master
bynt 1 year ago
parent 056c019576
commit 59997acf8f

@ -15,6 +15,8 @@
*/
package me.zhengjie.base;
import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@ -55,6 +57,7 @@ public class BaseEntity implements Serializable {
@CreationTimestamp
@Column(name = "create_time", updatable = false)
@ApiModelProperty(value = "创建时间", hidden = true)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
private Timestamp createTime;
@UpdateTimestamp

@ -0,0 +1,69 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.utils.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* <p>
*
* </p>
*
* @author Zheng Jie
* @date 2020-05-07
*/
@Getter
@AllArgsConstructor
public enum AmountScopeEnum {
/**
* 1-10
*/
ONE_TO_TEN(1, "1-10万"),
/**
* 10-20
*/
TEN_TO_TWENTY(2, "10-20万"),
/**
* 20-30
*/
TWENTY_TO_THIRTY(3, "20-30万"),
/**
* 30-60
*/
THIRTY_TO_SIXTY(4, "30-60万"),
/**
* 60
*/
GREATER_SIXTY(5, "60+");
private final Integer value;
private final String description;
public static AmountScopeEnum find(Integer val) {
for (AmountScopeEnum dataScopeEnum : AmountScopeEnum.values()) {
if (val.equals(dataScopeEnum.getValue())) {
return dataScopeEnum;
}
}
return null;
}
}

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-05-29T13:21:00+0800",
date = "2023-05-29T16:32:36+0800",
comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)"
)
@Component

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-05-29T13:21:01+0800",
date = "2023-05-29T16:32:36+0800",
comments = "version: 1.3.1.Final, compiler: javac, environment: Java 1.8.0_251 (Oracle Corporation)"
)
@Component

@ -6,7 +6,6 @@ import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ -48,6 +47,9 @@ public class LoanUser extends BaseEntity implements Serializable {
@ApiModelProperty(value = "额度类型 1:5-10万 2:10-20万 3:20-30万 4:30-50万 5:50万以上")
private Integer quotaType;
@Column(name = "remarks")
@ApiModelProperty(value = "备注")
private String remarks;

@ -24,11 +24,13 @@ public class LoanUserDTO {
@ApiModelProperty(value = "地址")
private String address;
@NotNull
@ApiModelProperty(value = "借款类别 1:信用卡 2:网贷 3:信用卡+网贷")
private Integer borrowingType;
@NotNull
@ApiModelProperty(value = "额度类型 1:5-10万 2:10-20万 3:20-30万 4:30-50万 5:50万以上")
@ApiModelProperty(value = "额度类型 1:1-10万 2:10-20万 3:20-30万 4:30-60万 5:60万以上")
private Integer quotaType;
@ApiModelProperty(value = "备注")
private String remarks;
}

@ -0,0 +1,34 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.loan.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* @website https://el-admin.vip
* @author x
* @date 2021-08-05
**/
@Data
public class LoanUserQueryCriteria {
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> createTime;
}

@ -1,21 +1,26 @@
package me.zhengjie.modules.loan.rest;
import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.annotation.NoRepeatSubmit;
import me.zhengjie.common.http.CommonResponse;
import me.zhengjie.common.http.ResponseCode;
import me.zhengjie.modules.loan.dto.LoanUserDTO;
import me.zhengjie.modules.loan.dto.LoanUserQueryCriteria;
import me.zhengjie.modules.loan.service.LoanUserService;
import me.zhengjie.service.dto.LogQueryCriteria;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Enzo
@ -40,4 +45,14 @@ public class LoanUserController {
new ResponseEntity<>(CommonResponse.createBySuccess(ResponseCode.SUCCESS), HttpStatus.OK)
: new ResponseEntity<>(CommonResponse.createByError(ResponseCode.ERROR), HttpStatus.INTERNAL_SERVER_ERROR);
}
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void download(HttpServletResponse response, LoanUserQueryCriteria criteria) throws IOException {
if (CollUtil.isNotEmpty(criteria.getCreateTime())) {
loanUserService.download(criteria, response);
}
}
}

@ -1,6 +1,10 @@
package me.zhengjie.modules.loan.service;
import me.zhengjie.modules.loan.dto.LoanUserDTO;
import me.zhengjie.modules.loan.dto.LoanUserQueryCriteria;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Enzo
@ -13,4 +17,11 @@ public interface LoanUserService {
* @return
*/
Boolean userSubmit(LoanUserDTO loanUserDTO);
/**
*
* @param criteria
* @param response
*/
void download(LoanUserQueryCriteria criteria, HttpServletResponse response) throws IOException;
}

@ -3,14 +3,26 @@ package me.zhengjie.modules.loan.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.Log;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.loan.domain.LoanUser;
import me.zhengjie.modules.loan.dto.LoanUserDTO;
import me.zhengjie.modules.loan.dto.LoanUserQueryCriteria;
import me.zhengjie.modules.loan.repository.LoanUserRepository;
import me.zhengjie.modules.loan.service.LoanUserService;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.MobileUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.enums.AmountScopeEnum;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author Enzo
* @date : 2022/6/6
@ -38,4 +50,21 @@ public class LoanUserServiceImpl implements LoanUserService {
}
return Boolean.FALSE;
}
@Override
public void download(LoanUserQueryCriteria criteria, HttpServletResponse response) throws IOException {
List<LoanUser> all = loanUserRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)));
List<Map<String, Object>> list = new ArrayList<>();
for (LoanUser user : all) {
AmountScopeEnum amountScopeEnum = AmountScopeEnum.find(user.getQuotaType());
Map<String, Object> map = new LinkedHashMap<>();
map.put("用户名", user.getUsername());
map.put("手机号码", user.getPhone());
map.put("额度类型", amountScopeEnum != null ? amountScopeEnum.getDescription() : "未知");
map.put("创建日期", user.getCreateTime().toString());
map.put("备注", user.getRemarks());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

Loading…
Cancel
Save