diff options
| author | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-03-15 10:39:25 +0800 |
|---|---|---|
| committer | tanghao <admin@LAPTOP-QCSKVLI9> | 2021-03-15 10:39:25 +0800 |
| commit | 10b33393c207cb361dc24a229f6ef73b9486fbc9 (patch) | |
| tree | 9208cdb69402430d57047e4b4c323071038aa81b | |
| parent | 6fb434c8aeb06be266fffa15742ea1bc7e524192 (diff) | |
feat: asset account 功能接口 增删改查相关
15 files changed, 530 insertions, 1 deletions
diff --git a/nz-admin/src/main/java/com/nis/common/utils/Constant.java b/nz-admin/src/main/java/com/nis/common/utils/Constant.java index 2631ad09..88a02819 100644 --- a/nz-admin/src/main/java/com/nis/common/utils/Constant.java +++ b/nz-admin/src/main/java/com/nis/common/utils/Constant.java @@ -692,4 +692,13 @@ public class Constant { // endpoint state告警规则 public static final String ENDPOINT_ALERT_RULE="endpoint_alert_rule"; + + // 存放prometheus推送过来的告警消息 + public static final String ALERT_MESSAGE_RECV="alert_message_recv"; + + // 存放prometheus已经处理过的告警信息 + public static final String ALERT_MESSAGE_SILENCE="alert_message_silence"; + + // 存放需要通知的告警信息 + public static final String ALERT_MESSAGE_NOTIFY="alert_message_notify"; } diff --git a/nz-admin/src/main/java/com/nis/modules/asset/controller/AssetAccountController.java b/nz-admin/src/main/java/com/nis/modules/asset/controller/AssetAccountController.java new file mode 100644 index 00000000..bc5ee8dd --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/controller/AssetAccountController.java @@ -0,0 +1,133 @@ +package com.nis.modules.asset.controller; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.nis.common.annotation.SysLog; +import com.nis.common.smartvalidate.ValidateUtils; +import com.nis.common.utils.DateUtil; +import com.nis.common.utils.OperationEnum; +import com.nis.common.utils.PageUtils; +import com.nis.common.utils.R; +import com.nis.common.utils.RCode; +import com.nis.common.utils.TypeEnum; +import com.nis.modules.asset.entity.AssetAccount; +import com.nis.modules.asset.service.AssetAccountService; + +@RestController +@RequestMapping("/asset/account") +public class AssetAccountController { + + @Autowired + private AssetAccountService assetAccountService; + + @GetMapping + @SysLog(operation = OperationEnum.QUERY,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:list"}) + public R list(@RequestParam Map<String, Object> params) { + PageUtils page = assetAccountService.queryPage(params); + return R.ok(page); + } + + @GetMapping("/{id}") + @SysLog(operation = OperationEnum.QUERY,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:id"}) + public R queryById(@PathVariable Integer id) { + + ValidateUtils.is(id).notNull(RCode.ASSET_ACCOUNT_ID_ISNULL); + + AssetAccount AssetAccount = assetAccountService.queryAssetAccountById(id); + return R.ok(AssetAccount); + } + + @GetMapping("/asset/{id}") + @SysLog(operation = OperationEnum.QUERY,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:asset:id"}) + public R queryByAssetId(@PathVariable Integer id) { + ValidateUtils.is(id).notNull(RCode.ASSET_ID_ISNULL); + + PageUtils page = assetAccountService.queryPageByAssetId(id); + + return R.ok(page); + } + + + @PostMapping + @SysLog(operation = OperationEnum.ADD,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:save"}) + public R save(@RequestBody AssetAccount assetAccount) { + ValidateUtils.is(assetAccount.getName()).notNull(RCode.ASSET_ACCOUNT_NAME_ISNULL) + .and(assetAccount.getProtocol()).notNull(RCode.ASSET_ACCOUNT_PROTOCOL_ISNULL) + .and(assetAccount.getAuthType()).notNull(RCode.ASSET_ACCOUNT_AUTHTYPE_ISNULL) + .and(assetAccount.getUsername()).notNull(RCode.ASSET_ACCOUNT_USERNAME_ISNULL) + .and(assetAccount.getPassword()).notNull(RCode.ASSET_ACCOUNT_PASSWORD_ISNULL) + .and(assetAccount.getPriKey()).notNull(RCode.ASSET_ACCOUNT_PRIKEY_ISNULL) + .and(assetAccount.getWeight()).notNull(RCode.ASSET_ACCOUNT_WEIGHT_ISNULL) + .and(assetAccount.getState()).notNull(RCode.ASSET_ACCOUNT_STATE_ISNULL); + + if(assetAccount.getProtocol().equals(2)) { + ValidateUtils.is(assetAccount.getUserTip()).notNull(RCode.ASSET_ACCOUNT_USERTIP_ISNULL) + .and(assetAccount.getPasswordTip()).notNull(RCode.ASSET_ACCOUNT_PASSWORDTIP_ISNULL); + } + + assetAccountService.saveOrUpdateAssetAccount(assetAccount); + return R.ok(); + } + + + @PutMapping + @SysLog(operation = OperationEnum.UPDATE,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:modify"}) + public R modify(@RequestBody AssetAccount assetAccount) { + ValidateUtils.is(assetAccount.getId()).notNull(RCode.ASSET_ACCOUNT_ID_ISNULL) + .and(assetAccount.getName()).notNull(RCode.ASSET_ACCOUNT_NAME_ISNULL) + .and(assetAccount.getProtocol()).notNull(RCode.ASSET_ACCOUNT_PROTOCOL_ISNULL) + .and(assetAccount.getAuthType()).notNull(RCode.ASSET_ACCOUNT_AUTHTYPE_ISNULL) + .and(assetAccount.getUsername()).notNull(RCode.ASSET_ACCOUNT_USERNAME_ISNULL) + .and(assetAccount.getPassword()).notNull(RCode.ASSET_ACCOUNT_PASSWORD_ISNULL) + .and(assetAccount.getPriKey()).notNull(RCode.ASSET_ACCOUNT_PRIKEY_ISNULL) + .and(assetAccount.getWeight()).notNull(RCode.ASSET_ACCOUNT_WEIGHT_ISNULL) + .and(assetAccount.getState()).notNull(RCode.ASSET_ACCOUNT_STATE_ISNULL); + + if(assetAccount.getProtocol().equals(2)) { + ValidateUtils.is(assetAccount.getUserTip()).notNull(RCode.ASSET_ACCOUNT_USERTIP_ISNULL) + .and(assetAccount.getPasswordTip()).notNull(RCode.ASSET_ACCOUNT_PASSWORDTIP_ISNULL); + } + + assetAccountService.saveOrUpdateAssetAccount(assetAccount); + return R.ok(); + } + + @DeleteMapping + @SysLog(operation = OperationEnum.DELETE,type = TypeEnum.ASSETACCOUNT) + @RequiresPermissions({"asset:account:delete"}) + public R delete(@RequestParam Integer... ids) { + ValidateUtils.is(ids).notNull(RCode.ASSET_ACCOUNT_ID_ISNULL); + + assetAccountService.removeByIds(Arrays.asList(ids)); + return R.ok(); + } + + @PutMapping("/rel") + @RequiresPermissions({"asset:account:rel:modify"}) + public R accountAssociation(@RequestParam Integer id , @RequestParam Integer[] ids) { + ValidateUtils.is(ids).notNull(RCode.ASSET_ID_ISNULL) + .and(id).notNull(RCode.ASSET_ACCOUNT_ID_ISNULL); + + assetAccountService.saveAssetAccountRel(id,Arrays.asList(ids)); + + return R.ok(); + } +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountDao.java b/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountDao.java new file mode 100644 index 00000000..751495de --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountDao.java @@ -0,0 +1,23 @@ +package com.nis.modules.asset.dao; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.nis.modules.asset.entity.AssetAccount; + +@Mapper +@Repository +public interface AssetAccountDao extends BaseMapper<AssetAccount>{ + + List<AssetAccount> selectAssetAccounts(IPage<AssetAccount> page,@Param("params")Map<String,Object> params); + + AssetAccount selectAssetAccountById(Integer id); + + List<AssetAccount> selectAssetAccountsByAssetId(IPage<AssetAccount> page,@Param("assetId")Integer assetId); +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountRelDao.java b/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountRelDao.java new file mode 100644 index 00000000..bc1f0a37 --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/dao/AssetAccountRelDao.java @@ -0,0 +1,13 @@ +package com.nis.modules.asset.dao; + +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.nis.modules.asset.entity.AssetAccountRel; + +@Mapper +@Repository +public interface AssetAccountRelDao extends BaseMapper<AssetAccountRel>{ + +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccount.java b/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccount.java new file mode 100644 index 00000000..8227822c --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccount.java @@ -0,0 +1,48 @@ +package com.nis.modules.asset.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; + +import lombok.Data; + +@Data +@TableName("asset_account") +public class AssetAccount { + + + private Integer id; + + private String name; + + private Integer protocol; + + private Integer authType; + + private String username; + + private String password; + + private String priKey; + + private Long updateBy; + + private Date updateAt; + + private String userTip; + + private String passwordTip; + + private Integer weight; + + private Integer state; + + private String seq; + + @TableField(exist = false) + private String updateById; + + @TableField(exist = false) + private String updateByName; +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccountRel.java b/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccountRel.java new file mode 100644 index 00000000..6c91f989 --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/entity/AssetAccountRel.java @@ -0,0 +1,16 @@ +package com.nis.modules.asset.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import lombok.Data; + +@Data +@TableName("asset_account_rel") +public class AssetAccountRel { + + private Integer id; + + private Integer assetId; + + private Integer accountId; +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountRelService.java b/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountRelService.java new file mode 100644 index 00000000..a3dcf83e --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountRelService.java @@ -0,0 +1,9 @@ +package com.nis.modules.asset.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.nis.modules.asset.entity.AssetAccountRel; + +public interface AssetAccountRelService extends IService<AssetAccountRel>{ + + +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountService.java b/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountService.java new file mode 100644 index 00000000..ae0597bd --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/service/AssetAccountService.java @@ -0,0 +1,23 @@ +package com.nis.modules.asset.service; + +import java.util.List; +import java.util.Map; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.nis.common.utils.PageUtils; +import com.nis.modules.asset.entity.AssetAccount; + +public interface AssetAccountService extends IService<AssetAccount>{ + + PageUtils queryPage(Map<String, Object> params); + + void removeByIds(List<Integer> ids); + + AssetAccount queryAssetAccountById(Integer id); + + void saveAssetAccountRel(Integer accountId, List<Integer> assetIds); + + PageUtils queryPageByAssetId(Integer assetId); + + void saveOrUpdateAssetAccount(AssetAccount assetAccount); +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountRelServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountRelServiceImpl.java new file mode 100644 index 00000000..1cf1ca55 --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountRelServiceImpl.java @@ -0,0 +1,20 @@ +package com.nis.modules.asset.service.impl; + + + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.nis.modules.asset.dao.AssetAccountRelDao; +import com.nis.modules.asset.entity.AssetAccountRel; +import com.nis.modules.asset.service.AssetAccountRelService; + +import cn.hutool.log.Log; + +@Service("assetAccountRelService") +public class AssetAccountRelServiceImpl extends ServiceImpl<AssetAccountRelDao,AssetAccountRel> implements AssetAccountRelService{ + + private final static Log logger = Log.get(); + + +} diff --git a/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountServiceImpl.java new file mode 100644 index 00000000..0608dd32 --- /dev/null +++ b/nz-admin/src/main/java/com/nis/modules/asset/service/impl/AssetAccountServiceImpl.java @@ -0,0 +1,91 @@ +package com.nis.modules.asset.service.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.nis.common.utils.DateUtil; +import com.nis.common.utils.PageUtils; +import com.nis.common.utils.Query; +import com.nis.modules.asset.dao.AssetAccountDao; +import com.nis.modules.asset.dao.AssetAccountRelDao; +import com.nis.modules.asset.entity.AssetAccount; +import com.nis.modules.asset.entity.AssetAccountRel; +import com.nis.modules.asset.service.AssetAccountRelService; +import com.nis.modules.asset.service.AssetAccountService; +import com.nis.modules.sys.entity.SysUserEntity; +import com.nis.modules.sys.shiro.ShiroUtils; + +import cn.hutool.log.Log; + +@Service("assetAccountService") +public class AssetAccountServiceImpl extends ServiceImpl<AssetAccountDao,AssetAccount> implements AssetAccountService{ + + private final static Log logger = Log.get(); + + @Autowired + private AssetAccountDao assetAccountDao; + + @Autowired + private AssetAccountRelService assetAccountRelService; + + @Override + public PageUtils queryPage(Map<String, Object> params) { + IPage<AssetAccount> page = new Query<AssetAccount>().getPage(params); + List<AssetAccount> assetAccounts = assetAccountDao.selectAssetAccounts(page,params); + page.setRecords(assetAccounts); + return new PageUtils(page); + } + + @Override + public void removeByIds(List<Integer> ids) { + + //删除asset account表中数据 + assetAccountDao.deleteBatchIds(ids); + + //删除关联表数据 + assetAccountRelService.remove(new LambdaQueryWrapper<AssetAccountRel>().in(AssetAccountRel::getAccountId, ids)); + } + + @Override + public AssetAccount queryAssetAccountById(Integer id) { + return assetAccountDao.selectAssetAccountById(id); + } + + @Override + public void saveAssetAccountRel(Integer accountId, List<Integer> assetIds) { + List<AssetAccountRel> datas =new ArrayList<AssetAccountRel>(); + for(Integer assetId: assetIds) { + AssetAccountRel data = new AssetAccountRel(); + data.setAssetId(assetId); + data.setAccountId(accountId); + datas.add(data); + } + assetAccountRelService.saveBatch(datas); + } + + @Override + public PageUtils queryPageByAssetId(Integer assetId) { + Map<String, Object> params = new HashMap<String, Object>(); + IPage<AssetAccount> page = new Query<AssetAccount>().getPage(params); + List<AssetAccount> assetAccounts = assetAccountDao.selectAssetAccountsByAssetId(page,assetId); + page.setRecords(assetAccounts); + return new PageUtils(page); + } + + @Override + public void saveOrUpdateAssetAccount(AssetAccount assetAccount) { + assetAccount.setUpdateAt(DateUtil.getUTCTimeByConfigTimeZone()); + // 当前登录用户 + SysUserEntity currentLoginUser = ShiroUtils.getUserEntity(); + assetAccount.setUpdateBy(currentLoginUser.getUserId()); + this.saveOrUpdate(assetAccount); + } +} diff --git a/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoServiceImpl.java index d4232a38..5aa90272 100644 --- a/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/project/service/impl/TopoServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @@ -64,7 +65,7 @@ public class TopoServiceImpl extends ServiceImpl<TopoDao, Topo> implements TopoS if (CollectionUtils.isEmpty(topos)) { return; } - Map<Integer, Object> topoProjectIdAndConfigMap = topos.stream().collect(Collectors.toMap(Topo::getProjectId, Topo::getTopo)); + Map<Integer, Object> topoProjectIdAndConfigMap = topos.stream().collect(Collectors.toMap(Topo::getProjectId, Function.identity())); // module 是批量删除,删除的或许不属于同一个 project Map<Integer, List<Module>> projectIdAndMoudles = modules.stream().collect(Collectors.groupingBy(Module::getProjectId)); diff --git a/nz-admin/src/main/resources/db/V2021.03.15__1.Insert asset_account asset_account_rel table.sql b/nz-admin/src/main/resources/db/V2021.03.15__1.Insert asset_account asset_account_rel table.sql new file mode 100644 index 00000000..c45f5051 --- /dev/null +++ b/nz-admin/src/main/resources/db/V2021.03.15__1.Insert asset_account asset_account_rel table.sql @@ -0,0 +1,44 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for asset_account +-- ---------------------------- +DROP TABLE IF EXISTS `asset_account`; +CREATE TABLE `asset_account` ( + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称', + `protocol` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '1:SSH\r\n\r\n2:TELNET', + `auth_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '1:用户名密码\r\n\r\n2:密钥', + `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '可选值:SSH,TELNET 统一大写', + `password` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'auth_type =1 : 记录登录密码\r\n\r\nauth_type=2 : 记录密钥密码', + `pri_key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, + `update_by` int(10) NOT NULL, + `update_at` datetime(0) NOT NULL, + `user_tip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'telnet协议有效', + `password_tip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'telnet协议有效', + `weight` int(3) NOT NULL COMMENT '值:1-100\r\n\r\n默认:10', + `state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '0:停用\r\n\r\n1:启用', + `seq` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '全局唯一,用于导入撤销\r\n', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; + + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for asset_account_rel +-- ---------------------------- +DROP TABLE IF EXISTS `asset_account_rel`; +CREATE TABLE `asset_account_rel` ( + `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', + `asset_id` int(10) NOT NULL COMMENT '资产id', + `account_id` int(10) NOT NULL COMMENT '账号id', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `asset_account_unique`(`asset_id`, `account_id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file diff --git a/nz-admin/src/main/resources/mapper/asset/AssetAccountDao.xml b/nz-admin/src/main/resources/mapper/asset/AssetAccountDao.xml new file mode 100644 index 00000000..4a661fbb --- /dev/null +++ b/nz-admin/src/main/resources/mapper/asset/AssetAccountDao.xml @@ -0,0 +1,85 @@ +<?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.nis.modules.asset.dao.AssetAccountDao"> + <resultMap type="com.nis.modules.asset.entity.AssetAccount" id="assetAccount"> + <result property="id" column="id"/> + <result property="name" column="name"/> + <result property="protocol" column="protocol"/> + <result property="authType" column="auth_type"/> + <result property="username" column="username"/> + <result property="updateBy" column="update_by"/> + <result property="updateById" column="update_by"/> + <result property="updateByName" column="update_by_name"/> + <result property="updateAt" column="update_at"/> + <result property="userTip" column="user_tip"/> + <result property="passwordTip" column="password_tip"/> + <result property="weight" column="weight"/> + <result property="state" column="state"/> + + </resultMap> + + <select id="selectAssetAccounts" resultMap="assetAccount"> + select aa.id, + aa.name, + aa.protocol, + aa.auth_type, + aa.username, + aa.update_by, + su.username as update_by_name, + aa.update_at, + aa.user_tip, + aa.password_tip, + aa.weight, + aa.state + from asset_account aa left join sys_user su on aa.update_by = su.user_id + where 1=1 + <if test="params.id!=null and params.id!=''"> + and aa.id = #{params.id} + </if> + <if test="params.protocol!=null and params.protocol!=''"> + and aa.protocol = #{params.protocol} + </if> + <if test="params.state!=null and params.state!=''"> + and aa.state = #{params.state} + </if> + <if test="params.name!=null and params.name!=''"> + and aa.name like CONCAT('%', #{params.name}, '%') + </if> + </select> + + <select id="selectAssetAccountById" resultMap="assetAccount"> + select aa.id, + aa.name, + aa.protocol, + aa.auth_type, + aa.username, + aa.update_by, + su.username as update_by_name, + aa.update_at, + aa.user_tip, + aa.password_tip, + aa.weight, + aa.state + from asset_account aa left join sys_user su on aa.update_by = su.user_id + where 1=1 and aa.id =#{id} + </select> + + + <select id="selectAssetAccountsByAssetId" resultMap="assetAccount"> + select aa.id, + aa.name, + aa.protocol, + aa.auth_type, + aa.username, + aa.update_by, + su.username as update_by_name, + aa.update_at, + aa.user_tip, + aa.password_tip, + aa.weight, + aa.state + from asset_account aa left join sys_user su on aa.update_by = su.user_id left join asset_account_rel aar on aa.id = aar.account_id + where aar.asset_id = #{assetId} + </select> +</mapper>
\ No newline at end of file diff --git a/nz-common/src/main/java/com/nis/common/utils/RCode.java b/nz-common/src/main/java/com/nis/common/utils/RCode.java index 9d39d072..db36e1dd 100644 --- a/nz-common/src/main/java/com/nis/common/utils/RCode.java +++ b/nz-common/src/main/java/com/nis/common/utils/RCode.java @@ -273,6 +273,18 @@ public enum RCode { ACCOUNT_SNMP_AUTHPROTOCOL_INVALIDE(334019,"Auth protocol must be MD5 or SHA"), ACCOUNT_SNMP_PRIVPROTOCOL_INVALIDE(334020,"Priv protocol must be DES or AES"), + ASSET_ACCOUNT_ID_ISNULL(331021,"asset account id can not be null"), + ASSET_ACCOUNT_NAME_ISNULL(331022,"asset account name can not be null"), + ASSET_ACCOUNT_PROTOCOL_ISNULL(331023,"asset account protocol can not be null"), + ASSET_ACCOUNT_AUTHTYPE_ISNULL(331024,"asset account auth type can not be null"), + ASSET_ACCOUNT_USERNAME_ISNULL(331025,"asset account username can not be null"), + ASSET_ACCOUNT_PASSWORD_ISNULL(331026,"asset account password can not be null"), + ASSET_ACCOUNT_PRIKEY_ISNULL(331027,"asset account prikey can not be null"), + ASSET_ACCOUNT_USERTIP_ISNULL(331028,"asset account user tip can not be null when auth type is telnet"), + ASSET_ACCOUNT_PASSWORDTIP_ISNULL(331029,"asset account password tip can not be null when auth type is telnet"), + ASSET_ACCOUNT_WEIGHT_ISNULL(331030,"asset account id can not be null"), + ASSET_ACCOUNT_STATE_ISNULL(331031,"asset account id can not be null"), + STATECONF_NAME_ISNULL(341000,"Asset state conf name is null"), STATECONF_PING_ISNULL(341001,"Asset state conf ping is null"), STATECONF_MONITOR_ISNULL(341002,"Asset state conf monitor is null"), diff --git a/nz-common/src/main/java/com/nis/common/utils/TypeEnum.java b/nz-common/src/main/java/com/nis/common/utils/TypeEnum.java index dd488247..916c56be 100644 --- a/nz-common/src/main/java/com/nis/common/utils/TypeEnum.java +++ b/nz-common/src/main/java/com/nis/common/utils/TypeEnum.java @@ -6,6 +6,8 @@ package com.nis.common.utils; public enum TypeEnum { //类型type ASSET("asset"), + ASSETACCOUNT("asset account"), + ASSETACCOUNTREL("asset account rel"), ENDPOINT("endpoint"), PROJECT("project"), MODULE("module"), |
