OCT
REM: 1. 更新配置文件 2. 增加处置设备表 3. 增加处置设备能力表 4. 增加处置设备能力单元测试
This commit is contained in:
parent
33e439a9b7
commit
c6cac8c320
|
@ -62,7 +62,7 @@ dispose.request-timeout-second=5
|
|||
|
||||
# 迪普设备配置
|
||||
# 发送超时时间(ms)
|
||||
#dptech.soap-conn-timeout-second=60
|
||||
dptech.soap-conn-timeout-second=60
|
||||
# 接收超时时间(ms)
|
||||
dptech.soap-recv-timeout-second=60
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.dispose.common;
|
||||
|
||||
/**
|
||||
* The enum Dispose capacity type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DisposeCapacityType {
|
||||
/**
|
||||
* The Cleanup.
|
||||
*/
|
||||
CLEANUP(0, "清洗能力"),
|
||||
/**
|
||||
* The Hidepend.
|
||||
*/
|
||||
HIDEPEND(1, "高防能力"),
|
||||
/**
|
||||
* The Blackhool.
|
||||
*/
|
||||
BLACKHOOL(2, "黑洞能力"),
|
||||
/**
|
||||
* The Detecive.
|
||||
*/
|
||||
DETECIVE(3, "检测能力"),
|
||||
|
||||
/**
|
||||
* Blocking dispose capacity type.
|
||||
*/
|
||||
BLOCKING(4, "封堵");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dispose capacity type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DisposeCapacityType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets code.
|
||||
*
|
||||
* @return the code
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets readme.
|
||||
*
|
||||
* @return the readme
|
||||
*/
|
||||
public String getReadme() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.dispose.common;
|
||||
|
||||
/**
|
||||
* The enum Dispose object type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum DisposeObjectType {
|
||||
/**
|
||||
* The Ip.
|
||||
*/
|
||||
IP(1, "IP地址"),
|
||||
/**
|
||||
* The Domain.
|
||||
*/
|
||||
DOMAIN(1 << 1, "域名"),
|
||||
|
||||
/**
|
||||
* The Url.
|
||||
*/
|
||||
URL(1 << 2, "URL");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dispose object type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
DisposeObjectType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets code.
|
||||
*
|
||||
* @return the code
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets readme.
|
||||
*
|
||||
* @return the readme
|
||||
*/
|
||||
public String getReadme() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.dispose.common;
|
||||
|
||||
/**
|
||||
* The enum Ip addr type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum IpAddrType {
|
||||
/**
|
||||
* Ip v 4 ip addr type.
|
||||
*/
|
||||
IPV4(1, "禁用"),
|
||||
/**
|
||||
* Ip v 6 ip addr type.
|
||||
*/
|
||||
IPV6(1 << 1, "禁用");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Ip addr type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
IpAddrType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets code.
|
||||
*
|
||||
* @return the code
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets readme.
|
||||
*
|
||||
* @return the readme
|
||||
*/
|
||||
public String getReadme() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ package com.dispose.common;
|
|||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum UserAccountStatus {
|
||||
public enum ObjectStatus {
|
||||
/**
|
||||
* Normal user account status.
|
||||
*/
|
||||
|
@ -38,7 +38,7 @@ public enum UserAccountStatus {
|
|||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
UserAccountStatus(int code, String readme) {
|
||||
ObjectStatus(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
}
|
|
@ -18,5 +18,5 @@ public class AuthConfigure {
|
|||
/**
|
||||
* The Token timout value.
|
||||
*/
|
||||
private String tokenTimoutMinute;
|
||||
private String tokenTimeoutMinute;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ public class AuthController {
|
|||
@Validated(ValidGroups.LoginReqValid.class)
|
||||
@RequestBody ProtocolReqDTO<LoginReq> mr)
|
||||
throws NoSuchAlgorithmException {
|
||||
|
||||
// 登录
|
||||
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(mr.getMsgContent().getUserName(),
|
||||
mr.getMsgContent().getPassword());
|
||||
|
@ -97,8 +96,7 @@ public class AuthController {
|
|||
@ApiOperation("注销")
|
||||
public ProtocolRespDTO<? extends BaseRespStatus> userLogout(@Validated(ValidGroups.LogoutReqValid.class)
|
||||
@RequestBody ProtocolReqDTO<LoginReq> mr,
|
||||
@RequestHeader HttpHeaders headers) {
|
||||
// 注销用户登录
|
||||
@RequestHeader HttpHeaders headers) { // 注销用户登录
|
||||
ErrorCode err = userAccountService.logoutService(mr.getMsgContent().getUserName(),
|
||||
mr.getAuthToken(headers));
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.dispose.mapper;
|
||||
|
||||
import com.dispose.pojo.entity.DisposeCapacity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import tk.mybatis.mapper.common.IdsMapper;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
import tk.mybatis.mapper.common.MySqlMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The interface Dispose capacity mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeCapacityMapper extends Mapper<DisposeCapacity>,
|
||||
IdsMapper<DisposeCapacity>, MySqlMapper<DisposeCapacity> {
|
||||
|
||||
/**
|
||||
* Add new dispose capacity int.
|
||||
*
|
||||
* @param devCaps the dev caps
|
||||
* @return the int
|
||||
*/
|
||||
int addNewDisposeCapacity(@Param("devCaps") List<DisposeCapacity> devCaps);
|
||||
|
||||
/**
|
||||
* Del dispose capacity int.
|
||||
*
|
||||
* @param deviceId the device id
|
||||
* @param capacityType the capacity type
|
||||
* @return the int
|
||||
*/
|
||||
int delDisposeCapacity(@Param("deviceId") Long deviceId,
|
||||
@Param("capacityType") Integer capacityType);
|
||||
|
||||
/**
|
||||
* Del device dispose capacity int.
|
||||
*
|
||||
* @param deviceId the device id
|
||||
* @return the int
|
||||
*/
|
||||
int delDeviceDisposeCapacity(@Param("deviceId") Long deviceId);
|
||||
|
||||
/**
|
||||
* Gets device dispose capacity.
|
||||
*
|
||||
* @param deviceId the device id
|
||||
* @return the device dispose capacity
|
||||
*/
|
||||
List<DisposeCapacity> getDeviceDisposeCapacity(@Param("deviceId") Long deviceId);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.dispose.mapper;
|
||||
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import tk.mybatis.mapper.common.IdsMapper;
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
import tk.mybatis.mapper.common.MySqlMapper;
|
||||
|
||||
/**
|
||||
* The interface Dispose device mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeDeviceMapper extends Mapper<DisposeDevice>,
|
||||
IdsMapper<DisposeDevice>, MySqlMapper<DisposeDevice> {
|
||||
|
||||
/**
|
||||
* Add new dispose device int.
|
||||
*
|
||||
* @param dev the dev
|
||||
* @return the int
|
||||
*/
|
||||
int addNewDisposeDevice(DisposeDevice dev);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.dispose.pojo.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* The type Dispose capacity.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Table(name = "dispose_capacity")
|
||||
@NameStyle(Style.normal)
|
||||
public class DisposeCapacity {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Device id.
|
||||
*/
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* The Capacity type.
|
||||
*/
|
||||
private Integer capacityType;
|
||||
|
||||
/**
|
||||
* The Object type.
|
||||
*/
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* The Ip type.
|
||||
*/
|
||||
private Integer ipType;
|
||||
|
||||
/**
|
||||
* The Protect ip.
|
||||
*/
|
||||
private String protectIp;
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.dispose.pojo.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Dispose device.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Table(name = "dispose_device")
|
||||
@NameStyle(Style.normal)
|
||||
public class DisposeDevice implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Ip addr.
|
||||
*/
|
||||
private String ipAddr;
|
||||
|
||||
/**
|
||||
* The Device type.
|
||||
*/
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* The Area code.
|
||||
*/
|
||||
private Integer areaCode;
|
||||
|
||||
/**
|
||||
* The Name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The Manufacturer.
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* The Model.
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* The Version.
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* The User name.
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* The Password.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* The Url path.
|
||||
*/
|
||||
private String urlPath;
|
||||
|
||||
/**
|
||||
* The Url type.
|
||||
*/
|
||||
private Integer urlType;
|
||||
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private String readme;
|
||||
|
||||
/**
|
||||
* The Status.
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* The Dev capacity.
|
||||
*/
|
||||
@Transient
|
||||
private List<DisposeCapacity> devCapacity;
|
||||
|
||||
/**
|
||||
* The Dev info.
|
||||
*/
|
||||
//@Transient
|
||||
//private DeviceInfo devInfo;
|
||||
|
||||
/**
|
||||
* The Link status.
|
||||
*/
|
||||
//@Transient
|
||||
//private Integer linkStatus;
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.dispose.service.impl;
|
|||
|
||||
import com.dispose.common.AuthConfigValue;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.UserAccountStatus;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.config.DisposeConfigure;
|
||||
import com.dispose.manager.UserAccountManager;
|
||||
import com.dispose.pojo.entity.UserAccount;
|
||||
|
@ -71,7 +71,7 @@ public class UserAccountServiceImpl implements UserAccountService {
|
|||
}
|
||||
|
||||
// 用户是否被锁定
|
||||
if (loginUser.getStatus() == UserAccountStatus.LOCKED.getCode()) {
|
||||
if (loginUser.getStatus() == ObjectStatus.LOCKED.getCode()) {
|
||||
log.error("User {} is locked", username);
|
||||
return MulReturnType.<ErrorCode, String>builder().firstParam(ErrorCode.ERR_USERLOCK).build();
|
||||
}
|
||||
|
|
|
@ -44,32 +44,35 @@ public class SystemInitial implements CommandLineRunner {
|
|||
private void loadConfigure() {
|
||||
|
||||
try {
|
||||
AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Long.parseLong(authConfigure.getTokenTimoutMinute()) * 60 * 1000;
|
||||
AuthConfigValue.TOKEN_EXPIRED_TIME_MS = Long.parseLong(authConfigure.getTokenTimeoutMinute()) * 60 * 1000;
|
||||
} catch (Exception ex) {
|
||||
log.error("load TOKEN_EXPIRED_TIME_MS configure error: {}", ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND = Integer.parseInt(dpTechConfigure.getSoapConnTimeoutSecond());
|
||||
} catch(Exception ex) {
|
||||
DpTechConfigValue.SOAP_CONNECT_TIMEOUT_SECOND =
|
||||
Integer.parseInt(dpTechConfigure.getSoapConnTimeoutSecond());
|
||||
} catch (Exception ex) {
|
||||
log.error("load SOAP_CONNECT_TIMEOUT_SECOND configure error: {}", ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND = Integer.parseInt(dpTechConfigure.getSoapRecvTimeoutSecond());
|
||||
} catch(Exception ex) {
|
||||
DpTechConfigValue.SOAP_RECEIVE_TIMEOUT_SECOND =
|
||||
Integer.parseInt(dpTechConfigure.getSoapRecvTimeoutSecond());
|
||||
} catch (Exception ex) {
|
||||
log.error("load SOAP_RECEIVE_TIMEOUT_SECOND configure error: {}", ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
DisposeConfigValue.REQUEST_TIMEOUT_MS = Integer.parseInt(disposeConfigure.getRequestTimeoutSecond()) * 1000;
|
||||
} catch(Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
log.error("load REQUEST_TIMEOUT_MS configure error: {}", ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT = Boolean.parseBoolean(disposeConfigure.getCheckProtocolTimeout());
|
||||
} catch(Exception ex) {
|
||||
DisposeConfigValue.CHECK_PROTO_REQUEST_TIMEOUT =
|
||||
Boolean.parseBoolean(disposeConfigure.getCheckProtocolTimeout());
|
||||
} catch (Exception ex) {
|
||||
log.error("load CHECK_PROTO_REQUEST_TIMEOUT configure error: {}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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.dispose.mapper.DisposeCapacityMapper">
|
||||
<insert id="addNewDisposeCapacity" useGeneratedKeys="true" keyProperty="id"
|
||||
parameterType="com.dispose.pojo.entity.DisposeCapacity">
|
||||
INSERT IGNORE INTO dispose_capacity(deviceId, capacityType, objectType, ipType, protectIp)
|
||||
VALUES
|
||||
<foreach collection="devCaps" item="cap" separator=",">
|
||||
(#{cap.deviceId}, #{cap.capacityType}, #{cap.objectType}, #{cap.ipType}, #{cap.protectIp})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="delDisposeCapacity">
|
||||
DELETE
|
||||
FROM dispose_capacity
|
||||
WHERE dispose_capacity.deviceId = #{deviceId}
|
||||
AND dispose_capacity.capacityType = #{capacityType}
|
||||
</delete>
|
||||
|
||||
<delete id="delDeviceDisposeCapacity">
|
||||
DELETE
|
||||
FROM dispose_capacity
|
||||
WHERE dispose_capacity.deviceId = #{deviceId}
|
||||
</delete>
|
||||
|
||||
<select id="getDeviceDisposeCapacity" resultType="com.dispose.pojo.entity.DisposeCapacity">
|
||||
SELECT *
|
||||
FROM dispose_capacity
|
||||
WHERE dispose_capacity.deviceId = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
<?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.dispose.mapper.DisposeDeviceMapper">
|
||||
<insert id="addNewDisposeDevice" useGeneratedKeys="true" keyProperty="id"
|
||||
parameterType="com.dispose.pojo.entity.DisposeDevice">
|
||||
INSERT IGNORE INTO dispose_device(ipAddr, deviceType,
|
||||
areaCode, deviceName, manufacturer,
|
||||
model, version, userName, password, urlPath, urlType, readme, status)
|
||||
VALUES (#{ipAddr}, #{deviceType},
|
||||
#{areaCode}, #{deviceName}, #{manufacturer},
|
||||
#{model}, #{version}, #{userName}, #{password}, #{urlPath}, #{urlType}, #{readme},
|
||||
${@com.dispose.common.ObjectStatus@NORMAL.getCode()})
|
||||
</insert>
|
||||
</mapper>
|
|
@ -4,7 +4,7 @@
|
|||
<!-- mapper xml文件中只编写复杂逻辑的SQL SQL单独拿出来写,与代码解耦,SQL的熟练编写是每个研发必备的技能 -->
|
||||
<select id="addUserAccount" resultType="com.dispose.pojo.entity.UserAccount">
|
||||
INSERT INTO user_account(username, password, operators, status)
|
||||
SELECT #{username}, #{password}, #{operators}, ${@com.dispose.common.UserAccountStatus@NORMAL.getCode()}
|
||||
SELECT #{username}, #{password}, #{operators}, ${@com.dispose.common.ObjectStatus@NORMAL.getCode()}
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS(
|
||||
SELECT username
|
||||
|
@ -73,7 +73,7 @@
|
|||
<update id="delUserAccount">
|
||||
UPDATE
|
||||
user_account
|
||||
SET status = ${@com.dispose.common.UserAccountStatus@DELETED.getCode()},
|
||||
SET status = ${@com.dispose.common.ObjectStatus@DELETED.getCode()},
|
||||
operators = #{operators},
|
||||
lockTime = CURRENT_TIMESTAMP
|
||||
WHERE username = #{username, jdbcType=VARCHAR}
|
||||
|
@ -82,7 +82,7 @@
|
|||
<update id="disableUserAccount">
|
||||
UPDATE
|
||||
user_account
|
||||
SET status = ${@com.dispose.common.UserAccountStatus@DISABLED.getCode()},
|
||||
SET status = ${@com.dispose.common.ObjectStatus@DISABLED.getCode()},
|
||||
operators = #{operators},
|
||||
lockTime = CURRENT_TIMESTAMP
|
||||
WHERE username = #{username, jdbcType=VARCHAR}
|
||||
|
@ -91,7 +91,7 @@
|
|||
<update id="lockUserAccount">
|
||||
UPDATE
|
||||
user_account
|
||||
SET status = ${@com.dispose.common.UserAccountStatus@LOCKED.getCode()},
|
||||
SET status = ${@com.dispose.common.ObjectStatus@LOCKED.getCode()},
|
||||
lockTime = CURRENT_TIMESTAMP
|
||||
WHERE username = #{username, jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
@ -99,7 +99,7 @@
|
|||
<update id="unlockUserAccount">
|
||||
UPDATE
|
||||
user_account
|
||||
SET status = ${@com.dispose.common.UserAccountStatus@NORMAL.getCode()},
|
||||
SET status = ${@com.dispose.common.ObjectStatus@NORMAL.getCode()},
|
||||
lockTime = 0
|
||||
WHERE username = #{username, jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.dispose.test.manager;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.UserAccountStatus;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.manager.UserAccountManager;
|
||||
import com.dispose.mapper.UserAccountMapper;
|
||||
import com.dispose.pojo.entity.UserAccount;
|
||||
|
@ -164,25 +164,25 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
|||
UserAccount user = userAccountMapper.getUserByName(v.getUsername());
|
||||
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long) user.getStatus(), UserAccountStatus.LOCKED.getCode());
|
||||
Assert.assertEquals((long) user.getStatus(), ObjectStatus.LOCKED.getCode());
|
||||
|
||||
userAccountManager.unlockUserAccount(v.getUsername());
|
||||
user = userAccountMapper.getUserByName(v.getUsername());
|
||||
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long) user.getStatus(), UserAccountStatus.NORMAL.getCode());
|
||||
Assert.assertEquals((long) user.getStatus(), ObjectStatus.NORMAL.getCode());
|
||||
|
||||
userAccountManager.disableUserAccount(v.getUsername(), "admin");
|
||||
user = userAccountMapper.getUserByName(v.getUsername());
|
||||
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long) user.getStatus(), UserAccountStatus.DISABLED.getCode());
|
||||
Assert.assertEquals((long) user.getStatus(), ObjectStatus.DISABLED.getCode());
|
||||
|
||||
userAccountManager.deleteUserAccount(v.getUsername(), "admin");
|
||||
user = userAccountMapper.getUserByName(v.getUsername());
|
||||
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long) user.getStatus(), UserAccountStatus.DELETED.getCode());
|
||||
Assert.assertEquals((long) user.getStatus(), ObjectStatus.DELETED.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
package com.dispose.test.mapper;
|
||||
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.DisposeObjectType;
|
||||
import com.dispose.common.IpAddrType;
|
||||
import com.dispose.mapper.DisposeCapacityMapper;
|
||||
import com.dispose.pojo.entity.DisposeCapacity;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Dispose capacity mapper test.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class DisposeCapacityMapperTest {
|
||||
|
||||
/**
|
||||
* The Dispose capacity mapper.
|
||||
*/
|
||||
@Resource
|
||||
DisposeCapacityMapper disposeCapacityMapper;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* A 1 add new dispose capacity.
|
||||
*
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_addNewDisposeCapacity() throws JsonProcessingException {
|
||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.CLEANUP.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.BLOCKING.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
int items = disposeCapacityMapper.addNewDisposeCapacity(newCapList);
|
||||
|
||||
Assert.assertEquals(items, newCapList.size());
|
||||
|
||||
List<DisposeCapacity> capList = disposeCapacityMapper.selectAll();
|
||||
|
||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 2 del dispose capacity.
|
||||
*
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
*/
|
||||
@Test
|
||||
public void a2_delDisposeCapacity() throws JsonProcessingException {
|
||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.CLEANUP.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.BLOCKING.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
int items = disposeCapacityMapper.addNewDisposeCapacity(newCapList);
|
||||
|
||||
Assert.assertEquals(items, newCapList.size());
|
||||
|
||||
List<DisposeCapacity> capList = disposeCapacityMapper.selectAll();
|
||||
|
||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
|
||||
items = disposeCapacityMapper.delDisposeCapacity(capList.get(0).getDeviceId(),
|
||||
capList.get(0).getCapacityType());
|
||||
|
||||
Assert.assertEquals(items, 1);
|
||||
|
||||
capList = disposeCapacityMapper.selectAll();
|
||||
|
||||
Assert.assertEquals(capList.size(), 1);
|
||||
|
||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void a3_delDeviceDisposeCapacity() {
|
||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.CLEANUP.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.BLOCKING.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
Assert.assertEquals(disposeCapacityMapper.addNewDisposeCapacity(newCapList), newCapList.size());
|
||||
|
||||
Assert.assertEquals(disposeCapacityMapper.delDeviceDisposeCapacity(newCapList.get(0).getDeviceId()),
|
||||
newCapList.size());
|
||||
|
||||
Assert.assertEquals(0, disposeCapacityMapper.selectAll().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void b1_getDeviceDisposeCapacity() throws JsonProcessingException {
|
||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.CLEANUP.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
newCapList.add(DisposeCapacity.builder()
|
||||
.deviceId(1L)
|
||||
.ipType(IpAddrType.IPV4.getCode() | IpAddrType.IPV6.getCode())
|
||||
.capacityType(DisposeCapacityType.BLOCKING.getCode())
|
||||
.objectType(DisposeObjectType.IP.getCode())
|
||||
.protectIp("")
|
||||
.build());
|
||||
|
||||
Assert.assertEquals(disposeCapacityMapper.addNewDisposeCapacity(newCapList), newCapList.size());
|
||||
|
||||
List<DisposeCapacity> capList = disposeCapacityMapper.getDeviceDisposeCapacity(newCapList.get(0).getDeviceId());
|
||||
|
||||
Assert.assertEquals(capList.size(), newCapList.size());
|
||||
|
||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.dispose.test.mapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* The type Dispose device mapper.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class DisposeDeviceMapper {
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.dispose.test.mapper;
|
||||
|
||||
import com.dispose.common.Helper;
|
||||
import com.dispose.common.UserAccountStatus;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.mapper.UserAccountMapper;
|
||||
import com.dispose.pojo.entity.UserAccount;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
@ -70,12 +70,12 @@ public class UserAccountMapperTest {
|
|||
userAccountMapper.lockUserAccount("admin");
|
||||
|
||||
UserAccount user = userAccountMapper.getUserByName("admin");
|
||||
Assert.assertEquals(new Long(user.getStatus()), new Long(UserAccountStatus.LOCKED.getCode()));
|
||||
Assert.assertEquals(new Long(user.getStatus()), new Long(ObjectStatus.LOCKED.getCode()));
|
||||
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
||||
|
||||
userAccountMapper.unlockUserAccount("admin");
|
||||
user = userAccountMapper.getUserByName("admin");
|
||||
Assert.assertEquals(new Long(user.getStatus()), new Long(UserAccountStatus.NORMAL.getCode()));
|
||||
Assert.assertEquals(new Long(user.getStatus()), new Long(ObjectStatus.NORMAL.getCode()));
|
||||
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class UserAccountMapperTest {
|
|||
userAccountMapper.delUserAccount(username, "admin");
|
||||
UserAccount user = userAccountMapper.getUserByName(username);
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long)user.getStatus(), UserAccountStatus.DELETED.getCode());
|
||||
Assert.assertEquals((long)user.getStatus(), ObjectStatus.DELETED.getCode());
|
||||
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class UserAccountMapperTest {
|
|||
userAccountMapper.disableUserAccount(username, "admin");
|
||||
UserAccount user = userAccountMapper.getUserByName(username);
|
||||
Assert.assertNotNull(user);
|
||||
Assert.assertEquals((long)user.getStatus(), UserAccountStatus.DISABLED.getCode());
|
||||
Assert.assertEquals((long)user.getStatus(), ObjectStatus.DISABLED.getCode());
|
||||
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue