Commit a393bc9e authored by 廖旭伟's avatar 廖旭伟

用户导出功能

parent f2d5dbe5
......@@ -3,10 +3,16 @@ package com.mortals.xhx.module.customer.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.CustomerSatusEnum;
import com.mortals.xhx.common.code.MemberLevelEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.vo.CustomerVo;
/**
......@@ -34,14 +40,17 @@ public class CustomerEntity extends CustomerVo implements IUser {
/**
* 客户真实名称
*/
@Excel(name = "真实名称姓名")
private String custName;
/**
* 单位名称
*/
@Excel(name = "单位名称")
private String organization;
/**
* 联系电话
*/
@Excel(name = "联系电话")
private String contactTelphone;
/**
* 企业顾问
......@@ -128,6 +137,9 @@ public class CustomerEntity extends CustomerVo implements IUser {
*/
public void setMemberLevel(Integer memberLevel){
this.memberLevel = memberLevel;
if(memberLevel!=null && MemberLevelEnum.getByValue(memberLevel)!=null) {
this.setLevelName(MemberLevelEnum.getByValue(memberLevel).getDesc());
}
}
/**
* 获取 客户真实名称
......@@ -282,6 +294,9 @@ public class CustomerEntity extends CustomerVo implements IUser {
*/
public void setStatus(Integer status){
this.status = status;
if(status!=null && CustomerSatusEnum.getByValue(status)!=null) {
this.setStatusName(CustomerSatusEnum.getByValue(status).getDesc());
}
}
/**
* 获取 最后一次登录时间
......@@ -296,6 +311,9 @@ public class CustomerEntity extends CustomerVo implements IUser {
*/
public void setLastLoginTime(Date lastLoginTime){
this.lastLoginTime = lastLoginTime;
if(lastLoginTime!=null) {
this.setLastLoginTimeStr(DateUtils.getDateTimeStr(lastLoginTime, "yyyy-MM-dd HH:mm:ss"));
}
}
/**
* 获取 最后一次登录地址
......
package com.mortals.xhx.module.customer.model;
import com.mortals.framework.annotation.Excel;
import lombok.Data;
@Data
public class CustomerEntityExt extends CustomerEntity {
/**
* 客户设计图片数量
*/
private Integer customerDesignPictures;
/**
* 客户设计视频数量
*/
private Integer customerDesignVideos;
private String createTimeStr;
......
package com.mortals.xhx.module.customer.model.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 客户管理视图对象
......@@ -38,4 +40,27 @@ public class CustomerVo extends BaseEntityLong {
private String oldPassword;
private String newPassword;
/**
* 客户设计图片数量
*/
@Excel(name = "图片作品数")
private Integer customerDesignPictures;
/**
* 客户设计视频数量
*/
@Excel(name = "视频作品数")
private Integer customerDesignVideos;
@Excel(name = "会员等级")
private String levelName;
@Excel(name = "使用状态")
private String statusName;
/**
* 最后一次登录时间
*/
@Excel(name = "最近登录时间")
private String lastLoginTimeStr;
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.utils.ReflectUtils;
import com.mortals.framework.utils.poi.ExcelUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.CustomerSatusEnum;
import com.mortals.xhx.common.code.CustomerSrcEnum;
......@@ -17,6 +19,7 @@ import com.mortals.xhx.common.code.MemberLevelEnum;
import com.mortals.xhx.common.code.SexEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.CustomerQuery;
import com.mortals.xhx.module.customer.service.CustomerService;
import org.springframework.web.bind.annotation.*;
......@@ -308,4 +311,31 @@ public class CustomerController extends BaseCRUDJsonBodyMappingController<Custom
return ret.toJSONString();
}
@Override
@UnAuth
public void exportExcel(@RequestBody CustomerEntity query) {
Context context = this.getContext();
String busiDesc = "导出" + this.getModuleDesc();
try {
this.doExportBefore(context, query);
String name = StringUtils.trim(this.moduleDesc);
if (StringUtils.isEmpty(name)) {
name = System.currentTimeMillis() + "";
}
String fileName = name + ".xlsx";
PageInfo pageInfo = new PageInfo(-1);
List<CustomerEntityExt> list = this.service.findExt(query, pageInfo, this.getContext()).getList();
Class<CustomerEntityExt> tClass = ReflectUtils.getClassGenricType(this.getClass(), 1);
ExcelUtil<CustomerEntityExt, Long> util = new ExcelUtil(tClass);
byte[] data = util.exportExcel(list, name);
this.responseStream(this.response, data, fileName);
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var11) {
this.doException(this.request, "导出异常", new HashMap(), var11);
}
}
}
\ No newline at end of file
spring:
main:
allow-bean-definition-overriding: true
application:
log:
level: @profiles.log.level@
path: @profiles.log.path@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment