refactor(agent): 重构代理商业务

- 新增 AgentController 类,实现代理商业务功能
- 重构 AgentCreateTenantRequest 类,添加数据校验注解
- 新增 AgentTenantSecretKeyDTO 类,用于代理租户密钥展示
- 删除 ApiAgentController 类,将相关功能合并到 AgentController- 更新相关服务类和 Mapper 类,调整字段和方法以适应新的业务逻辑
main-p
shi 2025-02-25 10:05:13 +08:00
parent 1e495270a9
commit 513c3a015c
99 changed files with 1348 additions and 1013 deletions

View File

@ -87,11 +87,8 @@
<artifactId>socket.io-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>

View File

@ -1,6 +1,5 @@
package com.ff;
import com.ff.base.config.IdGeneratorUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
@ -22,10 +21,9 @@ import org.springframework.security.authentication.dao.DaoAuthenticationProvider
@MapperScan({"com.ff.base.system.mapper","com.ff.quartz.mapper","com.ff.gen.mapper"})
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = DaoAuthenticationProvider.class)})
@EnableAsync
public class FFApplication implements CommandLineRunner
public class FFApplication
{
@Autowired
private IdGeneratorUtil idGeneratorUtil;
public static void main(String[] args)
@ -37,8 +35,5 @@ public class FFApplication implements CommandLineRunner
}
@Override
public void run(String... args) throws Exception {
idGeneratorUtil.init();
}
}

View File

@ -0,0 +1,124 @@
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.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.page.TableDataInfo;
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.MessageUtils;
import com.ff.base.utils.SecurityUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.base.system.service.ITenantSecretKeyService;
import lombok.extern.slf4j.Slf4j;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* api
*
* @author shi
* @date 2025/02/10
*/
@RestController
@RequestMapping("/agent/tenant")
@Slf4j
public class AgentController extends BaseController {
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
@Resource
private ITenantGameQuotaService tenantGameQuotaService;
@Resource
private ISysRoleService roleService;
@Resource
private ISysDeptService deptService;
@Resource
private ISysUserService userService;
/**
*
*
* @param tenantSecretKeyDTO
* @return {@link TableDataInfo }
*/
@GetMapping("/list")
@Transactional
@PreAuthorize("@ss.hasPermi('agent:tenant:list')")
public TableDataInfo list(TenantSecretKeyDTO tenantSecretKeyDTO) {
startPage();
tenantSecretKeyDTO.setAgentId(getUserId());
List<TenantSecretKey> tenantSecretKeys = tenantSecretKeyService.selectTenantSecretKeyDTOList(tenantSecretKeyDTO);
TableDataInfo dataTable = getDataTable(tenantSecretKeys);
List<AgentTenantSecretKeyDTO> list=new ArrayList<>();
for (TenantSecretKey row : (List<TenantSecretKey>) dataTable.getRows()) {
AgentTenantSecretKeyDTO agentTenantSecretKeyDTO=new AgentTenantSecretKeyDTO();
BeanUtils.copyProperties(row, agentTenantSecretKeyDTO);
list.add(agentTenantSecretKeyDTO);
}
dataTable.setRows(list);
return dataTable;
}
/**
*
*
* @return {@link AjaxResult }
*/
@PostMapping("/create")
@Transactional
@PreAuthorize("@ss.hasPermi('agent:tenant:create')")
public AjaxResult createTenant(@Validated @RequestBody AgentCreateTenantRequest agentCreateTenantRequest) {
Assert.isTrue(CollectionUtils.isEmpty(tenantSecretKeyService.selectTenantSecretKeyList(TenantSecretKey.builder()
.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.setTenantKey(agentCreateTenantRequest.getAccount());
tenantSecretKey.setPassword(SecurityUtils.encryptPassword(agentCreateTenantRequest.getPassword()));
tenantSecretKey.setTenantSn(tenantSecretKeyService.generateTenantSn());
tenantSecretKey.setTenantSecret(IdUtils.simpleUUID());
tenantSecretKey.setDepositRatio(agentCreateTenantRequest.getDepositRatio());
tenantSecretKey.setTenantType(agentCreateTenantRequest.getTenantType());
tenantSecretKey.setCreateBy(getUsername());
tenantSecretKey.setTenantStatus(Boolean.TRUE);
int insertedTenantSecretKey = tenantSecretKeyService.insertTenantSecretKey(tenantSecretKey);
return toAjax(insertedTenantSecretKey);
}
}

View File

@ -0,0 +1,89 @@
package com.ff.agent.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
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;
import java.math.BigDecimal;
/**
* ff_tenant_secret_key
*
* @author shi
* @date 2025-02-20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AgentTenantSecretKeyDTO extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;
/** 密码 */
@Excel(name = "密码")
@JsonIgnore
private String password;
/** 最后登录ip */
@Excel(name = "最后登录ip")
private String loginIp;
/** 最后登录时间 */
@Excel(name = "最后登录时间")
private Long loginData;
/** 租户key */
@Excel(name = "租户key")
private String tenantKey;
/** 代理id */
@Excel(name = "代理id")
private Long agentId;
/** 商户后缀 */
@Excel(name = "商户后缀")
@JsonIgnore
private String tenantSn;
/** 租户密钥 */
@Excel(name = "租户密钥")
@JsonIgnore
private String tenantSecret;
/** 租户状态 1正常 0停用 */
@Excel(name = "租户状态 1正常 0停用")
private Boolean tenantStatus;
/** 额度类型 TenantQuotaType 枚举 */
@Excel(name = "额度类型 TenantQuotaType 枚举")
private Integer quotaType;
/** 买分比例 */
@Excel(name = "买分比例")
private BigDecimal scoreRatio;
/** 租户类型 TenantType 枚举 */
@Excel(name = "租户类型 TenantType 枚举")
private Integer tenantType;
/** 透支比例 */
@Excel(name = "透支比例")
private BigDecimal depositRatio;
}

View File

@ -0,0 +1,58 @@
package com.ff.agent.request;
import com.ff.base.xss.Xss;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*
*
* @author shi
* @date 2025/02/20
*/
@Data
public class AgentCreateTenantRequest implements Serializable {
private static final long serialVersionUID = -5561068216486978354L;
/**
*
*/
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 2, max = 30, message = "用户账号长度不能超过30个字符")
private String account;
/**
*
*/
@NotBlank(message = "密码不能为空")
@Size(min = 5, max = 20, message = "密码长度不能超过25个字符")
private String password;
/**
*
*/
@NotBlank(message = "确认密码不能为空")
@Size(min = 5, max = 20, message = "密码长度不能超过25个字符")
private String confirmPassword;
/** 租户类型 TenantType 枚举 */
@NotNull(message = "租户类型不能为空")
private Integer tenantType;
/** 信誉额度*/
private BigDecimal realBalance;
/** 透支比例 */
private BigDecimal depositRatio;
}

View File

@ -3,8 +3,8 @@ package com.ff.annotation;
import com.ff.base.constant.Constants;
import com.ff.config.KeyConfig;
import com.ff.base.utils.sign.Md5Utils;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.service.ITenantSecretKeyService;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.system.service.ITenantSecretKeyService;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

View File

@ -1,81 +0,0 @@
package com.ff.api.controller;
import com.ff.annotation.CheckHeader;
import com.ff.api.response.TenantInfoResponse;
import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.QuotaType;
import com.ff.base.system.service.ISysDeptService;
import com.ff.base.system.service.ISysRoleService;
import com.ff.base.utils.SecurityUtils;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.common.domain.TenantGameQuota;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.common.service.ITenantSecretKeyService;
import com.ff.config.KeyConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* api
*
* @author shi
* @date 2025/02/10
*/
@RestController
@CheckHeader
@RequestMapping("/api/agent")
@Slf4j
public class ApiAgentController extends BaseController {
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
@Resource
private ISysRoleService roleService;
@Resource
private ISysDeptService deptService;
//
// /**
// * 信息
// *
// * @return {@link AjaxResult }
// */
// @PostMapping("/create/tenant")
// public AjaxResult createTenant(TenantSecretKey tenantSecretKey) {
// roleService.selectRoleList(tenantSecretKey)
// if (!userService.checkUserNameUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
// }
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
// }
// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
// {
// return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
// }
// user.setCreateBy(getUsername());
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
// return toAjax(userService.insertUser(user));
//
// tenantSecretKey.setAgentId(getUserId());
// tenantSecretKeyService.insertTenantSecretKey(tenantSecretKey);
// return AjaxResult.success(tenantInfoResponse);
// }
}

View File

@ -12,12 +12,9 @@ import com.ff.base.core.page.TableDataInfo;
import com.ff.base.enums.*;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.QuotaUtils;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.common.domain.TenantGameQuotaFlow;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.dto.GameBalanceExchange;
import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.common.service.ITenantGameQuotaService;

View File

@ -1,7 +1,6 @@
package com.ff.api.controller;
import cn.hutool.core.bean.BeanUtil;
import com.ff.annotation.CheckHeader;
import com.ff.api.request.MemberCreateApiRequest;
import com.ff.api.request.MemberInfoAllApiRequest;
@ -14,9 +13,8 @@ import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.ErrorCode;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.manager.AsyncManager;
import com.ff.base.utils.StringUtils;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService;
import com.ff.game.api.request.*;
@ -42,7 +40,6 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
@ -99,14 +96,7 @@ public class ApiMemberController extends BaseController {
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String gameAccount = StringUtils.addSuffix(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn());
//向第三方注册账号
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
.account(gameAccount)
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.build();
Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
Assert.isTrue(result, "建立游戏账号失败");
List<Member> members = memberService.selectMemberList(Member.builder()
.tenantKey(tenantSecretKey.getTenantKey()).gameAccount(gameAccount).build());
@ -119,8 +109,17 @@ public class ApiMemberController extends BaseController {
.platformCode(memberCreateApiRequest.getPlatformCode())
.currencyCode(memberCreateApiRequest.getCurrencyCode())
.build();
return toAjax(memberService.insertMember(member));
int insertMember = memberService.insertMember(member);
Assert.isTrue(insertMember>0, "建立游戏账号失败");
}
//向第三方注册账号
CreateMemberRequestDTO gamesBaseRequestDTO = CreateMemberRequestDTO.builder()
.account(gameAccount)
.agentId(gameSecretKey.getCode())
.agentKey(gameSecretKey.getKey())
.build();
Boolean result = iGamesService.createMember(gamesBaseRequestDTO);
Assert.isTrue(result, "建立游戏账号失败");
return toAjax(Boolean.TRUE);
}
@ -152,8 +151,8 @@ public class ApiMemberController extends BaseController {
.agentKey(gameSecretKey.getKey())
.build();
MemberInfoResponseDTO memberInfo = iGamesService.getMemberInfo(gamesBaseRequestDTO);
MemberInfoResponse memberInfoResponse=new MemberInfoResponse();
BeanUtils.copyProperties(memberInfo,memberInfoResponse);
MemberInfoResponse memberInfoResponse = new MemberInfoResponse();
BeanUtils.copyProperties(memberInfo, memberInfoResponse);
return AjaxResult.success(memberInfoResponse);
}
@ -226,6 +225,4 @@ public class ApiMemberController extends BaseController {
}
}

