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. ios 耳机插入拔出检测

    [AVAudioSession sharedInstance]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@se ...

  2. jenkins之 pipeline 小尝试

    最近,一个小需求,动态建立slave节点来执行自动化用例,原有jenkins 老方式不满足需求,就用到jenkins2的pipeline来实现,但在实现过程中,2个小坑记录下 1.jenkins不能读 ...

  3. python搭建简单http文件服务器

    import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequest ...

  4. get_or_create函数

    get_or_create函数比较好用. 如果查询到就返回,如果没查询到就向数据库加入新的对象. e.g. size = Size.objects.get_or_create(sizeName=siz ...

  5. day_6.16网络编程

    单线程服务器select版: select ---->最多1024个 poll ----->解决了套接字上限的问题----->轮询检测 关于 sys模块: 通过fd找套接字 协程: ...

  6. C - Building Fence

    Long long ago, there is a famous farmer named John. He owns a big farm and many cows. There are two ...

  7. Win 10 计算机管理失效(Windows找不到文件“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Computer Management.lnk)

    Windows找不到文件“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Computer Mana ...

  8. ubuntu 搜狗输入法 在中断失效

    实测是更换了皮肤后,出现在中断输入故障,乱码.在其他界面可能是正常的,更换语言没用. killall fcitx输入法突然好了(根据网友所说,更改一堆东西貌似并没有什么用) 此时关闭输入法皮肤一切正常 ...

  9. CH 2601 - 电路维修 - [双端队列BFS]

    题目链接:传送门 描述 Ha'nyu是来自异世界的魔女,她在漫无目的地四处漂流的时候,遇到了善良的少女Rika,从而被收留在地球上.Rika的家里有一辆飞行车.有一天飞行车的电路板突然出现了故障,导致 ...

  10. 生日蛋糕 POJ - 1190 搜索 数学

    http://poj.org/problem?id=1190 题解:四个剪枝. #define _CRT_SECURE_NO_WARNINGS #include<cstring> #inc ...