From 47d3c331a04ce44b756973217f85a4a04ea45be0 Mon Sep 17 00:00:00 2001 From: luxin Date: Fri, 1 Sep 2017 14:47:07 +0800 Subject: Add NS mysql table Add NS mysql table and mybatis mapper file Change-Id: Ieea386e4898f2a20a5644dfcc8bea545bd98505c Issue-Id:VFC-216 Signed-off-by: luxin --- .../resmanagement/service/entity/NsEntity.java | 139 ++++++++++++++++++++ .../service/mapper/NsEntityMapper.java | 39 ++++++ .../resources/mybatis/mysql/NsEntityMapper.xml | 143 +++++++++++++++++++++ 3 files changed, 321 insertions(+) create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java create mode 100644 ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java create mode 100644 ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml (limited to 'ResmanagementService/service/src') diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java new file mode 100644 index 0000000..a413134 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/entity/NsEntity.java @@ -0,0 +1,139 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + *
+ *

+ *

+ * + * @author + * @version VFC 1.0 Sep 1, 2017 + */ +public class NsEntity implements Serializable { + + /** */ + private String id; + + /** */ + private String name; + + /** */ + private String nsdId; + + /** */ + private String description; + + /** */ + private String status; + + /** */ + private String cteateTime; + + /** */ + private String lastUpdate; + + private static final long serialVersionUID = 1L; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNsdId() { + return nsdId; + } + + public void setNsdId(String nsdId) { + this.nsdId = nsdId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCteateTime() { + return cteateTime; + } + + public void setCteateTime(String cteateTime) { + this.cteateTime = cteateTime; + } + + public String getLastUpdate() { + return lastUpdate; + } + + public void setLastUpdate(String lastUpdate) { + this.lastUpdate = lastUpdate; + } + + public static NsEntity toEntity(JSONObject jsonObject) { + NsEntity nsEntity = new NsEntity(); + nsEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + nsEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + nsEntity.setNsdId(JsonUtil.getJsonFieldStr(jsonObject, "nsdId")); + nsEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); + nsEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + nsEntity.setCteateTime(JsonUtil.getJsonFieldStr(jsonObject, "cteateTime")); + nsEntity.setLastUpdate(JsonUtil.getJsonFieldStr(jsonObject, "lastUpdate")); + return nsEntity; + } + + @Override + public String toString() { + JSONObject nsResJson = new JSONObject(); + nsResJson.put("id", StringUtils.trimToEmpty(this.getId())); + nsResJson.put("name", StringUtils.trimToEmpty(this.getName())); + nsResJson.put("nsdId", StringUtils.trimToEmpty(this.getNsdId())); + nsResJson.put("description", StringUtils.trimToEmpty(this.getDescription())); + nsResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + nsResJson.put("cteateTime", StringUtils.trimToEmpty(this.getCteateTime())); + nsResJson.put("lastUpdate", StringUtils.trimToEmpty(this.getLastUpdate())); + return nsResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java new file mode 100644 index 0000000..69db361 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/mapper/NsEntityMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.onap.vfc.nfvo.resmanagement.service.entity.NsEntity; + +public interface NsEntityMapper { + + int deleteByPrimaryKey(String id); + + int insert(NsEntity record); + + int insertSelective(NsEntity record); + + NsEntity selectByPrimaryKey(String id); + + List getAllNs(Map condition); + + int updateByPrimaryKeySelective(NsEntity record); + + int updateByPrimaryKey(NsEntity record); +} diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml new file mode 100644 index 0000000..a792694 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/NsEntityMapper.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + ID, NAME, NSD_ID, DESCRIPTION, STATUS, CTEATE_TIME, LAST_UPDATE + + + + + delete from ns + where ID = #{id,jdbcType=VARCHAR} + + + insert into ns (ID, NAME, NSD_ID, + DESCRIPTION, STATUS, CTEATE_TIME, + LAST_UPDATE) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{nsdId,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{cteateTime,jdbcType=VARCHAR}, + #{lastUpdate,jdbcType=VARCHAR}) + + + insert into ns + + + ID, + + + NAME, + + + NSD_ID, + + + DESCRIPTION, + + + STATUS, + + + CTEATE_TIME, + + + LAST_UPDATE, + + + + + #{id,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{nsdId,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{status,jdbcType=VARCHAR}, + + + #{cteateTime,jdbcType=VARCHAR}, + + + #{lastUpdate,jdbcType=VARCHAR}, + + + + + update ns + + + NAME = #{name,jdbcType=VARCHAR}, + + + NSD_ID = #{nsdId,jdbcType=VARCHAR}, + + + DESCRIPTION = #{description,jdbcType=VARCHAR}, + + + STATUS = #{status,jdbcType=VARCHAR}, + + + CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR}, + + + LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR}, + + + where ID = #{id,jdbcType=VARCHAR} + + + update ns + set NAME = #{name,jdbcType=VARCHAR}, + NSD_ID = #{nsdId,jdbcType=VARCHAR}, + DESCRIPTION = #{description,jdbcType=VARCHAR}, + STATUS = #{status,jdbcType=VARCHAR}, + CTEATE_TIME = #{cteateTime,jdbcType=VARCHAR}, + LAST_UPDATE = #{lastUpdate,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + + \ No newline at end of file -- cgit 1.2.3-korg