diff --git a/src/main/java/com/gxwebsoft/common/system/controller/ProtocolController.java b/src/main/java/com/gxwebsoft/common/system/controller/ProtocolController.java new file mode 100644 index 0000000..74c3941 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/controller/ProtocolController.java @@ -0,0 +1,118 @@ +package com.gxwebsoft.common.system.controller; + +import com.gxwebsoft.common.core.annotation.OperationLog; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.system.entity.Protocol; +import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.common.system.param.ProtocolParam; +import com.gxwebsoft.common.system.service.ProtocolService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.time.LocalDateTime; +import java.util.List; + +/** + * 协议管理控制器 + * + * @author xm + * @since 2026-05-06 08:20:48 + */ +@Api(tags = "协议管理管理") +@RestController +@RequestMapping("/api/system/protocol") +public class ProtocolController extends BaseController { + @Resource + private ProtocolService protocolService; + +// @PreAuthorize("hasAuthority('common.system:protocol:list')") + @OperationLog + @ApiOperation("分页查询协议管理") + @GetMapping("/page") + public ApiResult> page(ProtocolParam param) { + // 使用关联查询 + return success(protocolService.pageRel(param)); + } + +// @PreAuthorize("hasAuthority('common.system:protocol:list')") + @OperationLog + @ApiOperation("查询全部协议管理") + @GetMapping() + public ApiResult> list(ProtocolParam param) { + // 使用关联查询 + return success(protocolService.listRel(param)); + } + +// @PreAuthorize("hasAuthority('common.system:protocol:list')") + @OperationLog + @ApiOperation("根据id查询协议管理") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(protocolService.getByIdRel(id)); + } + + @OperationLog + @ApiOperation("通过端口及协议类型获取协议") + @GetMapping("/getInfo") + @Parameters({ + @Parameter(name = "clientType", description = "适用客户端 1-用户端 2-其他", required = true, example = "1"), + @Parameter(name = "protocolType", description = "协议类型 1-用户协议 2-隐私策略 3-理赔说明 4-个人信息处理授权书", required = true, example = "1") + }) + public ApiResult getInfo(@RequestParam("clientType") Integer clientType, @RequestParam("protocolType") Integer protocolType) { + // 使用关联查询 + return success(protocolService.getInfo(clientType, protocolType)); + } + +// @PreAuthorize("hasAuthority('common.system:protocol:save')") + @OperationLog + @ApiOperation("添加协议管理") + @PostMapping() + public ApiResult save(@Valid @RequestBody Protocol protocol) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + protocol.setCreator(loginUser.getUserId()); + } + protocol.setCreateTime(LocalDateTime.now()); + if (protocolService.save(protocol)) { + return success("添加成功"); + } + return fail("添加失败"); + } + +// @PreAuthorize("hasAuthority('common.system:protocol:update')") + @OperationLog + @ApiOperation("修改协议管理") + @PutMapping() + public ApiResult update(@RequestBody Protocol protocol) { + User loginUser = getLoginUser(); + if (loginUser != null) { + protocol.setUpdater(loginUser.getUserId()); + } + protocol.setUpdateTime(LocalDateTime.now()); + if (protocolService.updateById(protocol)) { + return success("修改成功"); + } + return fail("修改失败"); + } + +// @PreAuthorize("hasAuthority('common.system:protocol:remove')") + @OperationLog + @ApiOperation("删除协议管理") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (protocolService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/common/system/entity/Protocol.java b/src/main/java/com/gxwebsoft/common/system/entity/Protocol.java new file mode 100644 index 0000000..55b2c7b --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/entity/Protocol.java @@ -0,0 +1,59 @@ +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 io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 协议管理 + * + * @author xm + * @since 2026-05-06 08:20:47 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "Protocol对象", description = "协议管理") +@TableName("sys_protocol") +public class Protocol implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "适用客户端 1-用户端 2-其他") + private Integer clientType; + + @ApiModelProperty(value = "协议类型 1-用户协议 2-隐私策略 3-理赔说明 4-个人信息处理授权书") + private Integer protocolType; + + @ApiModelProperty(value = "协议内容") + private String protocolContent; + + @ApiModelProperty(value = "租户ID") + private Integer tenantId; + + @ApiModelProperty(value = "创建人") + private Integer creator; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改人") + private Integer updater; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + + @ApiModelProperty(value = "是否删除 0-未删 1-已删") + @TableLogic + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/common/system/mapper/ProtocolMapper.java b/src/main/java/com/gxwebsoft/common/system/mapper/ProtocolMapper.java new file mode 100644 index 0000000..f38e257 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/mapper/ProtocolMapper.java @@ -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.Protocol; +import com.gxwebsoft.common.system.param.ProtocolParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 协议管理Mapper + * + * @author xm + * @since 2026-05-06 08:20:47 + */ +public interface ProtocolMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ProtocolParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ProtocolParam param); + +} diff --git a/src/main/java/com/gxwebsoft/common/system/mapper/xml/ProtocolMapper.xml b/src/main/java/com/gxwebsoft/common/system/mapper/xml/ProtocolMapper.xml new file mode 100644 index 0000000..13973ac --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/mapper/xml/ProtocolMapper.xml @@ -0,0 +1,53 @@ + + + + + + + SELECT a.* + FROM sys_protocol a + + + AND a.id = #{param.id} + + + AND a.protocol_type = #{param.protocolType} + + + AND a.client_type = #{param.clientType} + + + AND a.protocol_content LIKE CONCAT('%', #{param.protocolContent}, '%') + + + AND a.creator = #{param.creator} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND a.updater = #{param.updater} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/common/system/param/ProtocolParam.java b/src/main/java/com/gxwebsoft/common/system/param/ProtocolParam.java new file mode 100644 index 0000000..608a0ed --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/param/ProtocolParam.java @@ -0,0 +1,52 @@ +package com.gxwebsoft.common.system.param; + +import com.gxwebsoft.common.core.annotation.QueryField; +import com.gxwebsoft.common.core.annotation.QueryType; +import com.gxwebsoft.common.core.web.BaseParam; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 协议管理查询参数 + * + * @author xm + * @since 2026-05-06 08:20:47 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "ProtocolParam对象", description = "协议管理查询参数") +public class ProtocolParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "协议类型 1-用户协议 2-隐私策略 3-理赔说明 4-个人信息处理授权书") + @QueryField(type = QueryType.EQ) + private Integer protocolType; + + @ApiModelProperty(value = "适用客户端 1-用户端 2-其他") + @QueryField(type = QueryType.EQ) + private Integer clientType; + + @ApiModelProperty(value = "协议内容") + private String protocolContent; + + @ApiModelProperty(value = "创建人") + @QueryField(type = QueryType.EQ) + private Integer creator; + + @ApiModelProperty(value = "修改人") + @QueryField(type = QueryType.EQ) + private Integer updater; + + @ApiModelProperty(value = "是否删除 0-未删 1-已删") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/common/system/service/ProtocolService.java b/src/main/java/com/gxwebsoft/common/system/service/ProtocolService.java new file mode 100644 index 0000000..12ae826 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/service/ProtocolService.java @@ -0,0 +1,50 @@ +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.Protocol; +import com.gxwebsoft.common.system.param.ProtocolParam; + +import java.util.List; + +/** + * 协议管理Service + * + * @author xm + * @since 2026-05-06 08:20:47 + */ +public interface ProtocolService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ProtocolParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ProtocolParam param); + + /** + * 根据id查询 + * + * @param id 主键ID + * @return Protocol + */ + Protocol getByIdRel(Integer id); + + /** + * 通过端口及协议类型获取协议 + * @param clientType 端口 + * @param protocolType 协议类型 + * @return + */ + Protocol getInfo(Integer clientType, Integer protocolType); + +} diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/ProtocolServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/ProtocolServiceImpl.java new file mode 100644 index 0000000..29d8dd6 --- /dev/null +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/ProtocolServiceImpl.java @@ -0,0 +1,58 @@ +package com.gxwebsoft.common.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.common.system.mapper.ProtocolMapper; +import com.gxwebsoft.common.system.service.ProtocolService; +import com.gxwebsoft.common.system.entity.Protocol; +import com.gxwebsoft.common.system.param.ProtocolParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 协议管理Service实现 + * + * @author xm + * @since 2026-05-06 08:20:47 + */ +@Service +public class ProtocolServiceImpl extends ServiceImpl implements ProtocolService { + + @Override + public PageResult pageRel(ProtocolParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ProtocolParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("create_time desc"); + return page.sortRecords(list); + } + + @Override + public Protocol getByIdRel(Integer id) { + ProtocolParam param = new ProtocolParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + + @Override + public Protocol getInfo(Integer clientType, Integer protocolType) { + List list = lambdaQuery().eq(Protocol::getClientType, clientType).eq(Protocol::getProtocolType, protocolType).list(); + if(CollectionUtils.isNotEmpty(list)){ + return list.get(0); + }else { + throw new RuntimeException("暂无相关协议!"); + } + } + +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 0bb9236..6de8d14 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -6,7 +6,7 @@ spring: allow-circular-references: true allow-bean-definition-overriding: true # 允许bean定义覆盖,解决RabbitMQConfig中的objectMapper bean冲突 datasource: - url: jdbc:mysql://8.134.55.105:13306/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 + url: jdbc:mysql://47.107.249.41:13306/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 username: gxwebsoft_core password: ZXT5FkBREBJQPiAs driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a100196..9e1f787 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -63,16 +63,16 @@ spring: password: redis_t74P8C # RabbitMQ 配置 - rabbitmq: - host: 1Panel-rabbitmq-kvHZ - port: 5672 - username: rabbitmq - password: rabbitmq - virtual-host: / - # 开启确认模式 - publisher-confirm-type: correlated - # 开启Return模式 - publisher-returns: true +# rabbitmq: +# host: 1Panel-rabbitmq-kvHZ +# port: 5672 +# username: rabbitmq +# password: rabbitmq +# virtual-host: / +# # 开启确认模式 +# publisher-confirm-type: correlated +# # 开启Return模式 +# publisher-returns: true # 邮件服务器配置 mail: diff --git a/src/test/java/com/gxwebsoft/generator/SysGenerator.java b/src/test/java/com/gxwebsoft/generator/SysGenerator.java index 4ab130a..5bc7c7a 100644 --- a/src/test/java/com/gxwebsoft/generator/SysGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/SysGenerator.java @@ -33,11 +33,11 @@ public class SysGenerator { // Vue文件输出目录 private static final String OUTPUT_DIR_VUE = "/src"; // 作者名称 - private static final String AUTHOR = "科技小王子"; + private static final String AUTHOR = "xm"; // 是否在xml中添加二级缓存配置 private static final boolean ENABLE_CACHE = false; // 数据库连接配置 - private static final String DB_URL = "jdbc:mysql://8.134.55.105:13306/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8"; + private static final String DB_URL = "jdbc:mysql://47.107.249.41:13306/gxwebsoft_core?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8"; private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver"; private static final String DB_USERNAME = "gxwebsoft_core"; private static final String DB_PASSWORD = "ZXT5FkBREBJQPiAs"; @@ -54,6 +54,7 @@ public class SysGenerator { // "sys_user_verify" // "sys_user_role", // "sys_authorize_code" + "aa" }; // 需要去除的表前缀 private static final String[] TABLE_PREFIX = new String[]{