View File

@ -8,7 +8,7 @@ import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.QuotaType;
import com.ff.base.utils.bean.BeanUtils;
import com.ff.common.domain.TenantGameQuota;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.config.KeyConfig;
import lombok.extern.slf4j.Slf4j;

View File

@ -1,46 +0,0 @@
package com.ff.api.request;
import com.ff.base.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*
*
* @author shi
* @date 2025/02/20
*/
@Data
public class AgentCreateTenant implements Serializable {
private static final long serialVersionUID = -5561068216486978354L;
/**
*
*/
private String account;
/**
*
*/
private String password;
/**
*
*/
private String confirmPassword;
/** 额度类型 TenantQuotaType 枚举 */
private Integer quotaType;
/** 买分比例 */
@Excel(name = "买分比例")
private BigDecimal scoreRatio;
/** 租户类型 TenantType 枚举 */
private Integer tenantType;
/** 透支比例 */
private BigDecimal depositRatio;
}

View File

@ -16,8 +16,8 @@ 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.common.domain.TenantSecretKey;
import com.ff.common.service.ITenantSecretKeyService;
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;

View File

@ -1,6 +1,8 @@
package com.ff.common.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableId;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
@ -23,6 +25,7 @@ public class TenantGameQuota extends BaseEntity
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;
/** 租户key */

View File

@ -1,6 +1,8 @@
package com.ff.common.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class CurrencyServiceImpl implements ICurrencyService
@Override
public int insertCurrency(Currency currency)
{
currency.setId(IdUtil.getSnowflakeNextId());
currency.setCreateTime(DateUtils.getNowDate());
return currencyMapper.insertCurrency(currency);
}

View File

@ -1,6 +1,8 @@
package com.ff.common.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class LangServiceImpl implements ILangService
@Override
public int insertLang(Lang lang)
{
lang.setId(IdUtil.getSnowflakeNextId());
lang.setCreateTime(DateUtils.getNowDate());
return langMapper.insertLang(lang);
}

View File

@ -3,6 +3,7 @@ package com.ff.common.service.impl;
import java.math.BigDecimal;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -51,6 +52,7 @@ public class TenantGameQuotaFlowServiceImpl implements ITenantGameQuotaFlowServi
*/
@Override
public int insertTenantGameQuotaFlow(TenantGameQuotaFlow tenantGameQuotaFlow) {
tenantGameQuotaFlow.setId(IdUtil.getSnowflakeNextId());
tenantGameQuotaFlow.setCreateTime(DateUtils.getNowDate());
return tenantGameQuotaFlowMapper.insertTenantGameQuotaFlow(tenantGameQuotaFlow);
}

View File

