天翼云-物理机查询、编辑、删除

develop
yuemian 2024-09-02 16:56:01 +08:00
parent 57edbdd781
commit 73998f4e56
3 changed files with 4 additions and 56 deletions

View File

@ -39,5 +39,6 @@ CREATE TABLE `physical_server` (
`tenant_id` bigint DEFAULT NULL COMMENT '租户id',
`project_id` bigint DEFAULT NULL COMMENT '项目id',
`is_deleted` tinyint(1) DEFAULT NULL COMMENT '是否删除',
`display_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '展示名称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

View File

@ -128,6 +128,9 @@ public class PhysicalServer extends Generic {
@Column("creator_id")
private Long creatorId;
@Column("mender_id")
private Long menderId;
@Column("tenant_id")
private Long tenantId;

View File

@ -1,56 +0,0 @@
package com.bocloud.cmp.repository;
import com.bocloud.cmp.entity.PhysicalServer;
import com.megatron.common.utils.Common;
import com.megatron.common.utils.MapTools;
import com.megatron.database.core.intf.impl.BasicGenericDao;
import com.megatron.framework.core.CurrentService;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 访
*
* @author wangyu
* @version 1.0
* @since 2020515
*/
@Repository("serverRepository")
public class PhysicalServerRepository extends BasicGenericDao<PhysicalServer, Long> {
public PhysicalServerRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate, CurrentService service) {
super(jdbcTemplate, npJdbcTemplate, service);
}
public List<PhysicalServer> listByVendor(Long vendorId) {
String sql = "select a.* from physical_server a where a.is_deleted = 0";
Map<String, Object> params = new HashMap<>(8);
if (null != vendorId) {
sql += " and a.vendor_id = :vendorId";
params.put(Common.VENDORID, vendorId);
}
return this.list(PhysicalServer.class, sql, params);
}
public boolean removeByVendor(Long vendorId, Long userId) {
String sql = "update physical_server set is_deleted = true , gmt_modify = :gmtModify where is_deleted = 0 and vendor_id = :vendorId";
Map<String, Object> params = MapTools.simpleMap(Common.VENDORID, vendorId);
params.put("gmtModify", new Date());
return this.execute(sql, params) > 0;
}
public boolean remove(Long id, Long userId) {
String sql = "update physical_server set is_deleted = true,gmt_modify = :gmtModify where is_deleted = 0 and id = :id";
Map<String, Object> params = MapTools.simpleMap("id", id);
params.put("gmtModify", new Date());
return this.execute(sql, params) > 0;
}
}