feat(sys): 添加系统公告模块并优化租户信息获取

- 新增系统公告相关接口、控制器、服务、Mapper和XML文件
- 修改租户信息获取逻辑,按币种获取平台信息
-优化租户白名单相关接口,移除权限控制
main-p
shi 2025-02-28 14:01:47 +08:00
parent f4be0750f5
commit 53d0edef5d
13 changed files with 469 additions and 9 deletions

View File

@ -19,6 +19,16 @@ public interface TenantPlatformMapper
*/
TenantPlatform selectTenantPlatformById(Long id);
/**
* id
*
* @param tenantId id
* @return {@link List }<{@link String }>
*/
List<String> selectCurrencyCodeByTenantId(Long tenantId);
/**
*
*

View File

@ -27,6 +27,14 @@ public interface ITenantPlatformService
*/
List<TenantPlatform> selectTenantPlatformList(TenantPlatform tenantPlatform);
/**
* id
*
* @param tenantId id
* @return {@link List }<{@link String }>
*/
List<String> selectCurrencyCodeByTenantId(Long tenantId);
/**
*
*

View File

@ -1,5 +1,6 @@
package com.ff.base.system.service.impl;
import java.util.Collections;
import java.util.List;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,6 +47,17 @@ public class TenantPlatformServiceImpl implements ITenantPlatformService
return tenantPlatformMapper.selectTenantPlatformList(tenantPlatform);
}
/**
* id
*
* @param tenantId id
* @return {@link List }<{@link String }>
*/
@Override
public List<String> selectCurrencyCodeByTenantId(Long tenantId) {
return tenantPlatformMapper.selectCurrencyCodeByTenantId(tenantId);
}
/**
*
*

View File

@ -37,6 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectCurrencyCodeByTenantId" >
select currency_code from ff_tenant_platform
where tenant_id = #{tenantId} group by currency_code
</select>
<insert id="insertTenantPlatform" parameterType="TenantPlatform">
insert into ff_tenant_platform
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -0,0 +1,93 @@
package com.ff.sys.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ff.base.annotation.Log;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.BusinessType;
import com.ff.sys.domain.SysNotice;
import com.ff.sys.service.ISysNoticeService;
import com.ff.base.utils.poi.ExcelUtil;
import com.ff.base.core.page.TableDataInfo;
/**
* Controller
*
* @author shi
* @date 2025-02-28
*/
@RestController
@RequestMapping("/sys/notice")
public class SysNoticeController extends BaseController
{
@Autowired
private ISysNoticeService sysNoticeService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('sys:notice:list')")
@GetMapping("/list")
public TableDataInfo list(SysNotice sysNotice)
{
startPage();
List<SysNotice> list = sysNoticeService.selectSysNoticeList(sysNotice);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('sys:notice:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sysNoticeService.selectSysNoticeById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('sys:notice:add')")
@Log(title = "系统公告", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysNotice sysNotice)
{
return toAjax(sysNoticeService.insertSysNotice(sysNotice));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('sys:notice:edit')")
@Log(title = "系统公告", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysNotice sysNotice)
{
return toAjax(sysNoticeService.updateSysNotice(sysNotice));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('sys:notice:remove')")
@Log(title = "系统公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysNoticeService.deleteSysNoticeByIds(ids));
}
}

View File

@ -0,0 +1,29 @@
package com.ff.sys.domain;
import com.ff.base.annotation.Excel;
import com.ff.base.core.domain.BaseEntity;
import lombok.Data;
/**
* ff_sys_notice
*
* @author shi
* @date 2025-02-28
*/
@Data
public class SysNotice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 内容 */
@Excel(name = "内容")
private String content;
}

View File

@ -0,0 +1,61 @@
package com.ff.sys.mapper;
import java.util.List;
import com.ff.sys.domain.SysNotice;
/**
* Mapper
*
* @author shi
* @date 2025-02-28
*/
public interface SysNoticeMapper
{
/**
*
*
* @param id
* @return
*/
SysNotice selectSysNoticeById(Long id);
/**
*
*
* @param sysNotice
* @return
*/
List<SysNotice> selectSysNoticeList(SysNotice sysNotice);
/**
*
*
* @param sysNotice
* @return
*/
int insertSysNotice(SysNotice sysNotice);
/**
*
*
* @param sysNotice
* @return
*/
int updateSysNotice(SysNotice sysNotice);
/**
*
*
* @param id
* @return
*/
int deleteSysNoticeById(Long id);
/**
*
*
* @param ids
* @return
*/
int deleteSysNoticeByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ff.sys.service;
import java.util.List;
import com.ff.sys.domain.SysNotice;
/**
* Service
*
* @author shi
* @date 2025-02-28
*/
public interface ISysNoticeService
{
/**
*
*
* @param id
* @return
*/
SysNotice selectSysNoticeById(Long id);
/**
*
*
* @param sysNotice
* @return
*/
List<SysNotice> selectSysNoticeList(SysNotice sysNotice);
/**
*
*
* @param sysNotice
* @return
*/
int insertSysNotice(SysNotice sysNotice);
/**
*
*
* @param sysNotice
* @return
*/
int updateSysNotice(SysNotice sysNotice);
/**
*
*
* @param ids
* @return
*/
int deleteSysNoticeByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
int deleteSysNoticeById(Long id);
}

View File

@ -0,0 +1,99 @@
package com.ff.sys.service.impl;
import java.util.List;
import com.ff.base.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ff.sys.mapper.SysNoticeMapper;
import com.ff.sys.domain.SysNotice;
import com.ff.sys.service.ISysNoticeService;
import cn.hutool.core.util.IdUtil;
/**
* Service
*
* @author shi
* @date 2025-02-28
*/
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
@Autowired
private SysNoticeMapper sysNoticeMapper;
/**
*
*
* @param id
* @return
*/
@Override
public SysNotice selectSysNoticeById(Long id)
{
return sysNoticeMapper.selectSysNoticeById(id);
}
/**
*
*
* @param sysNotice
* @return
*/
@Override
public List<SysNotice> selectSysNoticeList(SysNotice sysNotice)
{
return sysNoticeMapper.selectSysNoticeList(sysNotice);
}
/**
*
*
* @param sysNotice
* @return
*/
@Override
public int insertSysNotice(SysNotice sysNotice)
{
sysNotice.setId(IdUtil.getSnowflakeNextId());
sysNotice.setCreateTime(DateUtils.getNowDate());
return sysNoticeMapper.insertSysNotice(sysNotice);
}
/**
*
*
* @param sysNotice
* @return
*/
@Override
public int updateSysNotice(SysNotice sysNotice)
{
sysNotice.setUpdateTime(DateUtils.getNowDate());
return sysNoticeMapper.updateSysNotice(sysNotice);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteSysNoticeByIds(Long[] ids)
{
return sysNoticeMapper.deleteSysNoticeByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteSysNoticeById(Long id)
{
return sysNoticeMapper.deleteSysNoticeById(id);
}
}

View File

@ -41,7 +41,6 @@ public class TenantController extends BaseController {
*
* @return {@link AjaxResult }
*/
@PreAuthorize("@ss.hasPermi('tenant:info:query')")
@GetMapping
public AjaxResult getInfo() {
TenantSecretKey tenantSecretKey = tenantSecretKeyService.selectTenantSecretKeyById(getUserId());
@ -50,12 +49,18 @@ public class TenantController extends BaseController {
.tenantGameQuotaList(tenantGameQuotaService.selectTenantGameQuotaList(TenantGameQuota.builder()
.tenantKey(tenantSecretKey.getTenantKey())
.build()))
.tenantPlatforms(tenantPlatformService.selectTenantPlatformList(TenantPlatform.builder()
.tenantId(tenantSecretKey.getId())
.build()))
.currencyCodes(tenantPlatformService.selectCurrencyCodeByTenantId(tenantSecretKey.getId()))
.build();
return success(tenantDTO);
}
@GetMapping("/platforms/{currencyCode}")
public AjaxResult getTenantPlatformsInfo(@PathVariable("currencyCode") String currencyCode) {
return success(tenantPlatformService.selectTenantPlatformList(TenantPlatform.builder()
.currencyCode(currencyCode)
.tenantId(getUserId())
.build()));
}
}

View File

@ -37,7 +37,6 @@ public class TenantWhiteController extends BaseController
/**
*
*/
@PreAuthorize("@ss.hasPermi('tenant:white:list')")
@GetMapping("/list")
public TableDataInfo list(TenantWhite tenantWhite)
{
@ -51,7 +50,6 @@ public class TenantWhiteController extends BaseController
/**
*
*/
@PreAuthorize("@ss.hasPermi('tenant:white:add')")
@Log(title = "租户白名单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TenantWhite tenantWhite)
@ -64,7 +62,6 @@ public class TenantWhiteController extends BaseController
/**
*
*/
@PreAuthorize("@ss.hasPermi('tenant:white:remove')")
@Log(title = "租户白名单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)

View File

@ -34,7 +34,7 @@ public class TenantDTO implements java.io.Serializable{
private List<TenantGameQuota> tenantGameQuotaList;
/**
*
*
*/
private List<TenantPlatform> tenantPlatforms;
private List<String> currencyCodes;
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ff.sys.mapper.SysNoticeMapper">
<resultMap type="SysNotice" id="SysNoticeResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSysNoticeVo">
select id, title, content, create_by, create_time, update_by, update_time from ff_sys_notice
</sql>
<select id="selectSysNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
<include refid="selectSysNoticeVo"/>
<where>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
</where>
</select>
<select id="selectSysNoticeById" parameterType="Long" resultMap="SysNoticeResult">
<include refid="selectSysNoticeVo"/>
where id = #{id}
</select>
<insert id="insertSysNotice" parameterType="SysNotice">
insert into ff_sys_notice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="title != null">title,</if>
<if test="content != null">content,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="title != null">#{title},</if>
<if test="content != null">#{content},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSysNotice" parameterType="SysNotice">
update ff_sys_notice
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="content != null">content = #{content},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysNoticeById" parameterType="Long">
delete from ff_sys_notice where id = #{id}
</delete>
<delete id="deleteSysNoticeByIds" parameterType="String">
delete from ff_sys_notice where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>