feat(用户登录日志):用户登录日志查询及导出功能
parent
cc3fd0a754
commit
195a55736a
@ -0,0 +1,33 @@
|
|||||||
|
package cn.estsh.i3plus.core.api.iservice.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysLogUserLogin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 用户登录日志
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-08-31 11:47
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface ISysLogUserLoginService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录日志分页查询
|
||||||
|
* @param sysLogUserLogin 查询条件
|
||||||
|
* @param pager 分页信息
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
ListPager<SysLogUserLogin> querySysLogUserLoginByPager(SysLogUserLogin sysLogUserLogin, Pager pager);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录日志查询
|
||||||
|
* @param sysLogUserLogin 查询条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
List<SysLogUserLogin> findSysUserLoginList(SysLogUserLogin sysLogUserLogin);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysLogUserLoginService;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.ExcelTool;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
||||||
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
||||||
|
import cn.estsh.i3plus.platform.common.util.FileContentTypeTool;
|
||||||
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysLogUserLogin;
|
||||||
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description :
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-08-31 11:45
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "用户登录日志")
|
||||||
|
@RequestMapping(PlatformConstWords.BASE_URL + "/sys-log-user-login")
|
||||||
|
public class SysLogUserLoginController extends CoreBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysLogUserLoginService sysLogUserLoginService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Resource(name= CommonConstWords.IMPP_REDIS_RES)
|
||||||
|
private ImppRedis redisRes;
|
||||||
|
|
||||||
|
@GetMapping("/query")
|
||||||
|
@ApiOperation(value = "定时任务日志分页复杂查询",notes = "定时任务日志分页复杂查询")
|
||||||
|
public ResultBean querySysLogUserLogin(SysLogUserLogin sysLogUserLogin, Pager pager){
|
||||||
|
try {
|
||||||
|
ListPager logUserLoginListPager = sysLogUserLoginService.querySysLogUserLoginByPager(sysLogUserLogin, pager);
|
||||||
|
return ResultBean.success("查询成功").setListPager(logUserLoginListPager).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
||||||
|
}catch(ImppBusiException busExcep){
|
||||||
|
return ResultBean.fail(busExcep);
|
||||||
|
}catch(Exception e){
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export")
|
||||||
|
@ApiOperation(value = "定时任务日志分页复杂查询",notes = "定时任务日志分页复杂查询")
|
||||||
|
public void exportSysLogUserLogin(SysLogUserLogin sysLogUserLogin, HttpServletResponse response) throws Exception {
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
List<SysLogUserLogin> list = sysLogUserLoginService.findSysUserLoginList(sysLogUserLogin);
|
||||||
|
|
||||||
|
ExcelTool excelTool = new ExcelTool(entityManager, redisRes);
|
||||||
|
String fileName = "log-user-login-" + System.currentTimeMillis() + ".xls";
|
||||||
|
file = new File(fileName);
|
||||||
|
file.createNewFile();
|
||||||
|
File excle = excelTool.exportData(file, list, SysLogUserLogin.class, (LinkedHashMap<String, String>) ExcelTool.getColName(SysLogUserLogin.class));
|
||||||
|
|
||||||
|
response.setContentType("application/force-download"); // 设置强制下载不打开
|
||||||
|
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); // 设置文件名
|
||||||
|
response.addHeader("Content-type", FileContentTypeTool.getContentType(StringTool.getStringFileSuffix(fileName,true)));
|
||||||
|
|
||||||
|
// 设置文件名
|
||||||
|
try (BufferedInputStream bis = new BufferedInputStream(new DataInputStream(new FileInputStream(excle)))) {
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int i = bis.read(buffer);
|
||||||
|
while (i != -1) {
|
||||||
|
os.write(buffer, 0, i);
|
||||||
|
i = bis.read(buffer);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
FileUtils.deleteQuietly(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysLogUserLoginService;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||||
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.bean.SysLogUserLogin;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.repository.SysLogUserLoginRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 用户登录日志
|
||||||
|
* @Reference :
|
||||||
|
* @Author : yunhao
|
||||||
|
* @CreateDate : 2020-08-31 11:51
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class SysLogUserLoginService implements ISysLogUserLoginService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLogUserLoginRepository sysLogUserLoginRDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录日志分页查询
|
||||||
|
*
|
||||||
|
* @param sysLogUserLogin 查询条件
|
||||||
|
* @param pager 分页信息
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ListPager<SysLogUserLogin> querySysLogUserLoginByPager(SysLogUserLogin sysLogUserLogin, Pager pager) {
|
||||||
|
DdlPackBean ddlPackBean = CoreHqlPack.packHqlQuerySysLogUserLogin(sysLogUserLogin);
|
||||||
|
int count = sysLogUserLoginRDao.findByHqlWhereCount(ddlPackBean);
|
||||||
|
PagerHelper.getPager(pager, count);
|
||||||
|
return new ListPager<>(sysLogUserLoginRDao.findByHqlWherePage(ddlPackBean, pager), pager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录日志查询
|
||||||
|
*
|
||||||
|
* @param sysLogUserLogin 查询条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysLogUserLogin> findSysUserLoginList(SysLogUserLogin sysLogUserLogin) {
|
||||||
|
DdlPackBean ddlPackBean = CoreHqlPack.packHqlQuerySysLogUserLogin(sysLogUserLogin);
|
||||||
|
return sysLogUserLoginRDao.findByHqlWhere(ddlPackBean);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue