Browse Source

feat: [登录日志] 导出

master
memorylkf 2 months ago
parent
commit
3b04b68f11
3 changed files with 55 additions and 4 deletions
  1. +22
    -0
      hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysLogininfor.java
  2. +26
    -4
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysLogininforController.java
  3. +7
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysLogininforMapper.xml

+ 22
- 0
hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysLogininfor.java View File

@ -44,6 +44,12 @@ public class SysLogininfor extends BaseEntity
@Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date accessTime;
/** 开始日期 */
private String startDate;
/** 结束日期 */
private String endDate;
public Long getInfoId()
{
return infoId;
@ -111,4 +117,20 @@ public class SysLogininfor extends BaseEntity
{
this.accessTime = accessTime;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
}

+ 26
- 4
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysLogininforController.java View File

@ -1,7 +1,14 @@
package com.hxhq.system.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.hxhq.business.domain.SystemLog;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.ServletUtils;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.common.security.annotation.Logical;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -38,23 +45,38 @@ public class SysLogininforController extends BaseController
@Autowired
private RedisService redisService;
@RequiresPermissions("system:logininfor:list")
@RequiresPermissions(value = {"system:logininfor:list","business:systemLog:login"},logical = Logical.OR)
@GetMapping("/list")
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
if(StringUtils.isNoneBlank(logininfor.getEndDate())){
logininfor.setEndDate(DateUtils.dateTime(DateUtils.addDays(DateUtils.parseDate(logininfor.getEndDate()),1)));
}
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
}
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:logininfor:export")
@RequiresPermissions(value = {"system:logininfor:export","business:systemLog:export"},logical = Logical.OR)
@PostMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor)
{
if(StringUtils.isNoneBlank(logininfor.getEndDate())){
logininfor.setEndDate(DateUtils.dateTime(DateUtils.addDays(DateUtils.parseDate(logininfor.getEndDate()),1)));
}
List<SystemLog> logList = new ArrayList<>();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志");
for(SysLogininfor l:list){
SystemLog systemLog = new SystemLog();
systemLog.setQmrMc(l.getNickName());
systemLog.setCzlx(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?"登录":"Login");
systemLog.setCzsj(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,l.getAccessTime()));
systemLog.setCzxq(l.getMsg());
logList.add(systemLog);
}
ExcelUtil<SystemLog> util = new ExcelUtil<SystemLog>(SystemLog.class);
util.exportExcel(response, logList, "登录日志");
}
@RequiresPermissions("system:logininfor:remove")

+ 7
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysLogininforMapper.xml View File

@ -40,6 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND access_time &lt;= #{params.endTime}
</if>
<if test="startDate != null and startDate != ''"><!-- 开始时间检索 -->
AND access_time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''"><!-- 结束时间检索 -->
AND access_time &lt; #{endDate}
</if>
</where>
order by info_id desc
</select>

Loading…
Cancel
Save