1  实例明细url显示 2  增加了logo图片可以编辑

1  实例明细url显示

是在iop中写死的配置

2  增加了logo图片可以编辑

仿照 admin里  服务工厂-服务定义中的内容

(1)在edit.html中增加logo图片字样及调用选择图片,以及logo.html

    <div class="form-group form-required">
<label class="control-label col-sm-3">logo图片:</label> <div class="col-sm-7">
<input type="text" class="form-control" name="logo_url" value="{{serviceDef.logo_url}}" readonly
style="cursor:pointer;">
</div>
</div>

(2)在detail.js中增加          self.logoChoose($dialog); 以及logoChoose函数(在group.js中静姐写过)

3 前端和后端密钥支持删除

 (1)前端在secretKey.js中添加:首先增加按钮,写deleteSecretKey函数(前后端密钥一样)

(2)self.ajax.delete("/dev/v1.0/secretKey-list/delete/"+id,function(err,data)  通过这个借口,链接到后台 cloud-api-service中。

controller层:

dao层:修改,ApiClientDefineDao,,增加了ApiClientDefineEntityDao.java   ,增加了getListByClientId

/**
*
*/
package com.inspur.cloud.api.dao; import com.inspur.cloud.api.entity.ApiClientDefine;
import com.inspur.cloud.api.entity.ApiClientDefineEntity;
import com.inspur.cloud.api.entity.ApiServiceEntity;
import com.inspur.cloud.resource.ResourceRelationUtils;
import org.springframework.util.StringUtils;
import org.springside.modules.orm.hibernate.HibernateDao; import java.util.Date; /**
*
* @author cww<br>
* @version 1.0
* 2015-6-3 10:52:49<br>
*/
public class ApiClientDefineEntityDao<T extends ApiClientDefine> extends HibernateDao<T, String> { /**
* The t parameter must be a Resource object.
* <p></p>
*/
public void save(T t) {
this.save(t, StringUtils.isEmpty(t.getId()));
} /**
* The t parameter must be a Resource object.
* <p></p>
*/
public void save(T t, boolean isCreate) {
//create a resource Date time = new Date();
t.setUpdatedAt(time);
if(isCreate) {
if(t.getCreatedAt() == null) {
t.setCreatedAt(time);
}
t.setIsDeleted(Boolean.FALSE);
}
super.save(t);
} // private void setProperty() public void delete(String id) {
//check the resource has referenced by any other resource
ResourceRelationUtils.checkResourceDelete(id);
T t = this.get(id);
Date time = new Date();
t.setUpdatedAt(time);
t.setDeletedAt(time);
t.setIsDeleted(Boolean.TRUE);
this.save(t);
} /* (non-Javadoc)
* @see org.springside.modules.orm.hibernate.SimpleHibernateDao#delete(java.lang.Object)
*/
@Override
public void delete(ApiClientDefine entity) {
this.delete(entity.getId());
}
}

 entiyt 层:ApiClientDefine和ApiClientDefineEntity ,仿照静姐delete,增加了ApiClientDefineEntity(extends IdEntity)

package com.inspur.cloud.api.entity;

