修复:服务管理模块a-assets-server

This commit is contained in:
2025-03-03 18:39:56 +08:00
parent 02949a028f
commit 1013e7a432
7 changed files with 112 additions and 335 deletions

View File

@@ -1,15 +1,13 @@
package com.gxwebsoft.oa.controller;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.oa.service.OaAssetsServerService;
import com.gxwebsoft.oa.entity.OaAssetsServer;
import com.gxwebsoft.oa.param.OaAssetsServerParam;
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 com.gxwebsoft.oa.service.OaAssetsServerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -19,53 +17,47 @@ import javax.annotation.Resource;
import java.util.List;
/**
* 服务器资产记录表控制器
* 服务控制器
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
@Api(tags = "服务器资产记录表管理")
@Api(tags = "服务管理")
@RestController
@RequestMapping("/api/oa/oa-assets-server")
public class OaAssetsServerController extends BaseController {
@Resource
private OaAssetsServerService oaAssetsServerService;
@ApiOperation("分页查询服务器资产记录表")
@ApiOperation("分页查询服务")
@GetMapping("/page")
public ApiResult<PageResult<OaAssetsServer>> page(OaAssetsServerParam param) {
// 使用关联查询
return success(oaAssetsServerService.pageRel(param));
}
@ApiOperation("查询全部服务器资产记录表")
@ApiOperation("查询全部服务")
@GetMapping()
public ApiResult<List<OaAssetsServer>> list(OaAssetsServerParam param) {
PageParam<OaAssetsServer, OaAssetsServerParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
return success(oaAssetsServerService.list(page.getOrderWrapper()));
// 使用关联查询
//return success(oaAssetsServerService.listRel(param));
return success(oaAssetsServerService.listRel(param));
}
@PreAuthorize("hasAuthority('oa:oaAssetsServer:list')")
@OperationLog
@ApiOperation("根据id查询服务器资产记录表")
@ApiOperation("根据id查询服务")
@GetMapping("/{id}")
public ApiResult<OaAssetsServer> get(@PathVariable("id") Integer id) {
return success(oaAssetsServerService.getById(id));
// 使用关联查询
//return success(oaAssetsServerService.getByIdRel(id));
return success(oaAssetsServerService.getByIdRel(id));
}
@ApiOperation("添加服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:save')")
@ApiOperation("添加服务")
@PostMapping()
public ApiResult<?> save(@RequestBody OaAssetsServer oaAssetsServer) {
// 记录当前登录用户id
User loginUser = getLoginUser();
User loginUser = getLoginUser();
if (loginUser != null) {
oaAssetsServer.setUserId(loginUser.getUserId());
oaAssetsServer.setTenantId(loginUser.getTenantId());
}
if (oaAssetsServerService.save(oaAssetsServer)) {
return success("添加成功");
@@ -73,7 +65,8 @@ public class OaAssetsServerController extends BaseController {
return fail("添加失败");
}
@ApiOperation("修改服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:update')")
@ApiOperation("修改服务")
@PutMapping()
public ApiResult<?> update(@RequestBody OaAssetsServer oaAssetsServer) {
if (oaAssetsServerService.updateById(oaAssetsServer)) {
@@ -82,7 +75,8 @@ public class OaAssetsServerController extends BaseController {
return fail("修改失败");
}
@ApiOperation("删除服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:remove')")
@ApiOperation("删除服务")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (oaAssetsServerService.removeById(id)) {
@@ -91,7 +85,8 @@ public class OaAssetsServerController extends BaseController {
return fail("删除失败");
}
@ApiOperation("批量添加服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:save')")
@ApiOperation("批量添加服务")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<OaAssetsServer> list) {
if (oaAssetsServerService.saveBatch(list)) {
@@ -100,16 +95,18 @@ public class OaAssetsServerController extends BaseController {
return fail("添加失败");
}
@ApiOperation("批量修改服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:update')")
@ApiOperation("批量修改服务")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<OaAssetsServer> batchParam) {
if (batchParam.update(oaAssetsServerService, "server_id")) {
if (batchParam.update(oaAssetsServerService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除服务器资产记录表")
@PreAuthorize("hasAuthority('oa:oaAssetsServer:remove')")
@ApiOperation("批量删除服务")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (oaAssetsServerService.removeByIds(ids)) {

View File

@@ -1,130 +1,56 @@
package com.gxwebsoft.oa.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.util.Date;
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;
import java.io.Serializable;
import java.util.Date;
/**
* 服务器资产记录表
* 服务
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "OaAssetsServer对象", description = "服务器资产记录表")
@ApiModel(value = "OaAssetsServer对象", description = "服务")
public class OaAssetsServer implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "资产ID")
@TableId(value = "server_id", type = IdType.AUTO)
private Integer serverId;
@ApiModelProperty(value = "插件id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "资产名称")
private String name;
@ApiModelProperty(value = "服务名称")
private String server;
@ApiModelProperty(value = "资产标识")
private String code;
@ApiModelProperty(value = "接口地址")
private String serverUrl;
@ApiModelProperty(value = "资产类型")
private String type;
@ApiModelProperty(value = "服务器厂商")
private String brand;
@ApiModelProperty(value = "服务器配置")
private String configuration;
@ApiModelProperty(value = "初始账号")
private String account;
@ApiModelProperty(value = "初始密码")
private String password;
@ApiModelProperty(value = "(阿里云/腾讯云)登录账号")
private String brandAccount;
@ApiModelProperty(value = "(阿里云/腾讯云)登录密码")
private String brandPassword;
@ApiModelProperty(value = "宝塔面板")
private String panel;
@ApiModelProperty(value = "宝塔面板账号")
private String panelAccount;
@ApiModelProperty(value = "宝塔面板密码")
private String panelPassword;
@ApiModelProperty(value = "财务信息-合同金额")
private BigDecimal financeAmount;
@ApiModelProperty(value = "购买年限")
private Integer financeYears;
@ApiModelProperty(value = "续费金额")
private BigDecimal financeRenew;
@ApiModelProperty(value = "客户名称")
private String financeCustomerName;
@ApiModelProperty(value = "客户联系人")
private String financeCustomerContact;
@ApiModelProperty(value = "客户联系电话")
private String financeCustomerPhone;
@ApiModelProperty(value = "客户ID")
private Integer customerId;
@ApiModelProperty(value = "客户名称")
private String customerName;
@ApiModelProperty(value = "开放端口")
private String openPort;
@ApiModelProperty(value = "详情内容")
private String content;
@ApiModelProperty(value = "购买时间")
private Date startTime;
@ApiModelProperty(value = "到期时间")
private Date endTime;
@ApiModelProperty(value = "置顶状态")
private String isTop;
@ApiModelProperty(value = "可见性(public,private,protected)")
private String visibility;
@ApiModelProperty(value = "宝塔接口秘钥")
private String btSign;
@ApiModelProperty(value = "文章排序(数字越小越靠前)")
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "描述")
@ApiModelProperty(value = "服务器ID")
private Integer assetsId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "客户ID")
private Integer companyId;
@ApiModelProperty(value = "状态, 10待审核 20已通过 30已驳回")
private Integer status;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "机构id")
private Integer organizationId;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private String status;
@ApiModelProperty(value = "可见用户")
private String userIds;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
@@ -133,10 +59,15 @@ public class OaAssetsServer implements Serializable {
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "应用名称")
@TableField(exist = false)
private String tenantName;
@ApiModelProperty(value = "应用图标")
@TableField(exist = false)
private String logo;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
}

View File

@@ -9,10 +9,10 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 服务器资产记录表Mapper
* 服务Mapper
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
public interface OaAssetsServerMapper extends BaseMapper<OaAssetsServer> {

View File

@@ -7,107 +7,32 @@
SELECT a.*
FROM oa_assets_server a
<where>
<if test="param.serverId != null">
AND a.server_id = #{param.serverId}
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
<if test="param.server != null">
AND a.server LIKE CONCAT('%', #{param.server}, '%')
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.type != null">
AND a.type LIKE CONCAT('%', #{param.type}, '%')
</if>
<if test="param.brand != null">
AND a.brand LIKE CONCAT('%', #{param.brand}, '%')
</if>
<if test="param.configuration != null">
AND a.configuration LIKE CONCAT('%', #{param.configuration}, '%')
</if>
<if test="param.account != null">
AND a.account LIKE CONCAT('%', #{param.account}, '%')
</if>
<if test="param.password != null">
AND a.password LIKE CONCAT('%', #{param.password}, '%')
</if>
<if test="param.brandAccount != null">
AND a.brand_account LIKE CONCAT('%', #{param.brandAccount}, '%')
</if>
<if test="param.brandPassword != null">
AND a.brand_password LIKE CONCAT('%', #{param.brandPassword}, '%')
</if>
<if test="param.panel != null">
AND a.panel LIKE CONCAT('%', #{param.panel}, '%')
</if>
<if test="param.panelAccount != null">
AND a.panel_account LIKE CONCAT('%', #{param.panelAccount}, '%')
</if>
<if test="param.panelPassword != null">
AND a.panel_password LIKE CONCAT('%', #{param.panelPassword}, '%')
</if>
<if test="param.financeAmount != null">
AND a.finance_amount = #{param.financeAmount}
</if>
<if test="param.financeYears != null">
AND a.finance_years = #{param.financeYears}
</if>
<if test="param.financeRenew != null">
AND a.finance_renew = #{param.financeRenew}
</if>
<if test="param.financeCustomerName != null">
AND a.finance_customer_name LIKE CONCAT('%', #{param.financeCustomerName}, '%')
</if>
<if test="param.financeCustomerContact != null">
AND a.finance_customer_contact LIKE CONCAT('%', #{param.financeCustomerContact}, '%')
</if>
<if test="param.financeCustomerPhone != null">
AND a.finance_customer_phone LIKE CONCAT('%', #{param.financeCustomerPhone}, '%')
</if>
<if test="param.customerId != null">
AND a.customer_id = #{param.customerId}
</if>
<if test="param.customerName != null">
AND a.customer_name LIKE CONCAT('%', #{param.customerName}, '%')
</if>
<if test="param.openPort != null">
AND a.open_port LIKE CONCAT('%', #{param.openPort}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.endTime != null">
AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
</if>
<if test="param.isTop != null">
AND a.is_top LIKE CONCAT('%', #{param.isTop}, '%')
</if>
<if test="param.visibility != null">
AND a.visibility LIKE CONCAT('%', #{param.visibility}, '%')
</if>
<if test="param.btSign != null">
AND a.bt_sign LIKE CONCAT('%', #{param.btSign}, '%')
<if test="param.serverUrl != null">
AND a.server_url LIKE CONCAT('%', #{param.serverUrl}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.assetsId != null">
AND a.assets_id = #{param.assetsId}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.companyId != null">
AND a.company_id = #{param.companyId}
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.organizationId != null">
AND a.organization_id = #{param.organizationId}
</if>
<if test="param.status != null">
AND a.status LIKE CONCAT('%', #{param.status}, '%')
<if test="param.userIds != null">
AND a.user_ids LIKE CONCAT('%', #{param.userIds}, '%')
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
@@ -121,6 +46,11 @@
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.tenant_id = #{param.keywords}
OR a.server_url LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>

View File

@@ -1,139 +1,58 @@
package com.gxwebsoft.oa.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 com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 服务器资产记录表查询参数
* 服务查询参数
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "OaAssetsServerParam对象", description = "服务器资产记录表查询参数")
@ApiModel(value = "OaAssetsServerParam对象", description = "服务查询参数")
public class OaAssetsServerParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "资产ID")
@ApiModelProperty(value = "插件id")
@QueryField(type = QueryType.EQ)
private Integer serverId;
private Integer id;
@ApiModelProperty(value = "资产名称")
private String name;
@ApiModelProperty(value = "服务名称")
private String server;
@ApiModelProperty(value = "资产标识")
private String code;
@ApiModelProperty(value = "接口地址")
private String serverUrl;
@ApiModelProperty(value = "资产类型")
private String type;
@ApiModelProperty(value = "服务器厂商")
private String brand;
@ApiModelProperty(value = "服务器配置")
private String configuration;
@ApiModelProperty(value = "初始账号")
private String account;
@ApiModelProperty(value = "初始密码")
private String password;
@ApiModelProperty(value = "(阿里云/腾讯云)登录账号")
private String brandAccount;
@ApiModelProperty(value = "(阿里云/腾讯云)登录密码")
private String brandPassword;
@ApiModelProperty(value = "宝塔面板")
private String panel;
@ApiModelProperty(value = "宝塔面板账号")
private String panelAccount;
@ApiModelProperty(value = "宝塔面板密码")
private String panelPassword;
@ApiModelProperty(value = "财务信息-合同金额")
@QueryField(type = QueryType.EQ)
private BigDecimal financeAmount;
@ApiModelProperty(value = "购买年限")
@QueryField(type = QueryType.EQ)
private Integer financeYears;
@ApiModelProperty(value = "续费金额")
@QueryField(type = QueryType.EQ)
private BigDecimal financeRenew;
@ApiModelProperty(value = "客户名称")
private String financeCustomerName;
@ApiModelProperty(value = "客户联系人")
private String financeCustomerContact;
@ApiModelProperty(value = "客户联系电话")
private String financeCustomerPhone;
@ApiModelProperty(value = "客户ID")
@QueryField(type = QueryType.EQ)
private Integer customerId;
@ApiModelProperty(value = "客户名称")
private String customerName;
@ApiModelProperty(value = "开放端口")
private String openPort;
@ApiModelProperty(value = "详情内容")
private String content;
@ApiModelProperty(value = "购买时间")
private String startTime;
@ApiModelProperty(value = "到期时间")
private String endTime;
@ApiModelProperty(value = "置顶状态")
private String isTop;
@ApiModelProperty(value = "可见性(public,private,protected)")
private String visibility;
@ApiModelProperty(value = "宝塔接口秘钥")
private String btSign;
@ApiModelProperty(value = "文章排序(数字越小越靠前)")
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "描述")
@ApiModelProperty(value = "服务器ID")
@QueryField(type = QueryType.EQ)
private Integer assetsId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "客户ID")
@ApiModelProperty(value = "状态, 10待审核 20已通过 30已驳回")
@QueryField(type = QueryType.EQ)
private Integer companyId;
private Integer status;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "机构id")
@QueryField(type = QueryType.EQ)
private Integer organizationId;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private String status;
@ApiModelProperty(value = "可见用户")
private String userIds;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)

View File

@@ -8,10 +8,10 @@ import com.gxwebsoft.oa.param.OaAssetsServerParam;
import java.util.List;
/**
* 服务器资产记录表Service
* 服务Service
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
public interface OaAssetsServerService extends IService<OaAssetsServer> {
@@ -34,9 +34,9 @@ public interface OaAssetsServerService extends IService<OaAssetsServer> {
/**
* 根据id查询
*
* @param serverId 资产ID
* @param id 插件id
* @return OaAssetsServer
*/
OaAssetsServer getByIdRel(Integer serverId);
OaAssetsServer getByIdRel(Integer id);
}

