新增:服务器白名单功能
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
package com.gxwebsoft.common.system.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.WhiteDomainService;
|
||||
import com.gxwebsoft.common.system.entity.WhiteDomain;
|
||||
import com.gxwebsoft.common.system.param.WhiteDomainParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器白名单控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
@Api(tags = "服务器白名单管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/common.system/white-domain")
|
||||
public class WhiteDomainController extends BaseController {
|
||||
@Resource
|
||||
private WhiteDomainService whiteDomainService;
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:list')")
|
||||
@ApiOperation("分页查询服务器白名单")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<WhiteDomain>> page(WhiteDomainParam param) {
|
||||
// 使用关联查询
|
||||
return success(whiteDomainService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:list')")
|
||||
@ApiOperation("查询全部服务器白名单")
|
||||
@GetMapping()
|
||||
public ApiResult<List<WhiteDomain>> list(WhiteDomainParam param) {
|
||||
// 使用关联查询
|
||||
return success(whiteDomainService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:list')")
|
||||
@ApiOperation("根据id查询服务器白名单")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<WhiteDomain> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(whiteDomainService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加服务器白名单")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody WhiteDomain whiteDomain) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
whiteDomain.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (whiteDomainService.save(whiteDomain)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改服务器白名单")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody WhiteDomain whiteDomain) {
|
||||
if (whiteDomainService.updateById(whiteDomain)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除服务器白名单")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (whiteDomainService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加服务器白名单")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<WhiteDomain> list) {
|
||||
if (whiteDomainService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改服务器白名单")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<WhiteDomain> batchParam) {
|
||||
if (batchParam.update(whiteDomainService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('common.system:whiteDomain:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除服务器白名单")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (whiteDomainService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gxwebsoft.common.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务器白名单
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "WhiteDomain对象", description = "服务器白名单")
|
||||
@TableName("sys_white_domain")
|
||||
public class WhiteDomain implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "域名")
|
||||
private String domain;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.common.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.common.system.entity.WhiteDomain;
|
||||
import com.gxwebsoft.common.system.param.WhiteDomainParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器白名单Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
public interface WhiteDomainMapper extends BaseMapper<WhiteDomain> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<WhiteDomain>
|
||||
*/
|
||||
List<WhiteDomain> selectPageRel(@Param("page") IPage<WhiteDomain> page,
|
||||
@Param("param") WhiteDomainParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<WhiteDomain> selectListRel(@Param("param") WhiteDomainParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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.gxwebsoft.common.system.mapper.WhiteDomainMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_white_domain a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.domain != null">
|
||||
AND a.domain LIKE CONCAT('%', #{param.domain}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.WhiteDomain">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.WhiteDomain">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gxwebsoft.common.system.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务器白名单查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "WhiteDomainParam对象", description = "服务器白名单查询参数")
|
||||
public class WhiteDomainParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "域名")
|
||||
private String domain;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "排序号")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.common.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.WhiteDomain;
|
||||
import com.gxwebsoft.common.system.param.WhiteDomainParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器白名单Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
public interface WhiteDomainService extends IService<WhiteDomain> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<WhiteDomain>
|
||||
*/
|
||||
PageResult<WhiteDomain> pageRel(WhiteDomainParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<WhiteDomain>
|
||||
*/
|
||||
List<WhiteDomain> listRel(WhiteDomainParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return WhiteDomain
|
||||
*/
|
||||
WhiteDomain getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.common.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.system.mapper.WhiteDomainMapper;
|
||||
import com.gxwebsoft.common.system.service.WhiteDomainService;
|
||||
import com.gxwebsoft.common.system.entity.WhiteDomain;
|
||||
import com.gxwebsoft.common.system.param.WhiteDomainParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器白名单Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-26 00:22:21
|
||||
*/
|
||||
@Service
|
||||
public class WhiteDomainServiceImpl extends ServiceImpl<WhiteDomainMapper, WhiteDomain> implements WhiteDomainService {
|
||||
|
||||
@Override
|
||||
public PageResult<WhiteDomain> pageRel(WhiteDomainParam param) {
|
||||
PageParam<WhiteDomain, WhiteDomainParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<WhiteDomain> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WhiteDomain> listRel(WhiteDomainParam param) {
|
||||
List<WhiteDomain> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<WhiteDomain, WhiteDomainParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WhiteDomain getByIdRel(Integer id) {
|
||||
WhiteDomainParam param = new WhiteDomainParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,7 +64,8 @@ public class SysGenerator {
|
||||
// "sys_app_user",
|
||||
// "sys_app_url",
|
||||
// "sys_app_renew"
|
||||
"sys_version"
|
||||
// "sys_version",
|
||||
"sys_white_domain"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
|
||||
Reference in New Issue
Block a user