Commit f65970d9 by 吴迪

【新增】统计

parent 4ddb8a4b
...@@ -115,6 +115,8 @@ public class LogLoginController { ...@@ -115,6 +115,8 @@ public class LogLoginController {
if(!captcha){ if(!captcha){
return R.error("验证码不正确"); return R.error("验证码不正确");
} }
return R.ok(); return R.ok();
} }
......
package io.office.modules.manage.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.annotation.SysLog;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.common.validator.ValidatorUtils;
import io.office.common.validator.group.UpdateGroup;
import io.office.modules.manage.entity.WebsiteHitCountDetailEntity;
import io.office.modules.manage.form.WebsiteHitCountDetailForm;
import io.office.modules.manage.service.WebsiteHitCountDetailService;
import io.office.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
/**
* 网站点击量统计表
*
* @author wudi
* @email 632132852@qq.com
* @date 2023-12-10 14:58:04
*/
@RestController
@RequestMapping("/websitehitcountdetail")
public class WebsiteHitCountDetailController extends AbstractController {
@Autowired
private WebsiteHitCountDetailService websiteHitCountDetailService;
/**
* 列表
*/
/**
* 信息
*/
@RequestMapping("/info/{id}")
//@RequiresPermissions("manage:websitehitcountdetail:info")
public R info(@PathVariable("id") Long id) {
WebsiteHitCountDetailEntity websiteHitCountDetail = websiteHitCountDetailService.getById(id);
return R.ok().put("data", websiteHitCountDetail);
}
/**
* 保存
*/
@RequestMapping("/api/save")
//@RequiresPermissions("manage:websitehitcountdetail:save")
public R save(@RequestBody WebsiteHitCountDetailEntity websiteHitCountDetail, HttpServletRequest request) {
websiteHitCountDetailService.saveWebsiteHitCountDetail(websiteHitCountDetail, getUser(),request);
return R.ok();
}
/**
* 修改
*/
@SysLog("修改XXXX")
@RequestMapping("/update")
//@RequiresPermissions("manage:websitehitcountdetail:update")
public R update(@RequestBody WebsiteHitCountDetailForm websiteHitCountDetail) {
ValidatorUtils.validateEntity(websiteHitCountDetail, UpdateGroup.class);
//转化实体对象
WebsiteHitCountDetailEntity websiteHitCountDetailEntity = new WebsiteHitCountDetailEntity();
BeanUtil.copyProperties(websiteHitCountDetail, websiteHitCountDetailEntity);
websiteHitCountDetailService.updateWebsiteHitCountDetailById(websiteHitCountDetailEntity, getUser());
return R.ok();
}
/**
* 删除
*/
@SysLog("删除XXXX")
@RequestMapping("/delete")
//@RequiresPermissions("manage:websitehitcountdetail:delete")
public R delete(@RequestBody Long[] ids) {
websiteHitCountDetailService.removeByIds(Arrays.asList(ids));
return R.ok();
}
@RequestMapping("/list")
// @RequiresPermissions("manage:websitehitcountdetail:list")
public R list(@RequestBody WebsiteHitCountDetailForm websiteHitCountDetailForm) {
Page<WebsiteHitCountDetailForm> page = websiteHitCountDetailService.getListPage(websiteHitCountDetailForm,
new Page(websiteHitCountDetailForm.getPage(), websiteHitCountDetailForm.getLimit()));
PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
}
@RequestMapping("/getTotalCount")
// @RequiresPermissions("manage:websitehitcountdetail:list")
public R getTotalCount(@RequestBody WebsiteHitCountDetailForm websiteHitCountDetailForm) {
return R.ok().put("data", websiteHitCountDetailService.getTotalCount(websiteHitCountDetailForm));
}
}
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.WebsiteHitCountDetailEntity;
import io.office.modules.manage.form.WebsiteHitCountDetailForm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网站点击量统计表
*
* @author wudi
* @email 632132852@qq.com
* @date 2023-12-10 14:58:04
*/
@Mapper
public interface WebsiteHitCountDetailDao extends BaseMapper<WebsiteHitCountDetailEntity> {
List<WebsiteHitCountDetailForm> getListPage(@Param("websiteHitCountDetailForm") WebsiteHitCountDetailForm websiteHitCountDetailForm, Page page);
int getTotalCount(@Param("websiteHitCountDetailForm") WebsiteHitCountDetailForm websiteHitCountDetailForm);
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 网站点击量统计表
*
* @author wudi
* @email 632132852@qq.com
* @date 2023-12-10 14:58:04
*/
@Data
@TableName("website_hit_count_detail")
public class WebsiteHitCountDetailEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.INPUT)
private String id;
/**
* ip地址
*/
private String ip;
/**
* 点击时间
*/
private Date createTime;
/**
* 路由地址
*/
private String route;
/**
* 访问具体路径
*/
private String path;
}
package io.office.modules.manage.form;
import lombok.Data;
import java.io.Serializable;
/**
* 网站点击量统计表
*
* @author wudi
* @email 632132852@qq.com
* @date 2023-12-10 14:58:04
*/
@Data
public class WebsiteHitCountDetailForm implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ip地址
*/
private String ip;
/**
* 点击时间
*/
private String createStartTime;
private String createEndTime;
/**
* 路由地址
*/
private String route;
/**
* 访问具体路径
*/
private String path;
private int hitCount;
private int page;
private int limit;
private String orderFlag;
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.WebsiteHitCountDetailEntity;
import io.office.modules.manage.form.WebsiteHitCountDetailForm;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* 网站点击量统计表
*
* @author wudi
* @email 632132852@qq.com
* @date 2023-12-10 14:58:04
*/
public interface WebsiteHitCountDetailService extends IService<WebsiteHitCountDetailEntity> {
PageUtils queryPage(Map<String, Object> params);
@Transactional
void saveWebsiteHitCountDetail(WebsiteHitCountDetailEntity websiteHitCountDetailEntity, SysUserEntity loginUser, HttpServletRequest request);
@Transactional
void updateWebsiteHitCountDetailById(WebsiteHitCountDetailEntity websiteHitCountDetailEntity, SysUserEntity loginUser);
Page<WebsiteHitCountDetailForm> getListPage(WebsiteHitCountDetailForm websiteHitCountDetailForm, Page page);
int getTotalCount(WebsiteHitCountDetailForm websiteHitCountDetailForm);
}
package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sitech.idworkstarter.IdWorkService;
import io.office.common.utils.IPUtils;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.WebsiteHitCountDetailDao;
import io.office.modules.manage.entity.WebsiteHitCountDetailEntity;
import io.office.modules.manage.form.WebsiteHitCountDetailForm;
import io.office.modules.manage.service.WebsiteHitCountDetailService;
import io.office.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("websiteHitCountDetailService")
public class WebsiteHitCountDetailServiceImpl extends ServiceImpl<WebsiteHitCountDetailDao, WebsiteHitCountDetailEntity> implements WebsiteHitCountDetailService {
@Autowired
IdWorkService idWorkService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<WebsiteHitCountDetailEntity> page = this.page(
new Query<WebsiteHitCountDetailEntity>().getPage(params),
new QueryWrapper<WebsiteHitCountDetailEntity>().between(params.get("createStartTime")!=null&&params.get("createEndTime")!=null&& StringUtils.isNotBlank(params.get("createStartTime").toString())&& StringUtils.isNotBlank(params.get("createEndTime").toString()),"create_time",params.get("createStartTime").toString(),params.get("createEndTime").toString())
);
return new PageUtils(page);
}
@Override
public void updateWebsiteHitCountDetailById(WebsiteHitCountDetailEntity websiteHitCountDetailEntity, SysUserEntity loginUser) {
//websiteHitCountDetailEntity.setUpdateTime(new Date());
//websiteHitCountDetailEntity.setUpdateUserName(loginUser.getUsername());
//websiteHitCountDetailEntity.setUpdateUserId(loginUser.getUserId());
//baseMapper.updateById(websiteHitCountDetailEntity);
}
@Override
public Page<WebsiteHitCountDetailForm> getListPage(WebsiteHitCountDetailForm websiteHitCountDetailForm, Page page) {
//page.setTotal(baseMapper.getListPageCount(websiteHitCountDetailForm));
List<WebsiteHitCountDetailForm> newsList = baseMapper.getListPage(websiteHitCountDetailForm, page);
page.setRecords(newsList);
return page;
}
@Override
public int getTotalCount(WebsiteHitCountDetailForm websiteHitCountDetailForm) {
return baseMapper.getTotalCount(websiteHitCountDetailForm);
}
@Override
public void saveWebsiteHitCountDetail(WebsiteHitCountDetailEntity websiteHitCountDetailEntity, SysUserEntity loginUser, HttpServletRequest request) {
websiteHitCountDetailEntity.setId(idWorkService.getSEQByKey("id_seq"));
websiteHitCountDetailEntity.setIp(IPUtils.getIpAddr(request));
websiteHitCountDetailEntity.setCreateTime(new Date());
baseMapper.insert(websiteHitCountDetailEntity);
}
}
...@@ -18,9 +18,9 @@ spring: ...@@ -18,9 +18,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://118.190.181.128:51433;DatabaseName=gs108 url: jdbc:sqlserver://mssql.dev2.wangtiansoft.com:30022;DatabaseName=gs108
username: sa username: gs108
password: 1234.abcd password: V0ZR5nqHLop4W9UG
initial-size: 10 initial-size: 10
max-active: 100 max-active: 100
min-idle: 10 min-idle: 10
...@@ -52,14 +52,14 @@ dynamic: ...@@ -52,14 +52,14 @@ dynamic:
datasource: datasource:
slave1: slave1:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://118.190.181.128:51433;DatabaseName=gs108 url: jdbc:sqlserver://mssql.dev2.wangtiansoft.com:30022;DatabaseName=gs108
username: sa username: gs108
password: 1234.abcd password: V0ZR5nqHLop4W9UG
slave2: slave2:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://118.190.181.128:51433;DatabaseName=gs108 url: jdbc:sqlserver://mssql.dev2.wangtiansoft.com:30022;DatabaseName=gs108
username: sa username: gs108
password: 1234.abcd password: V0ZR5nqHLop4W9UG
##多数据源的配置 ##多数据源的配置
#dynamic: #dynamic:
......
...@@ -92,7 +92,7 @@ searchDayCountLimitSwitch: 100 ...@@ -92,7 +92,7 @@ searchDayCountLimitSwitch: 100
#域名 #域名
#域名 #域名
gs1: gs1:
domain: http://www.gs1cn.org domain: http://192.168.0.77
directory: directory:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.office.modules.manage.dao.WebsiteHitCountDetailDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.WebsiteHitCountDetailEntity" id="websiteHitCountDetailMap">
<result property="id" column="id"/>
<result property="ip" column="ip"/>
<result property="createTime" column="create_time"/>
<result property="route" column="route"/>
<result property="path" column="path"/>
</resultMap>
<select id="getListPage" parameterType="io.office.modules.manage.form.WebsiteHitCountDetailForm" resultType="io.office.modules.manage.form.WebsiteHitCountDetailForm">
select a.route,a.hit_count from (SELECT route, COUNT(1) AS hit_count
FROM website_hit_count_detail
<where>
<if test="websiteHitCountDetailForm.ip!=null and websiteHitCountDetailForm.ip!=''">
ip =#{websiteHitCountDetailForm.ip}
</if>
<if test="websiteHitCountDetailForm.createStartTime!=null and websiteHitCountDetailForm.createStartTime!=''">
and create_time &gt;= #{websiteHitCountDetailForm.createStartTime}
</if>
<if test="websiteHitCountDetailForm.createEndTime!=null and websiteHitCountDetailForm.createEndTime!=''">
and create_time &lt;= #{websiteHitCountDetailForm.createEndTime}
</if>
<if test="websiteHitCountDetailForm.route!=null and websiteHitCountDetailForm.route!=''">
and route = #{websiteHitCountDetailForm.route}
</if>
</where>
GROUP BY route ) a
<if test="websiteHitCountDetailForm.orderFlag==null || websiteHitCountDetailForm.orderFlag=='' ||websiteHitCountDetailForm.orderFlag=='1'">
order by hit_count desc
</if>
<if test="websiteHitCountDetailForm.orderFlag!=null and websiteHitCountDetailForm.orderFlag!='' and websiteHitCountDetailForm.orderFlag=='2'">
order by hit_count asc
</if>
</select>
<select id="getTotalCount" parameterType="io.office.modules.manage.form.WebsiteHitCountDetailForm" resultType="int">
SELECT COUNT(1) AS hit_count
FROM website_hit_count_detail
<where>
<if test="websiteHitCountDetailForm.createStartTime!=null and websiteHitCountDetailForm.createStartTime!=''">
and create_time &gt;= #{websiteHitCountDetailForm.createStartTime}
</if>
<if test="websiteHitCountDetailForm.createEndTime!=null and websiteHitCountDetailForm.createEndTime!=''">
and create_time &lt;= #{websiteHitCountDetailForm.createEndTime}
</if>
</where>
</select>
</mapper>
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