feat(agent): 添加代理注册功能并优化租户创建逻辑

- 新增代理注册相关字段和方法- 重构租户创建逻辑,支持信誉额度充值
- 优化数据库表结构,增加注册时间和IP等信息
- 调整代码格式,提高可读性
main-p
shi 2025-02-25 11:37:06 +08:00
parent 0193cf9efc
commit 7b5ab5fd92
19 changed files with 546 additions and 260 deletions

View File

@ -4,18 +4,24 @@ package com.ff.agent.contoller;
import cn.hutool.core.util.IdUtil;
import com.ff.agent.dto.AgentTenantSecretKeyDTO;
import com.ff.agent.request.AgentCreateTenantRequest;
import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.page.TableDataInfo;
import com.ff.base.enums.OperationType;
import com.ff.base.enums.QuotaType;
import com.ff.base.system.dto.TenantSecretKeyDTO;
import com.ff.base.system.service.ISysDeptService;
import com.ff.base.system.service.ISysRoleService;
import com.ff.base.system.service.ISysUserService;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.SecurityUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.base.utils.ip.IpUtils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.base.system.service.ITenantSecretKeyService;
import lombok.extern.slf4j.Slf4j;
@ -23,6 +29,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -98,10 +105,13 @@ public class AgentController extends BaseController {
.tenantKey(agentCreateTenantRequest.getAccount())
.build())), MessageUtils.message("operation.tenant.account.already.used"));
Assert.isTrue(agentCreateTenantRequest.getPassword().equals(agentCreateTenantRequest.getConfirmPassword()),MessageUtils.message("operation.password.mismatch"));
//创建租户
TenantSecretKey tenantSecretKey = new TenantSecretKey();
tenantSecretKey.setAgentId(getUserId());
tenantSecretKey.setRegisterIp(IpUtils.getIpAddr());
tenantSecretKey.setRegisterTime(DateUtils.getNowDate());
tenantSecretKey.setTenantKey(agentCreateTenantRequest.getAccount());
tenantSecretKey.setPassword(SecurityUtils.encryptPassword(agentCreateTenantRequest.getPassword()));
tenantSecretKey.setTenantSn(tenantSecretKeyService.generateTenantSn());
@ -112,7 +122,19 @@ public class AgentController extends BaseController {
tenantSecretKey.setTenantStatus(Boolean.TRUE);
int insertedTenantSecretKey = tenantSecretKeyService.insertTenantSecretKey(tenantSecretKey);
//信誉额度
if (!ObjectUtils.isEmpty(agentCreateTenantRequest.getRealBalance())){
tenantGameQuotaService.balanceChanges(BalanceChangesDTO.builder()
.isOut(Boolean.TRUE)
.currencyCode(Constants.USDT)
.tenantKey(agentCreateTenantRequest.getAccount())
.balance(agentCreateTenantRequest.getRealBalance())
.operationType(OperationType.TENANT_RECHARGE.getCode())
.quotaType(QuotaType.REPUTATION.getCode())
.remark(OperationType.TENANT_RECHARGE.getDescription())
.build());
}
return toAjax(insertedTenantSecretKey);
}

View File