View File

@@ -1,21 +1,21 @@
package com.gxwebsoft.oa.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.oa.mapper.OaAssetsServerMapper;
import com.gxwebsoft.oa.service.OaAssetsServerService;
import com.gxwebsoft.oa.entity.OaAssetsServer;
import com.gxwebsoft.oa.param.OaAssetsServerParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.oa.entity.OaAssetsServer;
import com.gxwebsoft.oa.mapper.OaAssetsServerMapper;
import com.gxwebsoft.oa.param.OaAssetsServerParam;
import com.gxwebsoft.oa.service.OaAssetsServerService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 服务器资产记录表Service实现
* 服务Service实现
*
* @author 科技小王子
* @since 2024-09-10 20:57:41
* @since 2024-10-21 19:15:26
*/
@Service
public class OaAssetsServerServiceImpl extends ServiceImpl<OaAssetsServerMapper, OaAssetsServer> implements OaAssetsServerService {
@@ -23,7 +23,7 @@ public class OaAssetsServerServiceImpl extends ServiceImpl<OaAssetsServerMapper,
@Override
public PageResult<OaAssetsServer> pageRel(OaAssetsServerParam param) {
PageParam<OaAssetsServer, OaAssetsServerParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
page.setDefaultOrder("sort_number asc, create_time desc");
List<OaAssetsServer> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@@ -33,14 +33,14 @@ public class OaAssetsServerServiceImpl extends ServiceImpl<OaAssetsServerMapper,
List<OaAssetsServer> list = baseMapper.selectListRel(param);
// 排序
PageParam<OaAssetsServer, OaAssetsServerParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public OaAssetsServer getByIdRel(Integer serverId) {
public OaAssetsServer getByIdRel(Integer id) {
OaAssetsServerParam param = new OaAssetsServerParam();
param.setServerId(serverId);
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}