@ -5,23 +5,23 @@ import java.math.RoundingMode;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.ff.base.constant.Constants;
import com.ff.base.enums.*;
import com.ff.base.exception.base.ApiException;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.NumberUtils;
import com.ff.base.utils.QuotaUtils;
import com.ff.base.utils.StringUtils;
import com.ff.common.domain.TenantGameQuotaFlow;
import com.ff.common.domain.TenantQuotaExchange;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.dto.BalanceRealChangesDTO;
import com.ff.common.dto.GameBalanceExchange;
import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.common.service.ITenantQuotaExchangeService;
import com.ff.common.service.ITenantSecretKeyService;
import com.ff.base.system.service.ITenantSecretKeyService;
import com.ff.game.api.IGamesService;
import com.ff.game.api.request.MemberInfoRequestDTO;
import com.ff.game.domain.GameSecretKey;
@ -34,7 +34,6 @@ import com.ff.common.mapper.TenantGameQuotaMapper;
import com.ff.common.domain.TenantGameQuota;
import com.ff.common.service.ITenantGameQuotaService;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
@ -105,6 +104,7 @@ public class TenantGameQuotaServiceImpl implements ITenantGameQuotaService {
*/
@Override
public int insertTenantGameQuota(TenantGameQuota tenantGameQuota) {
tenantGameQuota.setId(IdUtil.getSnowflakeNextId());
tenantGameQuota.setCreateTime(DateUtils.getNowDate());
return tenantGameQuotaMapper.insertTenantGameQuota(tenantGameQuota);
}

View File

@ -1,6 +1,8 @@
package com.ff.common.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -65,6 +67,7 @@ public class TenantQuotaExchangeServiceImpl implements ITenantQuotaExchangeServi
@Override
public int insertTenantQuotaExchange(TenantQuotaExchange tenantQuotaExchange)
{
tenantQuotaExchange.setId(IdUtil.getSnowflakeNextId());
tenantQuotaExchange.setCreateTime(DateUtils.getNowDate());
return tenantQuotaExchangeMapper.insertTenantQuotaExchange(tenantQuotaExchange);
}

View File

@ -1,126 +0,0 @@
package com.ff.common.service.impl;
import java.util.List;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ff.common.mapper.TenantSecretKeyMapper;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.service.ITenantSecretKeyService;
import org.springframework.util.CollectionUtils;
/**
* Service
*
* @author shi
* @date 2025-02-11
*/
@Service
public class TenantSecretKeyServiceImpl implements ITenantSecretKeyService
{
@Autowired
private TenantSecretKeyMapper tenantSecretKeyMapper;
/**
*
*
* @param id
* @return
*/
@Override
public TenantSecretKey selectTenantSecretKeyById(Long id)
{
return tenantSecretKeyMapper.selectTenantSecretKeyById(id);
}
/**
* sn
*
* @return {@link String }
*/
@Override
public synchronized String generateTenantSn() {
String sn = NumberUtils.generateRandomCode();
while (!CollectionUtils.isEmpty(tenantSecretKeyMapper.selectTenantSecretKeyList(TenantSecretKey.builder()
.tenantSn(sn)
.build()))) {
sn = NumberUtils.generateRandomCode();
}
return sn;
}
/**
*
*
* @param tenantKey
* @return {@link TenantSecretKey }
*/
@Override
public TenantSecretKey selectTenantSecretKeyByTenantKey(String tenantKey) {
return tenantSecretKeyMapper.selectTenantSecretKeyByTenantKey(tenantKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public List<TenantSecretKey> selectTenantSecretKeyList(TenantSecretKey tenantSecretKey)
{
return tenantSecretKeyMapper.selectTenantSecretKeyList(tenantSecretKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public int insertTenantSecretKey(TenantSecretKey tenantSecretKey)
{
tenantSecretKey.setCreateTime(DateUtils.getNowDate());
return tenantSecretKeyMapper.insertTenantSecretKey(tenantSecretKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public int updateTenantSecretKey(TenantSecretKey tenantSecretKey)
{
tenantSecretKey.setUpdateTime(DateUtils.getNowDate());
return tenantSecretKeyMapper.updateTenantSecretKey(tenantSecretKey);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTenantSecretKeyByIds(Long[] ids)
{
return tenantSecretKeyMapper.deleteTenantSecretKeyByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTenantSecretKeyById(Long id)
{
return tenantSecretKeyMapper.deleteTenantSecretKeyById(id);
}
}

View File

@ -1,6 +1,6 @@
package com.ff.config;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import org.springframework.stereotype.Component;
/**

View File

@ -1,7 +1,6 @@
package com.ff.game.api.jili.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSON;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
import com.ff.base.core.redis.RedisCache;
@ -10,16 +9,9 @@ import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.http.HttpClientSslUtils;
import com.ff.base.utils.http.HttpUtils;
import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService;
import com.ff.game.api.jili.client.JILIClient;
@ -30,7 +22,6 @@ import com.ff.game.service.*;
import com.ff.member.domain.Member;
import com.ff.member.service.IMemberService;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

View File

@ -1,7 +1,6 @@
package com.ff.game.api.xk.service.impl;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson2.JSON;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
import com.ff.base.core.redis.RedisCache;
@ -15,11 +14,8 @@ import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.JsonUtil;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.http.HttpClientSslUtils;
import com.ff.base.utils.sign.Md5Utils;
import com.ff.base.utils.uuid.IdUtils;
import com.ff.common.domain.TenantSecretKey;
import com.ff.config.KeyConfig;
import com.ff.game.api.IGamesService;
import com.ff.game.api.request.*;

View File

@ -2,7 +2,7 @@ package com.ff.game.mapper;
import java.util.List;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.game.domain.GameSecretKey;
import org.apache.ibatis.annotations.Param;

View File

@ -2,7 +2,6 @@ package com.ff.game.service;
import java.util.List;
import com.ff.common.domain.TenantSecretKey;
import com.ff.game.domain.GameSecretKey;
/**

View File

@ -2,6 +2,8 @@ package com.ff.game.service.impl;
import java.util.Collections;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -65,6 +67,7 @@ public class GameBettingDetailsServiceImpl implements IGameBettingDetailsService
@Override
public int insertGameBettingDetails(GameBettingDetails gameBettingDetails)
{
gameBettingDetails.setId(IdUtil.getSnowflakeNextId());
gameBettingDetails.setCreateTime(DateUtils.getNowDate());
return gameBettingDetailsMapper.insertGameBettingDetails(gameBettingDetails);
}

View File

@ -1,6 +1,8 @@
package com.ff.game.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class GameExchangeMoneyServiceImpl implements IGameExchangeMoneyService
@Override
public int insertGameExchangeMoney(GameExchangeMoney gameExchangeMoney)
{
gameExchangeMoney.setId(IdUtil.getSnowflakeNextId());
gameExchangeMoney.setCreateTime(DateUtils.getNowDate());
return gameExchangeMoneyMapper.insertGameExchangeMoney(gameExchangeMoney);
}

View File

@ -1,6 +1,8 @@
package com.ff.game.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class GameFreeRecordServiceImpl implements IGameFreeRecordService
@Override
public int insertGameFreeRecord(GameFreeRecord gameFreeRecord)
{
gameFreeRecord.setId(IdUtil.getSnowflakeNextId());
gameFreeRecord.setCreateTime(DateUtils.getNowDate());
return gameFreeRecordMapper.insertGameFreeRecord(gameFreeRecord);
}

View File

@ -1,6 +1,8 @@
package com.ff.game.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class GamePlatformServiceImpl implements IGamePlatformService
@Override
public int insertGamePlatform(GamePlatform gamePlatform)
{
gamePlatform.setId(IdUtil.getSnowflakeNextId());
gamePlatform.setCreateTime(DateUtils.getNowDate());
return gamePlatformMapper.insertGamePlatform(gamePlatform);
}

View File

@ -1,8 +1,9 @@
package com.ff.game.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import com.ff.common.domain.TenantSecretKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ff.game.mapper.GameSecretKeyMapper;
@ -54,6 +55,7 @@ public class GameSecretKeyServiceImpl implements IGameSecretKeyService
@Override
public int insertGameSecretKey(GameSecretKey gameSecretKey)
{
gameSecretKey.setId(IdUtil.getSnowflakeNextId());
gameSecretKey.setCreateTime(DateUtils.getNowDate());
return gameSecretKeyMapper.insertGameSecretKey(gameSecretKey);
}

View File

@ -3,6 +3,7 @@ package com.ff.game.service.impl;
import java.util.Collections;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.api.response.GameResponse;
import com.ff.base.constant.ConfigConstants;
import com.ff.base.utils.DateUtils;
@ -64,6 +65,7 @@ public class GameServiceImpl implements IGameService
@Override
public int insertGame(Game game)
{
game.setId(IdUtil.getSnowflakeNextId());
game.setCreateTime(DateUtils.getNowDate());
return gameMapper.insertGame(game);
}

View File

@ -1,6 +1,8 @@
package com.ff.member.service.impl;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -53,6 +55,7 @@ public class MemberServiceImpl implements IMemberService
@Override
public int insertMember(Member member)
{
member.setId(IdUtil.getSnowflakeNextId());
member.setCreateTime(DateUtils.getNowDate());
return memberMapper.insertMember(member);
}

View File

@ -1,5 +1,6 @@
package com.ff.quartz.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.quartz.domain.SysJobLog;
import com.ff.quartz.mapper.SysJobLogMapper;
import com.ff.quartz.service.ISysJobLogService;
@ -51,6 +52,7 @@ public class SysJobLogServiceImpl implements ISysJobLogService
@Override
public void addJobLog(SysJobLog jobLog)
{
jobLog.setJobLogId(IdUtil.getSnowflakeNextId());
jobLogMapper.insertJobLog(jobLog);
}

View File

@ -1,5 +1,6 @@
package com.ff.quartz.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.ScheduleConstants;
import com.ff.base.exception.job.TaskException;
import com.ff.quartz.domain.SysJob;
@ -202,6 +203,7 @@ public class SysJobServiceImpl implements ISysJobService
@Transactional(rollbackFor = Exception.class)
public int insertJob(SysJob job) throws SchedulerException, TaskException
{
job.setJobId(IdUtil.getSnowflakeNextId());
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
int rows = jobMapper.insertJob(job);
if (rows > 0)

View File

@ -5,18 +5,14 @@ import com.ff.base.constant.Constants;
import com.ff.base.enums.OperationType;
import com.ff.base.enums.QuotaType;
import com.ff.base.utils.DateUtils;
import com.ff.common.domain.TenantGameQuota;
import com.ff.common.domain.TenantGameQuotaFlow;
import com.ff.common.domain.TenantQuotaExchange;
import com.ff.common.domain.TenantSecretKey;
import com.ff.common.dto.BalanceChangesDTO;
import com.ff.common.dto.BalanceRealChangesDTO;
import com.ff.common.service.ITenantGameQuotaFlowService;
import com.ff.common.service.ITenantGameQuotaService;
import com.ff.common.service.ITenantQuotaExchangeService;
import com.ff.common.service.ITenantSecretKeyService;
import com.ff.base.system.service.ITenantSecretKeyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

View File

@ -3,14 +3,18 @@ package com.ff.system;
import com.ff.base.constant.Constants;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.domain.model.LoginBody;
import com.ff.base.enums.LoginType;
import com.ff.base.system.domain.SysMenu;
import com.ff.base.system.domain.SysRole;
import com.ff.base.system.domain.SysUser;
import com.ff.base.system.service.ISysDatasourceService;
import com.ff.base.system.service.ISysMenuService;
import com.ff.base.utils.SecurityUtils;
import com.ff.base.web.service.SysLoginService;
import com.ff.base.web.service.SysPermissionService;
import com.ff.base.system.service.ITenantSecretKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -18,8 +22,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
*
@ -27,8 +33,7 @@ import java.util.Set;
* @author ff
*/
@RestController
public class SysLoginController
{
public class SysLoginController {
@Autowired
private SysLoginService loginService;
@ -39,7 +44,11 @@ public class SysLoginController
private SysPermissionService permissionService;
@Resource
private ISysDatasourceService datasourceService;
private ISysDatasourceService datasourceService;
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
/**
*
@ -48,12 +57,21 @@ public class SysLoginController
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
public AjaxResult login(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
String token = "";
// 验证码校验
// loginService.validateCaptcha(loginBody.getUsername(), loginBody.getCode(), loginBody.getUuid());
// 登录前置校验
loginService.loginPreCheck(loginBody.getUsername(), loginBody.getPassword());
if (LoginType.TENANT.getValue().equals(loginBody.getLoginType())) {
token = tenantSecretKeyService.login(loginBody.getUsername(), loginBody.getPassword());
} else {
token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
}
ajax.put(Constants.TOKEN, token);
return ajax;
}
@ -64,8 +82,7 @@ public class SysLoginController
* @return
*/
@GetMapping("getInfo")
public AjaxResult getInfo(HttpServletRequest request)
{
public AjaxResult getInfo(HttpServletRequest request) {
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
@ -90,10 +107,13 @@ public class SysLoginController
* @return
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
public AjaxResult getRouters() {
List<Long> roleIds = SecurityUtils.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList());
List<SysMenu> menus = new ArrayList<>();
if (!CollectionUtils.isEmpty(roleIds)) {
menus = menuService.selectMenuTree(roleIds);
}
return AjaxResult.success(menuService.buildMenus(menus));
}
}

View File

@ -4,9 +4,12 @@ import com.ff.base.annotation.Log;
import com.ff.base.config.FFConfig;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.LoginType;
import com.ff.base.system.domain.SysUser;
import com.ff.base.core.domain.model.LoginUser;
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.SecurityUtils;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.file.FileUploadUtils;
@ -17,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
/**
*
*
@ -24,20 +29,21 @@ import org.springframework.web.multipart.MultipartFile;
*/
@RestController
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
public class SysProfileController extends BaseController {
@Autowired
private ISysUserService userService;
@Autowired
private TokenService tokenService;
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
/**
*
*/
@GetMapping
public AjaxResult profile()
{
public AjaxResult profile() {
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
@ -51,24 +57,20 @@ public class SysProfileController extends BaseController
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
public AjaxResult updateProfile(@RequestBody SysUser user) {
LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
{
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) {
return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
{
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) {
return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
}
if (userService.updateUserProfile(currentUser) > 0)
{
if (userService.updateUserProfile(currentUser) > 0) {
// 更新缓存用户信息
tokenService.setLoginUser(loginUser);
return success();
@ -81,22 +83,28 @@ public class SysProfileController extends BaseController
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
{
public AjaxResult updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
if (SecurityUtils.matchesPassword(newPassword, password)) {
return error("新密码不能与旧密码相同");
}
newPassword = SecurityUtils.encryptPassword(newPassword);
if (userService.resetUserPwd(userName, newPassword) > 0)
{
Integer loginType = loginUser.getUser().getLoginType();
Boolean result = Boolean.FALSE;
if (LoginType.TENANT.getValue().equals(loginType)) {
TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyByTenantKey(userName);
tenantSecretKey.setPassword(newPassword);
result = tenantSecretKeyService.updateTenantSecretKey(tenantSecretKey) > 0;
} else if (LoginType.ADMIN.getValue().equals(loginType)) {
result = userService.resetUserPwd(userName, newPassword) > 0;
}
if (result) {
// 更新缓存用户密码
loginUser.getUser().setPassword(newPassword);
tokenService.setLoginUser(loginUser);
@ -110,14 +118,11 @@ public class SysProfileController extends BaseController
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
{
if (!file.isEmpty())
{
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(FFConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar);
// 更新缓存用户头像

View File

@ -7,7 +7,7 @@ spring:
# 端口默认为6379
port: 6379
# 数据库索引
database: 2
database: 1
# 密码
password:
# 连接超时时间

View File

@ -116,23 +116,8 @@ xss:
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
#雪花算法id生成器配置
snowflake:
worker:
id: 1
datacenter:
id: 1
#aes密钥
encrypt:
body:
aes-key: gktsdFKqo7lJi3Kc #AES加密秘钥
netty:
app:
port: 9820
web:
port: 9821

View File

@ -42,3 +42,6 @@ no.export.permission=您没有导出数据的权限,请联系管理员添加
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
##租户
operation.tenant.account.already.used=租户账号已被使用,请更换租户账号
operation.password.mismatch=两次密码不一致

View File

@ -1,44 +1,73 @@
<?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.CurrencyMapper">
<resultMap type="Currency" id="CurrencyResult">
<result property="id" column="id" />
<result property="status" column="status" />
<result property="country" column="country" />
<result property="currencyCode" column="currency_code" />
<result property="currencySign" column="currency_sign" />
<result property="gameRate" column="game_rate" />
<result property="currencyDisplay" column="currency_display" />
<result property="currencyName" column="currency_name" />
<result property="fullName" column="full_name" />
<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="remark" column="remark" />
<result property="id" column="id"/>
<result property="status" column="status"/>
<result property="country" column="country"/>
<result property="currencyCode" column="currency_code"/>
<result property="currencySign" column="currency_sign"/>
<result property="gameRate" column="game_rate"/>
<result property="currencyDisplay" column="currency_display"/>
<result property="currencyName" column="currency_name"/>
<result property="fullName" column="full_name"/>
<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="remark" column="remark"/>
</resultMap>
<sql id="selectCurrencyVo">
select id, status, country, currency_code, currency_sign, game_rate, currency_display, currency_name, full_name, create_by, create_time, update_by, update_time, remark from ff_currency
select id,
status,
country,
currency_code,
currency_sign,
game_rate,
currency_display,
currency_name,
full_name,
create_by,
create_time,
update_by,
update_time,
remark
from ff_currency
</sql>
<select id="selectCurrencyList" parameterType="Currency" resultMap="CurrencyResult">
<include refid="selectCurrencyVo"/>
<where>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="country != null and country != ''"> and country = #{country}</if>
<if test="currencyCode != null and currencyCode != ''"> and currency_code = #{currencyCode}</if>
<if test="currencySign != null and currencySign != ''"> and currency_sign = #{currencySign}</if>
<if test="gameRate != null "> and game_rate = #{gameRate}</if>
<if test="currencyDisplay != null and currencyDisplay != ''"> and currency_display = #{currencyDisplay}</if>
<if test="currencyName != null and currencyName != ''"> and currency_name like concat('%', #{currencyName}, '%')</if>
<if test="fullName != null and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
<where>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="country != null and country != ''">
and country = #{country}
</if>
<if test="currencyCode != null and currencyCode != ''">
and currency_code = #{currencyCode}
</if>
<if test="currencySign != null and currencySign != ''">
and currency_sign = #{currencySign}
</if>
<if test="gameRate != null ">
and game_rate = #{gameRate}
</if>
<if test="currencyDisplay != null and currencyDisplay != ''">
and currency_display = #{currencyDisplay}
</if>
<if test="currencyName != null and currencyName != ''">
and currency_name like concat('%', #{currencyName}, '%')
</if>
<if test="fullName != null and fullName != ''">
and full_name like concat('%', #{fullName}, '%')
</if>
</where>
</select>
<select id="selectCurrencyById" parameterType="Long" resultMap="CurrencyResult">
<include refid="selectCurrencyVo"/>
where id = #{id}
@ -47,63 +76,149 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertCurrency" parameterType="Currency" useGeneratedKeys="true" keyProperty="id">
insert into ff_currency
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="status != null">status,</if>
<if test="country != null">country,</if>
<if test="currencyCode != null">currency_code,</if>
<if test="currencySign != null">currency_sign,</if>
<if test="gameRate != null">game_rate,</if>
<if test="currencyDisplay != null">currency_display,</if>
<if test="currencyName != null">currency_name,</if>
<if test="fullName != null">full_name,</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>
<if test="remark != null">remark,</if>
</trim>
<if test="id != null">
id,
</if>
<if test="status != null">
status,
</if>
<if test="country != null">
country,
</if>
<if test="currencyCode != null">
currency_code,
</if>
<if test="currencySign != null">
currency_sign,
</if>
<if test="gameRate != null">
game_rate,
</if>
<if test="currencyDisplay != null">
currency_display,
</if>
<if test="currencyName != null">
currency_name,
</if>
<if test="fullName != null">
full_name,
</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>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="status != null">#{status},</if>
<if test="country != null">#{country},</if>
<if test="currencyCode != null">#{currencyCode},</if>
<if test="currencySign != null">#{currencySign},</if>
<if test="gameRate != null">#{gameRate},</if>
<if test="currencyDisplay != null">#{currencyDisplay},</if>
<if test="currencyName != null">#{currencyName},</if>
<if test="fullName != null">#{fullName},</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>
<if test="remark != null">#{remark},</if>
</trim>
<if test="id != null">
#{id},
</if>
<if test="status != null">
#{status},
</if>
<if test="country != null">
#{country},
</if>
<if test="currencyCode != null">
#{currencyCode},
</if>
<if test="currencySign != null">
#{currencySign},
</if>
<if test="gameRate != null">
#{gameRate},
</if>
<if test="currencyDisplay != null">
#{currencyDisplay},
</if>
<if test="currencyName != null">
#{currencyName},
</if>
<if test="fullName != null">
#{fullName},
</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>
<if test="remark != null">
#{remark},
</if>
</trim>
</insert>
<update id="updateCurrency" parameterType="Currency">
update ff_currency
<trim prefix="SET" suffixOverrides=",">
<if test="status != null">status = #{status},</if>
<if test="country != null">country = #{country},</if>
<if test="currencyCode != null">currency_code = #{currencyCode},</if>
<if test="currencySign != null">currency_sign = #{currencySign},</if>
<if test="gameRate != null">game_rate = #{gameRate},</if>
<if test="currencyDisplay != null">currency_display = #{currencyDisplay},</if>
<if test="currencyName != null">currency_name = #{currencyName},</if>
<if test="fullName != null">full_name = #{fullName},</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="remark != null">remark = #{remark},</if>
<if test="status != null">
status = #{status},
</if>
<if test="country != null">
country = #{country},
</if>
<if test="currencyCode != null">
currency_code = #{currencyCode},
</if>
<if test="currencySign != null">
currency_sign = #{currencySign},
</if>
<if test="gameRate != null">
game_rate = #{gameRate},
</if>
<if test="currencyDisplay != null">
currency_display = #{currencyDisplay},
</if>
<if test="currencyName != null">
currency_name = #{currencyName},
</if>
<if test="fullName != null">
full_name = #{fullName},
</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="remark != null">
remark = #{remark},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCurrencyById" parameterType="Long">
delete from ff_currency where id = #{id}
delete
from ff_currency
where id = #{id}
</delete>
<delete id="deleteCurrencyByIds" parameterType="String">
delete from ff_currency where id in
delete from ff_currency where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertLang" parameterType="Lang" useGeneratedKeys="true" keyProperty="id">
insert into ff_lang
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="name != null">name,</if>
<if test="country != null">country,</if>
<if test="langCode != null">lang_code,</if>
@ -47,7 +47,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="country != null">#{country},</if>
<if test="langCode != null">#{langCode},</if>

View File

@ -35,7 +35,7 @@ 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=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="account != null">account,</if>
<if test="password != null">password,</if>
<if test="agentStatus != null">agent_status,</if>
@ -44,7 +44,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="account != null">#{account},</if>
<if test="password != null">#{password},</if>
<if test="agentStatus != null">#{agentStatus},</if>

View File

@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTenantGameQuotaFlow" parameterType="TenantGameQuotaFlow" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="quotaType != null">quota_type,</if>
<if test="memberId != null">member_id,</if>
@ -73,7 +73,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="quotaType != null">#{quotaType},</if>
<if test="memberId != null">#{memberId},</if>

View File

@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTenantGameQuota" parameterType="TenantGameQuota" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota
<trim prefix="(" suffix=")" suffixOverrides=",">
<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>
@ -57,7 +57,7 @@ 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=",">
<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>

View File

@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertTenantQuotaExchange" parameterType="TenantQuotaExchange" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_quota_exchange
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="currencyCode != null">currency_code,</if>
<if test="exchangeCurrencyCode != null">exchange_currency_code,</if>
<if test="exchangeRate != null">exchange_rate,</if>
@ -53,7 +53,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="currencyCode != null">#{currencyCode},</if>
<if test="exchangeCurrencyCode != null">#{exchangeCurrencyCode},</if>
<if test="exchangeRate != null">#{exchangeRate},</if>

View File

@ -2,10 +2,13 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ff.common.mapper.TenantSecretKeyMapper">
<mapper namespace="com.ff.base.system.mapper.TenantSecretKeyMapper">
<resultMap type="TenantSecretKey" id="TenantSecretKeyResult">
<result property="id" column="id" />
<result property="password" column="password" />
<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" />
@ -22,12 +25,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTenantSecretKeyVo">
select id, 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, 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
</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>
@ -39,20 +45,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="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>
<select id="selectTenantSecretKeyById" parameterType="Long" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
where id = #{id}
</select>
<select id="selectTenantSecretKeyByTenantKey" parameterType="String" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
where tenant_key = #{tenantKey}
</select>
<insert id="insertTenantSecretKey" parameterType="TenantSecretKey" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_secret_key
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="id != null">id,</if>
<if test="password != null">password,</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>
@ -66,8 +89,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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=",">
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="id != null">#{id},</if>
<if test="password != null">#{password},</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>
@ -81,12 +108,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateTenantSecretKey" parameterType="TenantSecretKey">
update ff_tenant_secret_key
<trim prefix="SET" suffixOverrides=",">
<if test="password != null">password = #{password},</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>
@ -104,6 +134,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<select id="selectTenantSecretKeyByTenantKey" parameterType="String" resultMap="TenantSecretKeyResult">
<include refid="selectTenantSecretKeyVo"/>
where tenant_key = #{tenantKey}
</select>
<delete id="deleteTenantSecretKeyById" parameterType="Long">
delete from ff_tenant_secret_key where id = #{id}
</delete>

View File

@ -90,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGameBettingDetails" parameterType="GameBettingDetails" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_betting_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="tenantKey != null">tenant_key,</if>
<if test="currencyCode != null">currency_code,</if>
<if test="memberId != null">member_id,</if>
@ -117,7 +117,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="tenantKey != null">#{tenantKey},</if>
<if test="currencyCode != null">#{currencyCode},</if>
<if test="memberId != null">#{memberId},</if>
@ -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=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
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=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
#{item.tenantKey},
#{item.gameId},
#{item.currencyCode},

View File

@ -57,7 +57,7 @@
<insert id="insertGameExchangeMoney" parameterType="GameExchangeMoney" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_exchange_money
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="tenantKey != null">tenant_key,</if>
<if test="currencyCode != null">currency_code,</if>
<if test="orderId != null">order_id,</if>
@ -77,7 +77,7 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="tenantKey != null">#{tenantKey},</if>
<if test="currencyCode != null">#{currencyCode},</if>
<if test="orderId != null">#{orderId},</if>

View File

@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGameFreeRecord" parameterType="GameFreeRecord" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_free_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="currencyCode != null">currency_code,</if>
<if test="platformCode != null">platform_code,</if>
<if test="referenceId != null">reference_id,</if>
@ -77,7 +77,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="currencyCode != null">#{currencyCode},</if>
<if test="platformCode != null">#{platformCode},</if>
<if test="referenceId != null">#{referenceId},</if>

View File

@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGame" parameterType="Game" useGeneratedKeys="true" keyProperty="id">
insert into ff_game
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="sortNo != null">sort_no,</if>
<if test="platformId != null">platform_id,</if>
<if test="gameCode != null">game_code,</if>
@ -59,7 +59,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="sortNo != null">#{sortNo},</if>
<if test="platformId != null">#{platformId},</if>
<if test="gameCode != null">#{gameCode},</if>

View File

@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGamePlatform" parameterType="GamePlatform" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_platform
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="sortNo != null">sort_no,</if>
<if test="platformCode != null">platform_code,</if>
<if test="platformType != null">platform_type,</if>
@ -50,7 +50,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="sortNo != null">#{sortNo},</if>
<if test="platformCode != null">#{platformCode},</if>
<if test="platformType != null">#{platformType},</if>

View File

@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertGameSecretKey" parameterType="GameSecretKey" useGeneratedKeys="true" keyProperty="id">
insert into ff_game_secret_key
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="platform != null and platform != ''">platform,</if>
<if test="code != null and code != ''">code,</if>
<if test="key != null and key != ''">`key`,</if>
@ -56,7 +56,7 @@ 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=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="platform != null and platform != ''">#{platform},</if>
<if test="code != null and code != ''">#{code},</if>
<if test="key != null and key != ''">#{key},</if>

View File

@ -39,7 +39,7 @@
<insert id="insertMember" parameterType="Member" useGeneratedKeys="true" keyProperty="id">
insert into ff_member
<trim prefix="(" suffix=")" suffixOverrides=",">
<trim prefix="(" suffix=")" suffixOverrides=","><if test="id != null">id,</if>
<if test="tenantKey != null">tenant_key,</if>
<if test="memberAccount != null and memberAccount != ''">member_account,</if>
<if test="gameAccount != null">game_account,</if>
@ -50,7 +50,7 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null">#{id},</if>
<if test="tenantKey != null">#{tenantKey},</if>
<if test="memberAccount != null and memberAccount != ''">#{memberAccount},</if>
<if test="gameAccount != null">#{gameAccount},</if>

View File

@ -23,6 +23,11 @@
</dependency>
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.6.3</version>
</dependency>
<!-- SpringBoot的依赖配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -184,6 +189,7 @@
<artifactId>javase</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -1,34 +0,0 @@
package com.ff.base.config;
import com.ff.base.utils.SnowflakeIdGenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* id
*
* @author liukang
* @date 2024-11-04
*/
@Configuration
public class IdGeneratorUtil {
private static SnowflakeIdGenerator snowflakeIdGenerator;
@Value("${snowflake.worker.id}")
private long workerId;
@Value("${snowflake.datacenter.id}")
private long dataCenterId;
public void init() {
snowflakeIdGenerator = new SnowflakeIdGenerator(workerId, dataCenterId);
}
public static long generateId() {
if (snowflakeIdGenerator == null) {
throw new IllegalStateException("SnowflakeIdGenerator is not initialized");
}
return snowflakeIdGenerator.nextId();
}
}

View File

@ -6,7 +6,7 @@ import com.ff.base.security.filter.JwtAuthenticationTokenFilter;
import com.ff.base.security.handle.AuthenticationEntryPointImpl;
import com.ff.base.security.handle.LogoutSuccessHandlerImpl;
import com.ff.base.security.provider.MyDaoAuthenticationProvider;
import com.ff.base.web.service.MemberDetailsServiceImpl;
import com.ff.base.web.service.TenantDetailsServiceImpl;
import com.ff.base.web.service.UserDetailsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@ -41,11 +41,8 @@ public class SecurityConfig {
@Autowired
private UserDetailsServiceImpl userDetailsService;
/**
*
*/
@Autowired
private MemberDetailsServiceImpl memberDetailsService;
private TenantDetailsServiceImpl tenantDetailsService;
/**
*
@ -86,20 +83,20 @@ public class SecurityConfig {
// 后台、会员两种验证方式实现类
List<UserDetailsService> userDetailsServices = new ArrayList<>();
userDetailsServices.add(userDetailsService);
userDetailsServices.add(memberDetailsService);
userDetailsServices.add(tenantDetailsService);
List<AuthenticationProvider> providers = new ArrayList<>();
MyDaoAuthenticationProvider adminDaoAuthenticationProvider = new MyDaoAuthenticationProvider();
adminDaoAuthenticationProvider.setUserDetailsService(userDetailsService); // or userDetailsService
adminDaoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder());
adminDaoAuthenticationProvider.setUserDetailsServices(userDetailsServices);
MyDaoAuthenticationProvider memberDaoAuthenticationProvider = new MyDaoAuthenticationProvider();
memberDaoAuthenticationProvider.setUserDetailsService(memberDetailsService); // or userDetailsService
memberDaoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder());
memberDaoAuthenticationProvider.setUserDetailsServices(userDetailsServices);
providers.add(adminDaoAuthenticationProvider);
providers.add(memberDaoAuthenticationProvider);
MyDaoAuthenticationProvider adminDaoAuthenticationProvider1 = new MyDaoAuthenticationProvider();
adminDaoAuthenticationProvider1.setUserDetailsService(tenantDetailsService);
adminDaoAuthenticationProvider1.setPasswordEncoder(bCryptPasswordEncoder());
adminDaoAuthenticationProvider1.setUserDetailsServices(userDetailsServices);
return new ProviderManager(providers);

View File

@ -251,4 +251,14 @@ public class Constants {
*/
public static final String USDT = "USDT";
/**
*
*/
public static final String AGENT_ROLE = "agent";
/**
*
*/
public static final String TENANT_ROLE = "tenant";
}

View File

@ -30,4 +30,9 @@ public class LoginBody
*/
private String uuid;
/**
*
*/
private Integer loginType;
}

View File

@ -74,10 +74,6 @@ public class LoginUser implements UserDetails
*/
private SysUser user;
/**
*
*/
private String currencyType;
public LoginUser()
{
@ -97,12 +93,6 @@ public class LoginUser implements UserDetails
this.permissions = permissions;
}
public LoginUser(Long userId,String currencyType, SysUser user)
{
this.userId = userId;
this.user = user;
this.currencyType = currencyType;
}
public Long getUserId()
{

View File

@ -0,0 +1,35 @@
package com.ff.base.enums;
import lombok.Getter;
/**
*
*
* @author shi
* @date 2025/02/24
*/
@Getter
public enum LoginType {
ADMIN(0, "后台"),
TENANT(1, "租户"),
AGENT(2, "代理"),
;
private final Integer value; // 登录类型值
private final String description; // 登录类型描述
LoginType(Integer value, String description) {
this.value = value;
this.description = description;
}
// 根据 value 查找对应的 description
public static String getDescriptionByValue(Integer value) {
for (LoginType type : LoginType.values()) {
if (type.getValue().equals(value)) {
return type.getDescription();
}
}
return null; // 未找到时返回 null
}
}

View File

@ -6,6 +6,7 @@ import com.ff.base.annotation.Excel.Type;
import com.ff.base.annotation.Excels;
import com.ff.base.core.domain.BaseEntity;
import com.ff.base.xss.Xss;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -19,334 +20,157 @@ import java.util.List;
*
* @author ff
*/
public class SysUser extends BaseEntity
{
@Data
public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 用户ID */
/**
* ID
*/
@Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
private Long userId;
/** 部门ID */
/**
* ID
*/
@Excel(name = "部门编号", type = Type.IMPORT)
private Long deptId;
/** 用户账号 */
/**
*
*/
@Excel(name = "登录名称")
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
private String userName;
/** 用户昵称 */
/**
*
*/
@Excel(name = "用户名称")
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
private String nickName;
/** 用户邮箱 */
/**
*
*/
@Excel(name = "用户邮箱")
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
private String email;
/** 手机号码 */
/**
*
*/
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
private String phonenumber;
/** 用户性别 */
/**
*
*/
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
/** 用户头像 */
/**
*
*/
private String avatar;
/** 密码 */
/**
*
*/
private String password;
/** 帐号状态0正常 1停用 */
/**
* 0 1
*/
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志0代表存在 2代表删除 */
/**
* 0 2
*/
private String delFlag;
/** 最后登录IP */
/**
* IP
*/
@Excel(name = "最后登录IP", type = Type.EXPORT)
private String loginIp;
/** 最后登录时间 */
/**
*
*/
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Long loginDate;
/** 部门对象 */
/**
*
*/
@Excels({
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
})
private SysDept dept;
/** 角色对象 */
/**
*
*/
private List<SysRole> roles;
/** 角色组 */
/**
*
*/
private Long[] roleIds;
/** 岗位组 */
/**
*
*/
private Long[] postIds;
/** 角色ID */
/**
* ID
*/
private Long roleId;
/**
* 0. 1.
* 0 1 2
*/
private Integer loginType;
/**
*
*/
private String realName;
public SysUser()
{
public SysUser() {
}
public SysUser(Long userId)
{
public SysUser(Long userId) {
this.userId = userId;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public Integer getLoginType() {
return loginType;
}
public void setLoginType(Integer loginType) {
this.loginType = loginType;
}
public Long getUserId()
{
return userId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public boolean isAdmin()
{
public boolean isAdmin() {
return isAdmin(this.userId);
}
public static boolean isAdmin(Long userId)
{
public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId;
}
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getNickName()
{
return nickName;
}
public void setNickName(String nickName)
{
this.nickName = nickName;
}
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
public String getPhonenumber()
{
return phonenumber;
}
public void setPhonenumber(String phonenumber)
{
this.phonenumber = phonenumber;
}
public String getSex()
{
return sex;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getAvatar()
{
return avatar;
}
public void setAvatar(String avatar)
{
this.avatar = avatar;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getLoginIp()
{
return loginIp;
}
public void setLoginIp(String loginIp)
{
this.loginIp = loginIp;
}
public Long getLoginDate()
{
return loginDate;
}
public void setLoginDate(Long loginDate)
{
this.loginDate = loginDate;
}
public SysDept getDept()
{
return dept;
}
public void setDept(SysDept dept)
{
this.dept = dept;
}
public List<SysRole> getRoles()
{
return roles;
}
public void setRoles(List<SysRole> roles)
{
this.roles = roles;
}
public Long[] getRoleIds()
{
return roleIds;
}
public void setRoleIds(Long[] roleIds)
{
this.roleIds = roleIds;
}
public Long[] getPostIds()
{
return postIds;
}
public void setPostIds(Long[] postIds)
{
this.postIds = postIds;
}
public Long getRoleId()
{
return roleId;
}
public void setRoleId(Long roleId)
{
this.roleId = roleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("userId", getUserId())
.append("deptId", getDeptId())
.append("userName", getUserName())
.append("nickName", getNickName())
.append("email", getEmail())
.append("phonenumber", getPhonenumber())
.append("sex", getSex())
.append("avatar", getAvatar())
.append("password", getPassword())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("loginIp", getLoginIp())
.append("loginDate", getLoginDate())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("dept", getDept())
.toString();
}
}

View File

@ -1,6 +1,9 @@
package com.ff.common.domain;
package com.ff.base.system.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
@ -27,6 +30,22 @@ public class TenantSecretKey extends BaseEntity
/** 密码 */
@Excel(name = "密码")
@JsonIgnore
private String password;
/** 最后登录ip */
@Excel(name = "最后登录ip")
private String loginIp;
/** 最后登录时间 */
@Excel(name = "最后登录时间")
private Long loginData;
/** 租户key */
@Excel(name = "租户key")
private String tenantKey;
@ -35,12 +54,16 @@ public class TenantSecretKey extends BaseEntity
@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,27 @@
package com.ff.base.system.dto;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import com.ff.base.system.domain.TenantSecretKey;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* ff_tenant_secret_key
*
* @author shi
* @date 2025-02-20
*/
@Data
public class TenantSecretKeyDTO extends TenantSecretKey
{
}

View File

@ -1,9 +1,11 @@
package com.ff.base.system.mapper;
import com.ff.base.system.domain.SysMenu;
import com.ff.base.system.domain.SysRole;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
*
@ -61,10 +63,10 @@ public interface SysMenuMapper
/**
* ID
*
* @param userId ID
* @param roleIds
* @return
*/
public List<SysMenu> selectMenuTreeByUserId(Long userId);
public List<SysMenu> selectMenuTreeByUserId(@Param("roleIds") List<Long> roleIds);
/**
* ID

View File

@ -2,6 +2,7 @@ package com.ff.base.system.mapper;
import com.ff.base.system.domain.SysRole;
import javax.management.relation.Role;
import java.util.List;
/**
@ -66,6 +67,15 @@ public interface SysRoleMapper
*/
public SysRole checkRoleNameUnique(String roleName);
/**
*
*
* @param roleKey
* @return {@link SysRole }
*/
SysRole selectRoleByRoleKey(String roleKey);
/**
*
*

View File

@ -126,10 +126,5 @@ public interface SysUserMapper
*/
public SysUser checkEmailUnique(String email);
/**
* /
* @param accountName /
* @return
*/
SysUser selectMemberUserByUserName(String accountName);
}

View File

@ -1,7 +1,8 @@
package com.ff.common.mapper;
package com.ff.base.system.mapper;
import java.util.List;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.system.dto.TenantSecretKeyDTO;
/**
* Mapper
@ -35,6 +36,15 @@ public interface TenantSecretKeyMapper
*/
List<TenantSecretKey> selectTenantSecretKeyList(TenantSecretKey tenantSecretKey);
/**
*
*
* @param tenantSecretKeyDTO dto
* @return {@link List }<{@link TenantSecretKey }>
*/
List<TenantSecretKey> selectTenantSecretKeyDTOList(TenantSecretKeyDTO tenantSecretKeyDTO);
/**
*
*

View File

@ -2,6 +2,7 @@ package com.ff.base.system.service;
import com.ff.base.core.domain.TreeSelect;
import com.ff.base.system.domain.SysMenu;
import com.ff.base.system.domain.SysRole;
import com.ff.base.system.domain.vo.RouterVo;
import java.util.List;
@ -50,10 +51,10 @@ public interface ISysMenuService
/**
* ID
*
* @param userId ID
* @param roleIds
* @return
*/
public List<SysMenu> selectMenuTreeByUserId(Long userId);
public List<SysMenu> selectMenuTree( List<Long> roleIds);
/**
* ID

View File

@ -68,6 +68,14 @@ public interface ISysRoleService
*/
public boolean checkRoleNameUnique(SysRole role);
/**
*
*
* @param roleKey
* @return {@link SysRole }
*/
SysRole selectRoleByRoleKey(String roleKey);
/**
*
*

View File

@ -205,10 +205,7 @@ public interface ISysUserService
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
/**
* /
* @param accountName /
* @return
*/
SysUser selectMemberUserByUserName(String accountName);
}

View File

@ -1,7 +1,8 @@
package com.ff.common.service;
package com.ff.base.system.service;
import java.util.List;
import com.ff.common.domain.TenantSecretKey;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.system.dto.TenantSecretKeyDTO;
/**
* Service
@ -11,6 +12,16 @@ import com.ff.common.domain.TenantSecretKey;
*/
public interface ITenantSecretKeyService
{
/**
*
*
* @param username
* @param password
* @return {@link String }
*/
String login(String username, String password);
/**
*
*
@ -19,6 +30,15 @@ public interface ITenantSecretKeyService
*/
TenantSecretKey selectTenantSecretKeyById(Long id);
/**
*
*
* @param tenantSecretKeyDTO dto
* @return {@link List }<{@link TenantSecretKey }>
*/
List<TenantSecretKey> selectTenantSecretKeyDTOList(TenantSecretKeyDTO tenantSecretKeyDTO);
/**
* sn
@ -73,4 +93,6 @@ public interface ITenantSecretKeyService
* @return
*/
int deleteTenantSecretKeyById(Long id);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.UserConstants;
import com.ff.base.core.redis.RedisCache;
@ -100,6 +101,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
*/
@Override
public int insertConfig(SysConfig config) {
config.setConfigId(IdUtil.getSnowflakeNextId());
int row = configMapper.insertConfig(config);
if (row > 0) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.system.domain.SysDatasource;
import com.ff.base.system.mapper.SysDatasourceMapper;
import com.ff.base.system.service.ISysDatasourceService;
@ -86,6 +87,7 @@ public class SysDatasourceServiceImpl implements ISysDatasourceService
@Override
public int insertSysDatasource(SysDatasource sysDatasource)
{
sysDatasource.setId(IdUtil.getSnowflakeNextId());
sysDatasource.setCreateTime(DateUtils.getNowDate());
return sysDatasourceMapper.insertSysDatasource(sysDatasource);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.annotation.DataScope;
import com.ff.base.constant.UserConstants;
import com.ff.base.core.domain.TreeSelect;
@ -212,6 +213,7 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override
public int insertDept(SysDept dept)
{
dept.setDeptId(IdUtil.getSnowflakeNextId());
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.system.domain.SysDictData;
import com.ff.base.utils.DictUtils;
import com.ff.base.system.mapper.SysDictDataMapper;
@ -83,6 +84,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService
@Override
public int insertDictData(SysDictData data)
{
data.setDictCode(IdUtil.getSnowflakeNextId());
int row = dictDataMapper.insertDictData(data);
if (row > 0)
{

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.UserConstants;
import com.ff.base.datasource.DynamicDataSourceContextHolder;
import com.ff.base.exception.ServiceException;
@ -160,6 +161,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
*/
@Override
public int insertDictType(SysDictType dict) {
dict.setDictId(IdUtil.getSnowflakeNextId());
int row = dictTypeMapper.insertDictType(dict);
if (row > 0) {
DictUtils.setDictCache(dict.getDictType(), null);

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.system.domain.SysLogininfor;
import com.ff.base.system.mapper.SysLogininforMapper;
import com.ff.base.system.service.ISysLogininforService;
@ -28,6 +29,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService
@Override
public void insertLogininfor(SysLogininfor logininfor)
{
logininfor.setInfoId(IdUtil.getSnowflakeNextId());
logininforMapper.insertLogininfor(logininfor);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.Constants;
import com.ff.base.constant.UserConstants;
import com.ff.base.core.domain.TreeSelect;
@ -119,20 +120,20 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* ID
*
* @param userId
* @param roleIds
* @return
*/
@Override
public List<SysMenu> selectMenuTreeByUserId(Long userId)
public List<SysMenu> selectMenuTree( List<Long> roleIds)
{
List<SysMenu> menus = null;
if (SecurityUtils.isAdmin(userId))
if (SecurityUtils.isAdmin(SecurityUtils.getUserId()))
{
menus = menuMapper.selectMenuTreeAll();
}
else
{
menus = menuMapper.selectMenuTreeByUserId(userId);
menus = menuMapper.selectMenuTreeByUserId(roleIds);
}
return getChildPerms(menus, 0);
}
@ -296,6 +297,7 @@ public class SysMenuServiceImpl implements ISysMenuService
@Override
public int insertMenu(SysMenu menu)
{
menu.setMenuId(IdUtil.getSnowflakeNextId());
return menuMapper.insertMenu(menu);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.system.domain.SysOperLog;
import com.ff.base.system.mapper.SysOperLogMapper;
import com.ff.base.system.service.ISysOperLogService;
@ -27,6 +28,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
@Override
public void insertOperlog(SysOperLog operLog)
{
operLog.setOperId(IdUtil.getSnowflakeNextId());
operLogMapper.insertOperlog(operLog);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.UserConstants;
import com.ff.base.exception.ServiceException;
import com.ff.base.utils.StringUtils;
@ -162,6 +163,7 @@ public class SysPostServiceImpl implements ISysPostService
@Override
public int insertPost(SysPost post)
{
post.setPostId(IdUtil.getSnowflakeNextId());
return postMapper.insertPost(post);
}

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.annotation.DataScope;
import com.ff.base.constant.UserConstants;
import com.ff.base.system.domain.SysRole;
@ -154,6 +155,17 @@ public class SysRoleServiceImpl implements ISysRoleService
return UserConstants.UNIQUE;
}
/**
*
*
* @param roleKey
* @return {@link SysRole }
*/
@Override
public SysRole selectRoleByRoleKey(String roleKey) {
return roleMapper.selectRoleByRoleKey(roleKey);
}
/**
*
*
@ -231,6 +243,7 @@ public class SysRoleServiceImpl implements ISysRoleService
@Transactional
public int insertRole(SysRole role)
{
role.setRoleId(IdUtil.getSnowflakeNextId());
// 新增角色信息
roleMapper.insertRole(role);
return insertRoleMenu(role);

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import cn.hutool.core.util.IdUtil;
import com.ff.base.annotation.DataScope;
import com.ff.base.constant.UserConstants;
import com.ff.base.system.domain.SysRole;
@ -257,6 +258,7 @@ public class SysUserServiceImpl implements ISysUserService
@Transactional
public int insertUser(SysUser user)
{
user.setUserId(IdUtil.getSnowflakeNextId());
// 新增用户信息
int rows = userMapper.insertUser(user);
// 新增用户岗位关联
@ -545,13 +547,5 @@ public class SysUserServiceImpl implements ISysUserService
return successMsg.toString();
}
/**
* /
* @param accountName /
* @return
*/
@Override
public SysUser selectMemberUserByUserName(String accountName) {
return userMapper.selectMemberUserByUserName(accountName);
}
}

View File

@ -0,0 +1,206 @@
package com.ff.base.system.service.impl;
import java.util.Collections;
import java.util.List;
import cn.hutool.core.util.IdUtil;
import com.ff.base.constant.Constants;
import com.ff.base.core.domain.model.LoginForm;
import com.ff.base.core.domain.model.LoginUser;
import com.ff.base.enums.LoginType;
import com.ff.base.exception.ServiceException;
import com.ff.base.exception.user.UserPasswordNotMatchException;
import com.ff.base.manager.AsyncManager;
import com.ff.base.manager.factory.AsyncFactory;
import com.ff.base.security.context.AuthenticationContextHolder;
import com.ff.base.system.dto.TenantSecretKeyDTO;
import com.ff.base.utils.DateUtils;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.NumberUtils;
import com.ff.base.utils.ip.IpUtils;
import com.ff.base.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import com.ff.base.system.mapper.TenantSecretKeyMapper;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.system.service.ITenantSecretKeyService;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
/**
* Service
*
* @author shi
* @date 2025-02-11
*/
@Service
public class TenantSecretKeyServiceImpl implements ITenantSecretKeyService {
@Autowired
private TenantSecretKeyMapper tenantSecretKeyMapper;
@Resource
private TokenService tokenService;
@Resource
private AuthenticationManager authenticationManager;
/**
*
*
* @param username
* @param password
* @return {@link String }
*/
@Override
public String login(String username, String password) {
// 用户验证
Authentication authentication = null;
try {
LoginForm loginForm = new LoginForm();
loginForm.setAccountName(username);
loginForm.setPassword(password);
loginForm.setLoginType(LoginType.TENANT.getValue());
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, loginForm);
AuthenticationContextHolder.setContext(authenticationToken);
authentication = authenticationManager.authenticate(authenticationToken);
} catch (Exception e) {
if (e instanceof BadCredentialsException) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
} else {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
} finally {
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
//更新租户信息
TenantSecretKey tenantSecretKey = new TenantSecretKey();
tenantSecretKey.setId(loginUser.getUserId());
tenantSecretKey.setLoginIp(IpUtils.getIpAddr());
tenantSecretKey.setLoginData(DateUtils.getNowDate());
tenantSecretKeyMapper.updateTenantSecretKey(tenantSecretKey);
// 生成token
return tokenService.createToken(loginUser);
}
/**
*
*
* @param id
* @return
*/
@Override
public TenantSecretKey selectTenantSecretKeyById(Long id) {
return tenantSecretKeyMapper.selectTenantSecretKeyById(id);
}
/**
*
*
* @param tenantSecretKeyDTO dto
* @return {@link List }<{@link TenantSecretKey }>
*/
@Override
public List<TenantSecretKey> selectTenantSecretKeyDTOList(TenantSecretKeyDTO tenantSecretKeyDTO) {
return tenantSecretKeyMapper.selectTenantSecretKeyDTOList(tenantSecretKeyDTO);
}
/**
* sn
*
* @return {@link String }
*/
@Override
public synchronized String generateTenantSn() {
String sn = NumberUtils.generateRandomCode();
while (!CollectionUtils.isEmpty(tenantSecretKeyMapper.selectTenantSecretKeyList(TenantSecretKey.builder()
.tenantSn(sn)
.build()))) {
sn = NumberUtils.generateRandomCode();
}
return sn;
}
/**
*
*
* @param tenantKey
* @return {@link TenantSecretKey }
*/
@Override
public TenantSecretKey selectTenantSecretKeyByTenantKey(String tenantKey) {
return tenantSecretKeyMapper.selectTenantSecretKeyByTenantKey(tenantKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public List<TenantSecretKey> selectTenantSecretKeyList(TenantSecretKey tenantSecretKey) {
return tenantSecretKeyMapper.selectTenantSecretKeyList(tenantSecretKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public int insertTenantSecretKey(TenantSecretKey tenantSecretKey) {
tenantSecretKey.setCreateTime(DateUtils.getNowDate());
tenantSecretKey.setId(IdUtil.getSnowflakeNextId());
return tenantSecretKeyMapper.insertTenantSecretKey(tenantSecretKey);
}
/**
*
*
* @param tenantSecretKey
* @return
*/
@Override
public int updateTenantSecretKey(TenantSecretKey tenantSecretKey) {
tenantSecretKey.setUpdateTime(DateUtils.getNowDate());
return tenantSecretKeyMapper.updateTenantSecretKey(tenantSecretKey);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTenantSecretKeyByIds(Long[] ids) {
return tenantSecretKeyMapper.deleteTenantSecretKeyByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTenantSecretKeyById(Long id) {
return tenantSecretKeyMapper.deleteTenantSecretKeyById(id);
}
}

View File

@ -14,8 +14,10 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.PatternMatchUtils;
import javax.management.relation.Role;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -26,14 +28,6 @@ import java.util.stream.Collectors;
public class SecurityUtils
{
/**
*
* @return {@link String }
*/
public static String getUserCurrencyType(){
return getLoginUser().getCurrencyType();
}
/**
* idnull
@ -67,6 +61,24 @@ public class SecurityUtils
}
}
/**
*
*
* @return {@link List }<{@link SysRole }>
*/
public static List<SysRole> getRoles()
{
try
{
return getLoginUser().getUser().getRoles();
}
catch (Exception e)
{
throw new ServiceException("获取用户角色异常", HttpStatus.UNAUTHORIZED);
}
}
/**
* ID
**/
@ -227,6 +239,7 @@ public class SecurityUtils
return hasRole(roles, role);
}
/**
*
*

View File

@ -1,73 +0,0 @@
package com.ff.base.utils;
/**
* id
*
* @author liukang
* @date 2024-11-04
*/
public class SnowflakeIdGenerator {
private static final long EPOCH = 1609459200000L; // 自定义起始时间戳例如2021-01-01 00:00:00
private static final long WORKER_ID_BITS = 5L;
private static final long DATA_CENTER_ID_BITS = 5L;
private static final long SEQUENCE_BITS = 12L;
private static final long MAX_WORKER_ID = -1L ^ (-1L << WORKER_ID_BITS);
private static final long MAX_DATA_CENTER_ID = -1L ^ (-1L << DATA_CENTER_ID_BITS);
private static final long SEQUENCE_MASK = -1L ^ (-1L << SEQUENCE_BITS);
private static final long WORKER_ID_SHIFT = SEQUENCE_BITS;
private static final long DATA_CENTER_ID_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS;
private static final long TIMESTAMP_LEFT_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS + DATA_CENTER_ID_BITS;
private long workerId;
private long dataCenterId;
private long sequence = 0L;
private long lastTimestamp = -1L;
public SnowflakeIdGenerator(long workerId, long dataCenterId) {
if (workerId > MAX_WORKER_ID || workerId < 0) {
throw new IllegalArgumentException("worker Id can't be greater than " + MAX_WORKER_ID + " or less than 0");
}
if (dataCenterId > MAX_DATA_CENTER_ID || dataCenterId < 0) {
throw new IllegalArgumentException("data center Id can't be greater than " + MAX_DATA_CENTER_ID + " or less than 0");
}
this.workerId = workerId;
this.dataCenterId = dataCenterId;
}
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & SEQUENCE_MASK;
if (sequence == 0) {
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
return ((timestamp - EPOCH) << TIMESTAMP_LEFT_SHIFT) |
(dataCenterId << DATA_CENTER_ID_SHIFT) |
(workerId << WORKER_ID_SHIFT) |
sequence;
}
protected long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
protected long timeGen() {
return System.currentTimeMillis();
}
}

View File

@ -1,7 +1,7 @@
package com.ff.base.utils.file;
import cn.hutool.core.util.IdUtil;
import com.ff.base.config.FFConfig;
import com.ff.base.config.IdGeneratorUtil;
import com.ff.base.constant.Constants;
import com.ff.base.exception.file.FileNameLengthLimitExceededException;
import com.ff.base.exception.file.FileSizeLimitExceededException;
@ -125,7 +125,7 @@ public class FileUploadUtils
public static final String extractFilename(MultipartFile file)
{
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
IdGeneratorUtil.generateId(), Seq.getId(Seq.uploadSeqType), getExtension(file));
IdUtil.getSnowflakeNextId(), Seq.getId(Seq.uploadSeqType), getExtension(file));
}
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException

View File

@ -1,59 +0,0 @@
package com.ff.base.web.service;
import com.ff.base.core.domain.model.LoginUser;
import com.ff.base.enums.MemberStatus;
import com.ff.base.exception.ServiceException;
import com.ff.base.system.domain.SysUser;
import com.ff.base.system.service.ISysConfigService;
import com.ff.base.system.service.ISysUserService;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
/**
*
*
* @author ff
*/
@Service
public class MemberDetailsServiceImpl implements UserDetailsService {
@Autowired
private ISysUserService userService;
@Autowired
private SysPasswordService passwordService;
@Autowired
private ISysConfigService sysConfigService;
private static final Logger log = LoggerFactory.getLogger(MemberDetailsServiceImpl.class);
@Override
public UserDetails loadUserByUsername(String accountName) throws UsernameNotFoundException {
SysUser user = userService.selectMemberUserByUserName(accountName);
if (StringUtils.isNull(user)) {
log.info("登录用户:{} 不存在.", accountName);
throw new ServiceException(MessageUtils.message("user.not.exists"));
} else if (MemberStatus.MemberStatus_6.getCode().equals(user.getStatus())) {
log.info("登录用户:{} 已被停用.", accountName);
throw new ServiceException(MessageUtils.message("user.blocked"));
}
passwordService.validate(user);
String defaultCurrency = sysConfigService.selectConfigByKey("default.currency");
return createLoginUser(user,defaultCurrency);
}
public UserDetails createLoginUser(SysUser user,String defaultCurrency) {
return new LoginUser(user.getUserId(),defaultCurrency, user);
}
}

View File

@ -4,6 +4,7 @@ import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
import com.ff.base.constant.UserConstants;
import com.ff.base.core.domain.model.LoginForm;
import com.ff.base.enums.LoginType;
import com.ff.base.system.domain.SysUser;
import com.ff.base.core.domain.model.LoginUser;
import com.ff.base.core.redis.RedisCache;
@ -61,18 +62,18 @@ public class SysLoginService
*/
public String login(String username, String password, String code, String uuid)
{
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证
Authentication authentication = null;
try
{
LoginForm loginForm = new LoginForm();
loginForm.setAccountName(username);
loginForm.setPassword(password);
loginForm.setLoginType(0);
loginForm.setLoginType(LoginType.ADMIN.getValue());
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, loginForm);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername

View File

@ -43,7 +43,7 @@ public class SysPasswordService
return CacheConstants.PWD_ERR_CNT_KEY + username;
}
public void validate(SysUser user)
public void validate(String userPassword)
{
Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
String username = usernamePasswordAuthenticationToken.getName();
@ -62,7 +62,7 @@ public class SysPasswordService
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
}
if (!matches(user, password))
if (!matches(userPassword, password))
{
retryCount = retryCount + 1;
redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
@ -74,9 +74,9 @@ public class SysPasswordService
}
}
public boolean matches(SysUser user, String rawPassword)
public boolean matches(String userPassword, String rawPassword)
{
return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
return SecurityUtils.matchesPassword(rawPassword, userPassword);
}
public void clearLoginRecordCache(String loginName)

View File

@ -0,0 +1,97 @@
package com.ff.base.web.service;
import com.ff.base.constant.Constants;
import com.ff.base.core.domain.model.LoginUser;
import com.ff.base.enums.LoginType;
import com.ff.base.enums.UserStatus;
import com.ff.base.exception.ServiceException;
import com.ff.base.system.domain.SysRole;
import com.ff.base.system.domain.SysUser;
import com.ff.base.system.domain.TenantSecretKey;
import com.ff.base.system.service.ISysMenuService;
import com.ff.base.system.service.ISysRoleService;
import com.ff.base.system.service.ISysUserService;
import com.ff.base.system.service.ITenantSecretKeyService;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Set;
/**
*
*
* @author ff
*/
@Service
public class TenantDetailsServiceImpl implements UserDetailsService
{
private static final Logger log = LoggerFactory.getLogger(TenantDetailsServiceImpl.class);
@Resource
private ITenantSecretKeyService tenantSecretKeyService;
@Resource
private SysPasswordService passwordService;
@Resource
private ISysMenuService menuService;
@Resource
private SysPermissionService permissionService;
@Resource
private ISysRoleService roleService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
{
TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyByTenantKey(username);
if (StringUtils.isNull(tenantSecretKey))
{
log.info("登录用户:{} 不存在.", username);
throw new ServiceException(MessageUtils.message("user.not.exists"));
}
else if (!tenantSecretKey.getTenantStatus())
{
log.info("登录用户:{} 已被停用.", username);
throw new ServiceException(MessageUtils.message("user.blocked"));
}
passwordService.validate(tenantSecretKey.getPassword());
return createLoginUser(tenantSecretKey);
}
public UserDetails createLoginUser(TenantSecretKey tenantSecretKey)
{
SysRole sysRole = roleService.selectRoleByRoleKey(Constants.TENANT_ROLE);
SysUser sysUser=new SysUser();
sysUser.setUserId(tenantSecretKey.getId());
sysUser.setUserName(tenantSecretKey.getTenantKey());
sysUser.setNickName(tenantSecretKey.getTenantKey());
sysUser.setPassword(tenantSecretKey.getPassword());
sysUser.setLoginType(LoginType.TENANT.getValue());
sysUser.setLoginIp(tenantSecretKey.getLoginIp());
sysUser.setLoginDate(tenantSecretKey.getLoginData());
ArrayList<SysRole> sysRoles = new ArrayList<>();
sysRoles.add(sysRole);
sysUser.setRoles(sysRoles);
sysUser.setRoleId(sysRole.getRoleId());
sysUser.setRoleIds(new Long[]{sysRole.getRoleId()});
return new LoginUser(tenantSecretKey.getId(),null, sysUser, menuService.selectMenuPermsByRoleId(sysRole.getRoleId()));
}
}

View File

@ -1,5 +1,6 @@
package com.ff.base.web.service;
import com.ff.base.enums.LoginType;
import com.ff.base.system.domain.SysUser;
import com.ff.base.core.domain.model.LoginUser;
import com.ff.base.enums.UserStatus;
@ -54,13 +55,14 @@ public class UserDetailsServiceImpl implements UserDetailsService
throw new ServiceException(MessageUtils.message("user.blocked"));
}
passwordService.validate(user);
passwordService.validate(user.getPassword());
return createLoginUser(user);
}
public UserDetails createLoginUser(SysUser user)
{
user.setLoginType(LoginType.ADMIN.getValue());
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
}
}

View File

@ -73,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertConfig" parameterType="SysConfig">
insert into sys_config (
<if test="configId != null ">config_id,</if>
<if test="configName != null and configName != '' ">config_name,</if>
<if test="configKey != null and configKey != '' ">config_key,</if>
<if test="configValue != null and configValue != '' ">config_value,</if>
@ -81,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="configId != null ">#{configId},</if>
<if test="configName != null and configName != ''">#{configName},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if>

View File

@ -96,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDictData" parameterType="SysDictData">
insert into sys_dict_data(
<if test="dictCode !=null">dict_code,</if>
<if test="dictSort != null">dict_sort,</if>
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
<if test="dictValue != null and dictValue != ''">dict_value,</if>
@ -108,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="dictCode !=null">#{dictCode},</if>
<if test="dictSort != null">#{dictSort},</if>
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>

View File

@ -88,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDictType" parameterType="SysDictType">
insert into sys_dict_type(
<if test="dictId != null">dict_id,</if>
<if test="dictName != null and dictName != ''">dict_name,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="status != null">status,</if>
@ -95,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="dictId != null">#{dictId},</if>
<if test="dictName != null and dictName != ''">#{dictName},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="status != null">#{status},</if>

View File

@ -17,8 +17,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<insert id="insertLogininfor" parameterType="SysLogininfor">
insert into sys_logininfor (user_name, status, ipaddr, login_location, browser, os, msg, login_time)
values (#{userName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, UNIX_TIMESTAMP() * 1000)
insert into sys_logininfor (info_id, user_name, status, ipaddr, login_location, browser, os, msg, login_time)
values (#{infoId},#{userName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, UNIX_TIMESTAMP() * 1000)
</insert>
<select id="selectLogininforList" parameterType="SysLogininfor" resultMap="SysLogininforResult">

View File

@ -74,14 +74,18 @@
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
<select id="selectMenuTreeByUserId" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.route_name, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
where m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
and ro.role_id in
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
order by m.parent_id, m.order_num
</select>

View File

@ -30,8 +30,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<insert id="insertOperlog" parameterType="SysOperLog">
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, UNIX_TIMESTAMP() * 1000)
insert into sys_oper_log(oper_Id,title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time)
values (#{operId},#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, UNIX_TIMESTAMP() * 1000)
</insert>
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">

View File

@ -90,6 +90,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where r.role_name=#{roleName} and r.del_flag = '0' limit 1
</select>
<select id="selectRoleByRoleKey" parameterType="String" resultMap="SysRoleResult">
select role_id,
role_name,
role_key,
role_sort,
data_scope,
status,
del_flag,
create_by,
create_time,
update_by,
update_time,
remark
from sys_role where del_flag = '0' and role_key=#{roleKey} limit 1
</select>
<select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1

View File

@ -222,25 +222,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectMemberUserByUserName" resultMap="SysUserResult">
SELECT
u.id AS user_id,
u.member_account AS user_name,
u.member_account AS nick_name,
u.real_name,
u.email,
u.avatar,
u.phone_number AS phonenumber,
u.PASSWORD,
u.sex,
u.STATUS,
u.login_ip,
u.login_date,
1 AS login_type
FROM
ff_member u
WHERE
u.member_account = #{accountName}
OR u.phone_number = #{accountName}
</select>
</mapper>