@ -1,6 +1,7 @@
package com.ff.agent.request;
import com.ff.base.annotation.Excel;
import com.ff.base.xss.Xss;
import lombok.Data;
@ -34,12 +35,12 @@ public class AgentCreateTenantRequest implements Serializable {
@NotBlank(message = "密码不能为空")
@Size(min = 5, max = 20, message = "密码长度不能超过25个字符")
private String password;
/**
*
*/
@NotBlank(message = "确认密码不能为空")
@Size(min = 5, max = 20, message = "密码长度不能超过25个字符")
private String confirmPassword;
/** 买分比例 */
@NotNull(message = "买分比例不能为空")
private BigDecimal scoreRatio;
/** 租户类型 TenantType 枚举 */

View File

@ -1,104 +0,0 @@
package com.ff.common.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.system.domain.TenantSecretKey;
import com.ff.base.system.service.ITenantSecretKeyService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;
/**
* Controller
*
* @author shi
* @date 2025-02-11
*/
@RestController
@RequestMapping("/common/key")
public class TenantSecretKeyController extends BaseController
{
@Autowired
private ITenantSecretKeyService tenantSecretKeyService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:list')")
@GetMapping("/list")
public TableDataInfo list(TenantSecretKey tenantSecretKey)
{
startPage();
List<TenantSecretKey> list = tenantSecretKeyService.selectTenantSecretKeyList(tenantSecretKey);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:export')")
@Log(title = "用户租户密钥", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TenantSecretKey tenantSecretKey)
{
List<TenantSecretKey> list = tenantSecretKeyService.selectTenantSecretKeyList(tenantSecretKey);
ExcelUtil<TenantSecretKey> util = new ExcelUtil<TenantSecretKey>(TenantSecretKey.class);
util.exportExcel(response, list, "用户租户密钥数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(tenantSecretKeyService.selectTenantSecretKeyById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:add')")
@Log(title = "用户租户密钥", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TenantSecretKey tenantSecretKey)
{
return toAjax(tenantSecretKeyService.insertTenantSecretKey(tenantSecretKey));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:edit')")
@Log(title = "用户租户密钥", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TenantSecretKey tenantSecretKey)
{
return toAjax(tenantSecretKeyService.updateTenantSecretKey(tenantSecretKey));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('common:key:remove')")
@Log(title = "用户租户密钥", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(tenantSecretKeyService.deleteTenantSecretKeyByIds(ids));
}
}

View File

@ -1,40 +0,0 @@
package com.ff.common.domain;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ff_tenant_agent
*
* @author shi
* @date 2025-02-20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TenantAgent extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;
/** 账号 */
@Excel(name = "账号")
private String account;
/** 密码 */
@Excel(name = "密码")
private String password;
/** 代理状态 1正常 0停用 */
@Excel(name = "代理状态 1正常 0停用")
private Boolean agentStatus;
}

View File

@ -28,6 +28,7 @@ import com.ff.game.domain.GameSecretKey;
import com.ff.game.service.IGameSecretKeyService;
import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService;
import nonapi.io.github.classgraph.json.Id;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ff.common.mapper.TenantGameQuotaMapper;
@ -440,6 +441,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
if (ObjectUtils.isEmpty(tenantGameQuota)) {
tenantGameQuota = TenantGameQuota.builder()
.tenantKey(tenantKey)
.id(IdUtil.getSnowflakeNextId())
.balance(BigDecimal.ZERO)
.quotaType(quotaType)
.version(0)

View File

@ -1,5 +1,6 @@
package com.ff.game.api.jili.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
@ -650,6 +651,7 @@ public class GamesJILIServiceImpl implements IGamesService {
for (JILIBetRecordDataResponseDTO jiliBetRecordDataResponseDTO : dataBean.getResult()) {
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().data(jiliBetRecordDataResponseDTO).build());
if (!ObjectUtils.isEmpty(bettingDetails)) {
bettingDetails.setId(IdUtil.getSnowflakeNextId());
gameBettingDetails.add(bettingDetails);
}
wagersIds.add(jiliBetRecordDataResponseDTO.getWagersId());

View File

@ -1,5 +1,6 @@
package com.ff.game.api.xk.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
@ -510,6 +511,7 @@ public class GamesXKServiceImpl implements IGamesService {
for (XKBetRecordResponseDTO.DataBean.ResultBean bean : dataBean.getResult()) {
GameBettingDetails bettingDetails = this.dataBuild(GamesDataBuildDTO.builder().data(bean).build());
if (!ObjectUtils.isEmpty(bettingDetails)) {
bettingDetails.setId(IdUtil.getSnowflakeNextId());
gameBettingDetails.add(bettingDetails);
}
wagersIds.add(bean.getWagersId());

View File

@ -1,95 +1,171 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ff.common.mapper.TenantGameQuotaMapper">
<resultMap type="TenantGameQuota" id="TenantGameQuotaResult">
<result property="id" column="id" />
<result property="tenantKey" column="tenant_key" />
<result property="balance" column="balance" />
<result property="quotaType" column="quota_type" />
<result property="version" column="version" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="id" column="id"/>
<result property="tenantKey" column="tenant_key"/>
<result property="balance" column="balance"/>
<result property="quotaType" column="quota_type"/>
<result property="version" column="version"/>
<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="selectTenantGameQuotaVo">
select id, tenant_key, balance, quota_type, version, create_by, create_time, update_by, update_time from ff_tenant_game_quota
select id,
tenant_key,
balance,
quota_type,
version,
create_by,
create_time,
update_by,
update_time
from ff_tenant_game_quota
</sql>
<select id="selectTenantGameQuotaByTenantKey" resultMap="TenantGameQuotaResult">
<select id="selectTenantGameQuotaByTenantKey" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
where tenant_key = #{tenantKey} and quota_type = #{quotaType}
where tenant_key = #{tenantKey} and quota_type = #{quotaType}
</select>
<select id="selectTenantGameQuotaList" parameterType="TenantGameQuota" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
<where>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="quotaType != null and quotaType != ''"> and quota_type = #{quotaType}</if>
<if test="version != null "> and version = #{version}</if>
<where>
<if test="tenantKey != null and tenantKey != ''">
and tenant_key = #{tenantKey}
</if>
<if test="balance != null ">
and balance = #{balance}
</if>
<if test="quotaType != null and quotaType != ''">
and quota_type = #{quotaType}
</if>
<if test="version != null ">
and version = #{version}
</if>
</where>
</select>
<select id="selectTenantGameQuotaById" parameterType="Long" resultMap="TenantGameQuotaResult">
<include refid="selectTenantGameQuotaVo"/>
where id = #{id}
</select>
<update id="changeBalance" parameterType="TenantGameQuota">
update ff_tenant_game_quota set balance = #{balance},version =version+1
where tenant_key = #{tenantKey} and quota_type = #{quotaType} and version = #{version}
update ff_tenant_game_quota
set balance = #{balance},
version =version + 1
where tenant_key = #{tenantKey}
and quota_type = #{quotaType}
and version = #{version}
</update>
<insert id="insertTenantGameQuota" parameterType="TenantGameQuota" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="balance != null">balance,</if>
<if test="quotaType != null">quota_type,</if>
<if test="version != null">version,</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="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="balance != null">#{balance},</if>
<if test="quotaType != null">#{quotaType},</if>
<if test="version != null">#{version},</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>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="tenantKey != null and tenantKey != ''">
tenant_key,
</if>
<if test="balance != null">
balance,
</if>
<if test="quotaType != null">
quota_type,
</if>
<if test="version != null">
version,
</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="tenantKey != null and tenantKey != ''">
#{tenantKey},
</if>
<if test="balance != null">
#{balance},
</if>
<if test="quotaType != null">
#{quotaType},
</if>
<if test="version != null">
#{version},
</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="updateTenantGameQuota" parameterType="TenantGameQuota">
update ff_tenant_game_quota
<trim prefix="SET" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="balance != null">balance = #{balance},</if>
<if test="quotaType != null">quota_type = #{quotaType},</if>
<if test="version != null">version = #{version},</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>
<if test="tenantKey != null and tenantKey != ''">
tenant_key = #{tenantKey},
</if>
<if test="balance != null">
balance = #{balance},
</if>
<if test="quotaType != null">
quota_type = #{quotaType},
</if>
<if test="version != null">
version = #{version},
</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="deleteTenantGameQuotaById" parameterType="Long">
delete from ff_tenant_game_quota where id = #{id}
delete
from ff_tenant_game_quota
where id = #{id}
</delete>
<delete id="deleteTenantGameQuotaByIds" parameterType="String">
delete from ff_tenant_game_quota where id in
delete from ff_tenant_game_quota where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -191,7 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_betting_details
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<trim prefix="(" suffix=")" suffixOverrides=",">id,
tenant_key, game_id, currency_code, member_id, game_code, game_type, platform_code,
game_name, game_status, game_status_type, game_currency_code, account,
wagers_id, wagers_time, bet_amount, payoff_time, payoff_amount,
@ -199,7 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<trim prefix="(" suffix=")" suffixOverrides=",">#{item.id},
#{item.tenantKey},
#{item.gameId},
#{item.currencyCode},

View File

@ -11,7 +11,8 @@ import lombok.Getter;
@Getter
public enum OperationType {
API_BALANCE(1, "租户游玩操作余额"),
REAL_BALANCE_SETTLEMENT(2, "日用额度结算")
REAL_BALANCE_SETTLEMENT(2, "日用额度结算"),
TENANT_RECHARGE(3, "信誉额度充值")
;
private final Integer code;

View File

@ -0,0 +1,60 @@
package com.ff.base.system.domain;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ff_tenant_agent
*
* @author shi
* @date 2025-02-25
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TenantAgent extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;
/** 账号 */
@Excel(name = "账号")
private String account;
/** 密码 */
@Excel(name = "密码")
private String password;
/** 注册时间 */
@Excel(name = "注册时间")
private Long registerTime;
/** 注册IP */
@Excel(name = "注册IP")
private String registerIp;
/** 注册ip的城市 */
@Excel(name = "注册ip的城市")
private String registerIpCity;
/** 最后登录ip */
@Excel(name = "最后登录ip")
private String loginIp;
/** 最后登录时间 */
@Excel(name = "最后登录时间")
private Long loginData;
/** 租户状态 1正常 0停用 */
@Excel(name = "租户状态 1正常 0停用")
private Boolean tenantStatus;
}

View File

@ -1,9 +1,6 @@
package com.ff.base.system.domain;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
@ -15,7 +12,7 @@ import lombok.NoArgsConstructor;
* ff_tenant_secret_key
*
* @author shi
* @date 2025-02-20
* @date 2025-02-25
*/
@Data
@AllArgsConstructor
@ -28,14 +25,26 @@ public class TenantSecretKey extends BaseEntity
/** 主键id */
private Long id;
/** 租户key */
@Excel(name = "租户key")
private String tenantKey;
/** 密码 */
@Excel(name = "密码")
@JsonIgnore
private String password;
/** 注册时间 */
@Excel(name = "注册时间")
private Long registerTime;
/** 注册ip */
@Excel(name = "注册ip")
private String registerIp;
/** 注册ip的城市 */
@Excel(name = "注册ip的城市")
private String registerIpCity;
/** 最后登录ip */
@Excel(name = "最后登录ip")
private String loginIp;
@ -44,26 +53,16 @@ public class TenantSecretKey extends BaseEntity
@Excel(name = "最后登录时间")
private Long loginData;
/** 租户key */
@Excel(name = "租户key")
private String tenantKey;
/** 代理id */
@Excel(name = "代理id")
/** 上级代理id */
@Excel(name = "上级代理id")
private Long agentId;
/** 商户后缀 */
@Excel(name = "商户后缀")
@JsonIgnore
private String tenantSn;
/** 租户密钥 */
@Excel(name = "租户密钥")
@JsonIgnore
private String tenantSecret;
/** 租户状态 1正常 0停用 */

View File

@ -0,0 +1,62 @@
package com.ff.base.system.mapper;
import com.ff.base.system.domain.TenantAgent;
import java.util.List;
/**
* Mapper
*
* @author shi
* @date 2025-02-25
*/
public interface TenantAgentMapper
{
/**
*
*
* @param id
* @return
*/
TenantAgent selectTenantAgentById(Long id);
/**
*
*
* @param tenantAgent
* @return
*/
List<TenantAgent> selectTenantAgentList(TenantAgent tenantAgent);
/**
*
*
* @param tenantAgent
* @return
*/
int insertTenantAgent(TenantAgent tenantAgent);
/**
*
*
* @param tenantAgent
* @return
*/
int updateTenantAgent(TenantAgent tenantAgent);
/**
*
*
* @param id
* @return
*/
int deleteTenantAgentById(Long id);
/**
*
*
* @param ids
* @return
*/
int deleteTenantAgentByIds(Long[] ids);
}

View File

@ -0,0 +1,62 @@
package com.ff.base.system.service;
import com.ff.base.system.domain.TenantAgent;
import java.util.List;
/**
* Service
*
* @author shi
* @date 2025-02-25
*/
public interface ITenantAgentService
{
/**
*
*
* @param id
* @return
*/
TenantAgent selectTenantAgentById(Long id);
/**
*
*
* @param tenantAgent
* @return
*/
List<TenantAgent> selectTenantAgentList(TenantAgent tenantAgent);
/**
*
*
* @param tenantAgent
* @return
*/
int insertTenantAgent(TenantAgent tenantAgent);
/**
*
*
* @param tenantAgent
* @return
*/
int updateTenantAgent(TenantAgent tenantAgent);
/**
*
*
* @param ids
* @return
*/
int deleteTenantAgentByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
int deleteTenantAgentById(Long id);
}

View File

@ -0,0 +1,97 @@
package com.ff.base.system.service.impl;
import java.util.List;
import com.ff.base.system.domain.TenantAgent;
import com.ff.base.system.mapper.TenantAgentMapper;
import com.ff.base.system.service.ITenantAgentService;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author shi
* @date 2025-02-25
*/
@Service
public class TenantAgentServiceImpl implements ITenantAgentService
{
@Autowired
private TenantAgentMapper tenantAgentMapper;
/**
*
*
* @param id
* @return
*/
@Override
public TenantAgent selectTenantAgentById(Long id)
{
return tenantAgentMapper.selectTenantAgentById(id);
}
/**
*
*
* @param tenantAgent
* @return
*/
@Override
public List<TenantAgent> selectTenantAgentList(TenantAgent tenantAgent)
{
return tenantAgentMapper.selectTenantAgentList(tenantAgent);
}
/**
*
*
* @param tenantAgent
* @return
*/
@Override
public int insertTenantAgent(TenantAgent tenantAgent)
{
tenantAgent.setCreateTime(DateUtils.getNowDate());
return tenantAgentMapper.insertTenantAgent(tenantAgent);
}
/**
*
*
* @param tenantAgent
* @return
*/
@Override
public int updateTenantAgent(TenantAgent tenantAgent)
{
tenantAgent.setUpdateTime(DateUtils.getNowDate());
return tenantAgentMapper.updateTenantAgent(tenantAgent);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTenantAgentByIds(Long[] ids)
{
return tenantAgentMapper.deleteTenantAgentByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTenantAgentById(Long id)
{
return tenantAgentMapper.deleteTenantAgentById(id);
}
}

View File

@ -2,13 +2,18 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ff.common.mapper.TenantAgentMapper">
<mapper namespace="com.ff.base.system.mapper.TenantAgentMapper">
<resultMap type="TenantAgent" id="TenantAgentResult">
<result property="id" column="id" />
<result property="account" column="account" />
<result property="password" column="password" />
<result property="agentStatus" column="agent_status" />
<result property="registerTime" column="register_time" />
<result property="registerIp" column="register_ip" />
<result property="registerIpCity" column="register_ip_city" />
<result property="loginIp" column="login_ip" />
<result property="loginData" column="login_data" />
<result property="tenantStatus" column="tenant_status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
@ -16,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTenantAgentVo">
select id, account, password, agent_status, create_by, create_time, update_by, update_time from ff_tenant_agent
select id, account, password, register_time, register_ip, register_ip_city, login_ip, login_data, tenant_status, create_by, create_time, update_by, update_time from ff_tenant_agent
</sql>
<select id="selectTenantAgentList" parameterType="TenantAgent" resultMap="TenantAgentResult">
@ -24,7 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="account != null and account != ''"> and account = #{account}</if>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="agentStatus != null "> and agent_status = #{agentStatus}</if>
<if test="registerTime != null "> and register_time = #{registerTime}</if>
<if test="registerIp != null and registerIp != ''"> and register_ip = #{registerIp}</if>
<if test="registerIpCity != null and registerIpCity != ''"> and register_ip_city = #{registerIpCity}</if>
<if test="loginIp != null and loginIp != ''"> and login_ip = #{loginIp}</if>
<if test="loginData != null "> and login_data = #{loginData}</if>
<if test="tenantStatus != null "> and tenant_status = #{tenantStatus}</if>
</where>
</select>
@ -35,19 +45,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTenantAgent" parameterType="TenantAgent" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_agent
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="account != null">account,</if>
<if test="password != null">password,</if>
<if test="agentStatus != null">agent_status,</if>
<if test="registerTime != null">register_time,</if>
<if test="registerIp != null">register_ip,</if>
<if test="registerIpCity != null">register_ip_city,</if>
<if test="loginIp != null">login_ip,</if>
<if test="loginData != null">login_data,</if>
<if test="tenantStatus != null">tenant_status,</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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="account != null">#{account},</if>
<if test="password != null">#{password},</if>
<if test="agentStatus != null">#{agentStatus},</if>
<if test="registerTime != null">#{registerTime},</if>
<if test="registerIp != null">#{registerIp},</if>
<if test="registerIpCity != null">#{registerIpCity},</if>
<if test="loginIp != null">#{loginIp},</if>
<if test="loginData != null">#{loginData},</if>
<if test="tenantStatus != null">#{tenantStatus},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
@ -60,7 +80,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="account != null">account = #{account},</if>
<if test="password != null">password = #{password},</if>
<if test="agentStatus != null">agent_status = #{agentStatus},</if>
<if test="registerTime != null">register_time = #{registerTime},</if>
<if test="registerIp != null">register_ip = #{registerIp},</if>
<if test="registerIpCity != null">register_ip_city = #{registerIpCity},</if>
<if test="loginIp != null">login_ip = #{loginIp},</if>
<if test="loginData != null">login_data = #{loginData},</if>
<if test="tenantStatus != null">tenant_status = #{tenantStatus},</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>

View File

@ -6,10 +6,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="TenantSecretKey" id="TenantSecretKeyResult">
<result property="id" column="id" />
<result property="tenantKey" column="tenant_key" />
<result property="password" column="password" />
<result property="registerTime" column="register_time" />
<result property="registerIp" column="register_ip" />
<result property="registerIpCity" column="register_ip_city" />
<result property="loginIp" column="login_ip" />
<result property="loginData" column="login_data" />
<result property="tenantKey" column="tenant_key" />
<result property="agentId" column="agent_id" />
<result property="tenantSn" column="tenant_sn" />
<result property="tenantSecret" column="tenant_secret" />
@ -25,34 +28,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTenantSecretKeyVo">
select id, password, login_ip, login_data, tenant_key, agent_id, tenant_sn, tenant_secret, tenant_status, quota_type, score_ratio, tenant_type, deposit_ratio, create_by, create_time, update_by, update_time from ff_tenant_secret_key
select id, tenant_key, password, register_time, register_ip, register_ip_city, login_ip, login_data, agent_id, tenant_sn, tenant_secret, tenant_status, quota_type, score_ratio, tenant_type, deposit_ratio, create_by, create_time, update_by, update_time from ff_tenant_secret_key
</sql>
<select id="selectTenantSecretKeyList" parameterType="TenantSecretKey" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
<where>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="loginIp != null and loginIp != ''"> and login_ip = #{loginIp}</if>
<if test="loginData != null "> and login_data = #{loginData}</if>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="agentId != null "> and agent_id = #{agentId}</if>
<if test="tenantSn != null and tenantSn != ''"> and tenant_sn = #{tenantSn}</if>
<if test="tenantSecret != null and tenantSecret != ''"> and tenant_secret = #{tenantSecret}</if>
<if test="tenantStatus != null "> and tenant_status = #{tenantStatus}</if>
<if test="quotaType != null "> and quota_type = #{quotaType}</if>
<if test="scoreRatio != null "> and score_ratio = #{scoreRatio}</if>
<if test="tenantType != null "> and tenant_type = #{tenantType}</if>
<if test="depositRatio != null "> and deposit_ratio = #{depositRatio}</if>
</where>
</select>
<select id="selectTenantSecretKeyDTOList" parameterType="com.ff.base.system.dto.TenantSecretKeyDTO" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
<where>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="registerTime != null "> and register_time = #{registerTime}</if>
<if test="registerIp != null and registerIp != ''"> and register_ip = #{registerIp}</if>
<if test="registerIpCity != null and registerIpCity != ''"> and register_ip_city = #{registerIpCity}</if>
<if test="loginIp != null and loginIp != ''"> and login_ip = #{loginIp}</if>
<if test="loginData != null "> and login_data = #{loginData}</if>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key like concat('%',#{tenantKey},'%') </if>
<if test="agentId != null "> and agent_id = #{agentId}</if>
<if test="tenantSn != null and tenantSn != ''"> and tenant_sn = #{tenantSn}</if>
<if test="tenantSecret != null and tenantSecret != ''"> and tenant_secret = #{tenantSecret}</if>
@ -71,12 +59,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTenantSecretKey" parameterType="TenantSecretKey" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_secret_key
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="password != null">password,</if>
<if test="registerTime != null">register_time,</if>
<if test="registerIp != null">register_ip,</if>
<if test="registerIpCity != null">register_ip_city,</if>
<if test="loginIp != null">login_ip,</if>
<if test="loginData != null">login_data,</if>
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="agentId != null">agent_id,</if>
<if test="tenantSn != null">tenant_sn,</if>
<if test="tenantSecret != null and tenantSecret != ''">tenant_secret,</if>
@ -90,12 +81,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="password != null">#{password},</if>
<if test="registerTime != null">#{registerTime},</if>
<if test="registerIp != null">#{registerIp},</if>
<if test="registerIpCity != null">#{registerIpCity},</if>
<if test="loginIp != null">#{loginIp},</if>
<if test="loginData != null">#{loginData},</if>
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="agentId != null">#{agentId},</if>
<if test="tenantSn != null">#{tenantSn},</if>
<if test="tenantSecret != null and tenantSecret != ''">#{tenantSecret},</if>
@ -114,10 +108,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateTenantSecretKey" parameterType="TenantSecretKey">
update ff_tenant_secret_key
<trim prefix="SET" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="password != null">password = #{password},</if>
<if test="registerTime != null">register_time = #{registerTime},</if>
<if test="registerIp != null">register_ip = #{registerIp},</if>
<if test="registerIpCity != null">register_ip_city = #{registerIpCity},</if>
<if test="loginIp != null">login_ip = #{loginIp},</if>
<if test="loginData != null">login_data = #{loginData},</if>
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="agentId != null">agent_id = #{agentId},</if>
<if test="tenantSn != null">tenant_sn = #{tenantSn},</if>
<if test="tenantSecret != null and tenantSecret != ''">tenant_secret = #{tenantSecret},</if>
@ -145,6 +142,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from ff_tenant_secret_key where id = #{id}
</delete>
<select id="selectTenantSecretKeyDTOList" parameterType="com.ff.base.system.dto.TenantSecretKeyDTO" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
<where>
<if test="password != null and password != ''"> and password = #{password}</if>
<if test="loginIp != null and loginIp != ''"> and login_ip = #{loginIp}</if>
<if test="loginData != null "> and login_data = #{loginData}</if>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key like concat('%',#{tenantKey},'%') </if>
<if test="agentId != null "> and agent_id = #{agentId}</if>
<if test="tenantSn != null and tenantSn != ''"> and tenant_sn = #{tenantSn}</if>
<if test="tenantSecret != null and tenantSecret != ''"> and tenant_secret = #{tenantSecret}</if>
<if test="tenantStatus != null "> and tenant_status = #{tenantStatus}</if>
<if test="quotaType != null "> and quota_type = #{quotaType}</if>
<if test="scoreRatio != null "> and score_ratio = #{scoreRatio}</if>
<if test="tenantType != null "> and tenant_type = #{tenantType}</if>
<if test="depositRatio != null "> and deposit_ratio = #{depositRatio}</if>
</where>
</select>
<delete id="deleteTenantSecretKeyByIds" parameterType="String">
delete from ff_tenant_secret_key where id in
<foreach item="id" collection="array" open="(" separator="," close=")">

View File

@ -1,5 +1,6 @@
package com.ff.gen.service;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ff.base.constant.Constants;
@ -331,6 +332,7 @@ public class GenTableServiceImpl implements IGenTableService
}
else
{
column.setColumnId(IdUtil.getSnowflakeNextId());
genTableColumnMapper.insertGenTableColumn(column);
}
});

View File

@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
insert into gen_table_column (
<if test="columnId != null">column_id,</if>
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>
<if test="columnComment != null and columnComment != ''">column_comment,</if>
@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="columnId != null">#{columnId},</if>
<if test="tableId != null and tableId != ''">#{tableId},</if>
<if test="columnName != null and columnName != ''">#{columnName},</if>
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>