import java.io.Serializable;
import java.util.Date; import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table; import org.hibernate.annotations.Type; import com.fasterxml.jackson.annotation.JsonProperty;
import com.wordnik.swagger.annotations.ApiModelProperty; @Entity
@Table(name="Api_client_define")
public class ApiClientDefine extends ApiClientDefineEntity{
private static final long serialVersionUID = 1L; @JsonProperty("CLIENT_KEY")
private String clientKey;
@JsonProperty("CLIENT_SECRET")
private String clientSecret;
@JsonProperty("DESCRIPTION")
private String description;
@JsonProperty("CLIENT_TYPE")
private String clientType;
@JsonProperty("OWNER")
private String owner;
@JsonProperty("IN_USE")
private Boolean inUse;
@ApiModelProperty(hidden=true)
@JsonProperty("IS_DELETED")
private Boolean isDeleted;
@ApiModelProperty(hidden=true)
@JsonProperty("CREATED_AT")
private Date createdAt;
@ApiModelProperty(hidden=true)
@JsonProperty("UPDATED_AT")
private Date updatedAt;
@ApiModelProperty(hidden=true)
@JsonProperty("DELETED_AT")
private Date deletedAt; public String getClientKey() {
return clientKey;
}
public void setClientKey(String clientKey) {
this.clientKey = clientKey;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getClientType() {
return clientType;
}
public void setClientType(String clientType) {
this.clientType = clientType;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
@Type(type="com.inspur.cloudframework.hibernate.type.CharacterBooleanType")
public Boolean getInUse() {
return inUse;
}
public void setInUse(Boolean inUse) {
this.inUse = inUse;
} public Date getDeletedAt() {
return deletedAt;
} public void setDeletedAt(Date deletedAt) {
this.deletedAt = deletedAt;
} public Date getUpdatedAt() {
return updatedAt;
} public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
} @JsonProperty(value="CREATED_AT")
public Date getCreatedAt() {
return createdAt;
} public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
} @Type(type="com.inspur.cloudframework.hibernate.type.CharacterBooleanType")
public Boolean getIsDeleted() {
return isDeleted;
} public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
} }
/**
*
*/
package com.inspur.cloud.api.entity; import com.fasterxml.jackson.annotation.JsonProperty;
import com.inspur.cloud.entity.IdEntity;
import com.wordnik.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Type; import javax.persistence.MappedSuperclass;
import java.util.Date; /**
*
* @author tang<br>
* @version 1.0
* Aug 27, 2015 4:40:48 PM<br>
*/
@MappedSuperclass public class ApiClientDefineEntity extends IdEntity{ /**
*
*/
private static final long serialVersionUID = 4654645545548886144L; /**
*
*/
//private static final long serialVersionUID = -2312615559760803050L;
/*@ApiModelProperty(hidden=true)
@JsonProperty("IS_DELETED")
private Boolean isDeleted;
@ApiModelProperty(hidden=true)
@JsonProperty("CREATED_AT")
private Date createdAt;
@ApiModelProperty(hidden=true)
@JsonProperty("UPDATED_AT")
private Date updatedAt;
@ApiModelProperty(hidden=true)
@JsonProperty("DELETED_AT")
private Date deletedAt; *//**
* @return the deletedAt
*//*
public Date getDeletedAt() {
return deletedAt;
}
*//**
* @param deletedAt the deletedAt to set
*//*
public void setDeletedAt(Date deletedAt) {
this.deletedAt = deletedAt;
}
*//**
* @return the updatedAt
*//*
public Date getUpdatedAt() {
return updatedAt;
}
*//**
* @param updatedAt the updatedAt to set
*//*
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
*//**
* @return the createdAt
*//*
@JsonProperty(value="created_at")
public Date getCreatedAt() {
return createdAt;
}
*//**
* @param createdAt the createdAt to set
*//*
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
*//**
* @return the isDeleted
*//*
@Type(type="com.inspur.cloudframework.hibernate.type.CharacterBooleanType")
public Boolean getIsDeleted() {
return isDeleted;
}
*//**
* @param isDeleted the isDeleted to set
*//*
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}
*/
}

service层:ApiClientDefineServiceImpl

package com.inspur.cloud.api.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import javax.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page; import com.inspur.cloud.am.dao.UserDao;
import com.inspur.cloud.api.common.GuidGenerator;
import com.inspur.cloud.api.dao.ApiClientDefineDao;
import com.inspur.cloud.api.dao.ApiClientSvcInstRelaDao;
import com.inspur.cloud.api.dao.ApiServiceVersionDao;
import com.inspur.cloud.api.entity.ApiClientDefine;
import com.inspur.cloud.api.entity.ApiClientSvcInstRela;
import com.inspur.cloud.api.entity.ApiSvcVersion;
import com.inspur.cloud.api.utils.RedisCachePrefix; @Service
@Transactional
public class ApiClientDefineServiceImpl implements ApiClientDefineService { @Autowired
private ApiClientDefineDao apiClientDefineDao;
@Autowired
private ApiClientSvcInstRelaDao apiClientSvcInstRelaDao;
@Autowired
private ApiServiceVersionDao apiSvcVersionDao;
@Resource(name="apiRedisTemplate")
private RedisTemplate<String,String> redisTemplate;
@Autowired
private UserDao userDao; //获取当前用户下的所有密钥对(前端密钥)
public Page<ApiClientDefine> getApiClientDefineList(Page<ApiClientDefine> page,String description,String userId){
Map<String,Object> map = new HashMap<String,Object>();
map.put("OWNER", userId);
if(description!=null&&description.trim()!=""){
map.put("DESCRIPTION", description);
}
map.put("IS_DELETED", false);
Page<ApiClientDefine> apiClientDefinePage = apiClientDefineDao.getList(page, map);
return apiClientDefinePage;
}
//编辑
public void editSecretKey(String id,String name){
ApiClientDefine apiClientDefine = apiClientDefineDao.get(id);
apiClientDefine.setDescription(name);
apiClientDefine.setUpdatedAt(new Date());
apiClientDefineDao.save(apiClientDefine);
}
//新增
public void addSecretKey(String userId,String desc,String clientType){
ApiClientDefine api = new ApiClientDefine();
// String id = GuidGenerator.generate();
String clientKey = GuidGenerator.generate();
String clientSecret = GuidGenerator.generate();
// api.setId(id);
api.setClientKey(clientKey);
api.setClientSecret(clientSecret);
api.setClientType(clientType);
api.setDescription(desc);
api.setInUse(Boolean.TRUE);
api.setOwner(userId);
apiClientDefineDao.save(api);
// User user = this.userDao.get(userId);
if("SVC".equals(clientType)){
String redisValue = clientSecret+":"+api.getId();
// String redisValue = clientSecret+":"+id+":"+userId+":"+user.getLoginName();
RedisSerializer stringSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);
redisTemplate.setValueSerializer(stringSerializer);
redisTemplate.opsForValue().set(RedisCachePrefix.getBckKey(clientKey), redisValue);
}
}
//停用启用
public void stopSecretKey(String id){
ApiClientDefine apiClientDefine = apiClientDefineDao.findById(id);
Boolean inUse = apiClientDefine.getInUse();
if(inUse != null){
if(inUse.equals(Boolean.TRUE)){
apiClientDefine.setInUse(Boolean.FALSE);
}else if(inUse.equals(Boolean.FALSE)){
apiClientDefine.setInUse(Boolean.TRUE);
}
}
apiClientDefineDao.save(apiClientDefine);
} // 删除
public void deleteSecretKey(String id) {
ApiClientDefine apiClientDefine = apiClientDefineDao.findById(id);
Boolean inUse = apiClientDefine.getInUse();
if (inUse != null) {
if (inUse.equals(Boolean.TRUE)) {
apiClientDefine.setInUse(Boolean.FALSE);
} else if (inUse.equals(Boolean.FALSE)) {
apiClientDefine.setInUse(Boolean.TRUE);
}
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("CLIENT_ID", id);
List<ApiClientSvcInstRela> apiClientSvcInstRelaList = apiClientSvcInstRelaDao.getList(map);
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("svc_client_id", id);
List<ApiSvcVersion> apiSvcVersionList = apiSvcVersionDao.getListByClientId(map1);
// 根据 CLIENT_ID判断【 前端秘钥】是否使用
if (null == apiClientSvcInstRelaList || apiClientSvcInstRelaList.size() == 0) {
// 根据 CLIENT_ID判断【 后端秘钥】是否使用
if (null == apiSvcVersionList || apiSvcVersionList.size() == 0) {
apiClientDefineDao.delete(apiClientDefine);
} else {
ArrayList<String> arrayList = new ArrayList<>();
for (ApiSvcVersion apiVer : apiSvcVersionList) {
arrayList.add(apiVer.getDisplayName());
}
for (ApiSvcVersion apiVer : apiSvcVersionList) {
throw new RuntimeException("该密钥已被版本" + arrayList + "使用!请解绑后再尝试删除。");
}
}
} else {
throw new RuntimeException("该密钥已绑定服务实例,请执行解绑操作后再尝试删除!");
}
}
//重置密钥对
public void resetSecretKey(String id){
ApiClientDefine apiClientDefine = apiClientDefineDao.findById(id);
String clientType = apiClientDefine.getClientType();
String clientSecret = GuidGenerator.generate();
String clientKey = apiClientDefine.getClientKey();
RedisSerializer stringSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);
redisTemplate.setValueSerializer(stringSerializer);
if("DEV".equals(clientType)){
Map<String,Object> map = new HashMap<String,Object>();
map.put("CLIENT_ID", id);
String ownerId = apiClientDefine.getOwner();
String ownerName = this.userDao.get(ownerId).getLoginName();
List<ApiClientSvcInstRela> apiClientSvcInstRelaList = apiClientSvcInstRelaDao.getList(map);
if(apiClientSvcInstRelaList != null &&apiClientSvcInstRelaList.size()>0){
for (ApiClientSvcInstRela apiClientSvcInstRela : apiClientSvcInstRelaList) {
String versionId = apiClientSvcInstRela.getVersionId();
String redisValue = redisTemplate.opsForValue().get(RedisCachePrefix.getFrtKey(clientKey, versionId));
String[] split = redisValue.split(":");
redisValue =clientSecret+":"+split[1]+":"+split[2]+":"+ownerId+":"+ownerName;
redisTemplate.opsForValue().set(RedisCachePrefix.getFrtKey(clientKey, versionId), redisValue);
}
}
}else if("SVC".equals(clientType)){
String redisKey = clientKey;
String redisValue = clientSecret+":"+id;
// String redisValue = clientSecret+":"+id+":"+ownerId+":"+ownerName;
redisTemplate.opsForValue().set(RedisCachePrefix.getBckKey(redisKey),redisValue);
}
apiClientDefine.setClientSecret(clientSecret);
//apiClientDefine.setCreatedAt(new Date());
apiClientDefine.setUpdatedAt(new Date());
apiClientDefineDao.save(apiClientDefine);
} @Override
public List<ApiClientDefine> getAllSecretKeys(String vdcId){
Map<String,Object> params = new HashMap<String,Object>();
params.put("owner",vdcId);
List<ApiClientDefine> apiClientDefines=apiClientDefineDao.getapiClientDefine(params);
return apiClientDefines;
}
//获取当前用户下的所有密钥对(后端密钥)
public Page<ApiClientDefine> getBackEndApiClientDefineList(Page<ApiClientDefine> page,String desc,String vdcId){
Map<String,Object> map = new HashMap<String,Object>();
map.put("CLIENT_TYPE", "SVC");
map.put("OWNER", vdcId);
map.put("IS_DELETED", false);
if(desc!=null&&desc.trim()!=""){
map.put("DESCRIPTION", desc);
}
Page<ApiClientDefine> apiClientDefinePage = apiClientDefineDao.getList(page, map);
return apiClientDefinePage;
}
}

未完待续……

IOP知识点(1)的更多相关文章

  1. IOP知识点(5)

    1 检验规则 取“或”   2 IOP升级中心 2 IOP升级中心 http://10.110.17.12:8080/cloud-ops/#/environment/     admin 我修改了io ...

  2. IOP知识点(4)

    1.选择多个“li”后,如何再次筛选. 2 按钮屏蔽功能 1.选择多个“li”后,如何再次筛选. 2 按钮屏蔽功能 http://gitserver/iop/cloud-iopm-web/issues ...

  3. IOP知识点(3)-Modal.show

    1.position 模态框初始位置.可设为字符串 "左位置 上位置" 或数组 [左位置, 上位置],规则如下: 左位置 可设为 left|center|right 三者之一,上位 ...

  4. IOP知识点(2)

    1   URL资源访问不足时,需要添加URL权限 2   重定向问题解决办法:3  cloud-service-factory 项目 gradlew方法 1   URL资源访问不足时,需要添加URL权 ...

  5. ASP.NET Core 中的那些认证中间件及一些重要知识点

    前言 在读这篇文章之间,建议先看一下我的 ASP.NET Core 之 Identity 入门系列(一,二,三)奠定一下基础. 有关于 Authentication 的知识太广,所以本篇介绍几个在 A ...

  6. ASP.NET MVC开发:Web项目开发必备知识点

    最近加班加点完成一个Web项目,使用Asp.net MVC开发.很久以前接触的Asp.net开发还是Aspx形式,什么Razor引擎,什么MVC还是这次开发才明白,可以算是新手. 对新手而言,那进行A ...

  7. UWP开发必备以及常用知识点总结

    一直在学UWP,一直在写Code,自己到达了什么水平?还有多少东西需要学习才能独挡一面?我想对刚接触UWP的开发者都有这种困惑,偶尔停下来总结分析一下还是很有收获的! 以下内容是自己开发中经常遇到的一 ...

  8. C#高级知识点&(ABP框架理论学习高级篇)——白金版

    前言摘要 很早以前就有要写ABP高级系列教程的计划了,但是迟迟到现在这个高级理论系列才和大家见面.其实这篇博客很早就着手写了,只是楼主一直写写停停.看看下图,就知道这篇博客的生产日期了,谁知它的出厂日 ...

  9. lucene 基础知识点

    部分知识点的梳理,参考<lucene实战>及网络资料 1.基本概念 lucence 可以认为分为两大组件: 1)索引组件 a.内容获取:即将原始的内容材料,可以是数据库.网站(爬虫).文本 ...

随机推荐

  1. 正则表达式中,[\s\S]* 什么意思

    https://blog.csdn.net/haoyuedangkong_fei/article/details/53781936 例如:[a-z]表示从a到z之间的任意一个. 不是这样的吗?谁能给我 ...

  2. js的with语句,和debugger语句

    减少操作,速度及慢, 严格模式无法使用 debugger 在程序中打断点 'use strict' var name = 'global'; var obj = { name: "ajanu ...

  3. apache 设置环境变量

    在apache设置环境变量有什么好处: 提高代码的可移植性,不用因为换服务器而改项目代码

  4. 微信生成二维码 只需一个网址即刻 还有jquery生成二维码

    <div class="orderDetails-info"> <img src="http://qr.topscan.com/api.php?text ...

  5. DB2 Version 10.5 补丁下载

    DB2 Version 10.5 for Linux, UNIX, and Windows fix pack summary https://www.ibm.com/support/knowledge ...

  6. 非节点主机通过内网远程管理docker swarm集群

    这是今天使用 docker swarm 遇到的一个问题,终于在睡觉前解决了,在这篇随笔中记录一下. 在 docker swarm 集群的 manager 节点上用 docker cli 命令可以正常管 ...

  7. CM5.x配置spark错误解决

    通过cloudera manager 5.x添加spark服务,在创建服务过程中,发现spark服务创建失败,可以通过控制台错误输出看到如下日志信息: + perl -pi -e 's#{{CMF_C ...

  8. Linux 配置SFTP,配置用户访问权限

    之前我服务器是使用的Windows Server 2003,这段时间由于访问量变大我还是机智的换成Linux了,在搭建FTP的时候看到网上都是推荐vsftpd,不过我不推荐这个家伙,看官且看下文. 我 ...

  9. 完整OSW安装方法

    完整OSW安装方法(如果数据库是rac,一定要记得第5步,要不收集不到私网的信息): OSW介质见附件 1.上传介质到 /home/oracle 2.oracle用户将压缩包解压到归档arch目录下( ...

  10. LeetCode 463 Island Perimeter 解题报告

    题目要求 You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 rep ...