Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
7a5a30ebdd |
|
@ -0,0 +1,105 @@
|
|||
package com.ff.base.table.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ff.base.table.domain.Table;
|
||||
import com.ff.base.table.service.ITableService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
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 com.ff.base.annotation.Log;
|
||||
import com.ff.base.core.controller.BaseController;
|
||||
import com.ff.base.core.domain.AjaxResult;
|
||||
import com.ff.base.enums.BusinessType;
|
||||
import com.ff.base.utils.poi.ExcelUtil;
|
||||
import com.ff.base.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 分Controller
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025-03-28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/table/table")
|
||||
public class TableController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ITableService tableService;
|
||||
|
||||
/**
|
||||
* 查询分列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Table table)
|
||||
{
|
||||
startPage();
|
||||
List<Table> list = tableService.selectTableList(table);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出分列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:export')")
|
||||
@Log(title = "分", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Table table)
|
||||
{
|
||||
List<Table> list = tableService.selectTableList(table);
|
||||
ExcelUtil<Table> util = new ExcelUtil<Table>(Table.class);
|
||||
util.exportExcel(response, list, "分数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(tableService.selectTableById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:add')")
|
||||
@Log(title = "分", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Table table)
|
||||
{
|
||||
return toAjax(tableService.insertTable(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:edit')")
|
||||
@Log(title = "分", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Table table)
|
||||
{
|
||||
return toAjax(tableService.updateTable(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('table:table:remove')")
|
||||
@Log(title = "分", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(tableService.deleteTableByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.ff.base.table.domain;
|
||||
|
||||
import com.ff.base.annotation.Excel;
|
||||
import com.ff.base.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
/**
|
||||
* 分对象 ff_table
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025-03-28
|
||||
*/
|
||||
@Data
|
||||
public class Table extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 表名 */
|
||||
@Excel(name = "表名")
|
||||
private String tableName;
|
||||
|
||||
/** 分表字段 */
|
||||
@Excel(name = "分表字段")
|
||||
private String tableField;
|
||||
|
||||
/** 分表类型 day天分表 */
|
||||
@Excel(name = " 分表类型 day天分表 ")
|
||||
private String type;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.ff.base.table.mapper;
|
||||
|
||||
import com.ff.base.table.domain.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分Mapper接口
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025-03-28
|
||||
*/
|
||||
public interface TableMapper
|
||||
{
|
||||
/**
|
||||
* 查询分
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 分
|
||||
*/
|
||||
Table selectTableById(Long id);
|
||||
|
||||
/**
|
||||
* 查询分列表
|
||||
*
|
||||
* @param table 分
|
||||
* @return 分集合
|
||||
*/
|
||||
List<Table> selectTableList(Table table);
|
||||
|
||||
/**
|
||||
* 新增分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
int insertTable(Table table);
|
||||
|
||||
/**
|
||||
* 修改分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
int updateTable(Table table);
|
||||
|
||||
/**
|
||||
* 删除分
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTableById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除分
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTableByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.ff.base.table.service;
|
||||
|
||||
import com.ff.base.table.domain.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分Service接口
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025-03-28
|
||||
*/
|
||||
public interface ITableService
|
||||
{
|
||||
/**
|
||||
* 查询分
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 分
|
||||
*/
|
||||
Table selectTableById(Long id);
|
||||
|
||||
/**
|
||||
* 查询分列表
|
||||
*
|
||||
* @param table 分
|
||||
* @return 分集合
|
||||
*/
|
||||
List<Table> selectTableList(Table table);
|
||||
|
||||
/**
|
||||
* 新增分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
int insertTable(Table table);
|
||||
|
||||
/**
|
||||
* 修改分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
int updateTable(Table table);
|
||||
|
||||
/**
|
||||
* 批量删除分
|
||||
*
|
||||
* @param ids 需要删除的分主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTableByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除分信息
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTableById(Long id);
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.ff.base.table.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ff.base.table.domain.Table;
|
||||
import com.ff.base.table.mapper.TableMapper;
|
||||
import com.ff.base.table.service.ITableService;
|
||||
import com.ff.base.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 分Service业务层处理
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025-03-28
|
||||
*/
|
||||
@Service
|
||||
public class TableServiceImpl implements ITableService
|
||||
{
|
||||
@Autowired
|
||||
private TableMapper tableMapper;
|
||||
|
||||
/**
|
||||
* 查询分
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 分
|
||||
*/
|
||||
@Override
|
||||
public Table selectTableById(Long id)
|
||||
{
|
||||
return tableMapper.selectTableById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分列表
|
||||
*
|
||||
* @param table 分
|
||||
* @return 分
|
||||
*/
|
||||
@Override
|
||||
public List<Table> selectTableList(Table table)
|
||||
{
|
||||
return tableMapper.selectTableList(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTable(Table table)
|
||||
{
|
||||
table.setId(IdUtil.getSnowflakeNextId());
|
||||
table.setCreateTime(DateUtils.getNowDate());
|
||||
return tableMapper.insertTable(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分
|
||||
*
|
||||
* @param table 分
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTable(Table table)
|
||||
{
|
||||
table.setUpdateTime(DateUtils.getNowDate());
|
||||
return tableMapper.updateTable(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除分
|
||||
*
|
||||
* @param ids 需要删除的分主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTableByIds(Long[] ids)
|
||||
{
|
||||
return tableMapper.deleteTableByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分信息
|
||||
*
|
||||
* @param id 分主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTableById(Long id)
|
||||
{
|
||||
return tableMapper.deleteTableById(id);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,14 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.shardingsphere</groupId>
|
||||
<artifactId>shardingsphere-spring-boot-starter</artifactId>
|
||||
<version>5.0.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.ff.quartz.task;
|
||||
|
||||
|
||||
import com.ff.base.table.service.ITableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* 表格作业
|
||||
*
|
||||
* @author shi
|
||||
* @date 2025/03/28
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("tablesJob")
|
||||
public class TablesJob {
|
||||
|
||||
@Autowired
|
||||
private ITableService tableService;
|
||||
|
||||
public void checkTablesJob() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 检查当前小时表
|
||||
checkAndCreateTable(now);
|
||||
// 检查前一小时表(处理跨天情况)
|
||||
checkAndCreateTable(now.minusHours(1));
|
||||
}
|
||||
private void checkAndCreateTable(LocalDateTime time) {
|
||||
String tableSuffix = time.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
||||
String tableName = "ff_game_betting_details_" + tableSuffix;
|
||||
|
||||
if (!tableManager.isTableExists(tableName)) {
|
||||
tableManager.createHourTable(tableName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -76,6 +76,8 @@ spring:
|
|||
config:
|
||||
multi-statement-allow: true
|
||||
|
||||
|
||||
|
||||
forest:
|
||||
backend: okhttp3 # 后端HTTP框架(默认为 okhttp3)
|
||||
max-connections: 1000 # 连接池最大连接数(默认为 500)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<?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="com.ff.base.table.mapper.TableMapper">
|
||||
|
||||
<resultMap type="Table" id="TableResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="tableName" column="table_name" />
|
||||
<result property="tableField" column="table_field" />
|
||||
<result property="type" column="type" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTableVo">
|
||||
select id, table_name, table_field, type, create_by, create_time, update_by, update_time from ff_table
|
||||
</sql>
|
||||
|
||||
<select id="selectTableList" parameterType="Table" resultMap="TableResult">
|
||||
<include refid="selectTableVo"/>
|
||||
<where>
|
||||
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
|
||||
<if test="tableField != null and tableField != ''"> and table_field = #{tableField}</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTableById" parameterType="Long" resultMap="TableResult">
|
||||
<include refid="selectTableVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertTable" parameterType="Table">
|
||||
insert into ff_table
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="tableName != null">table_name,</if>
|
||||
<if test="tableField != null">table_field,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="tableName != null">#{tableName},</if>
|
||||
<if test="tableField != null">#{tableField},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTable" parameterType="Table">
|
||||
update ff_table
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="tableName != null">table_name = #{tableName},</if>
|
||||
<if test="tableField != null">table_field = #{tableField},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTableById" parameterType="Long">
|
||||
delete from ff_table where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTableByIds" parameterType="String">
|
||||
delete from ff_table where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue