diff --git a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java index b7e3a1115a1b04e6d2067b92ad1933c693ee9e80..6613192ce0c3b0511961ebb3e250eaa33631221a 100644 --- a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java @@ -16,6 +16,7 @@ package neatlogic.module.cmdb.api.attr; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.attrvaluehandler.core.AttrValueHandlerFactory; @@ -33,6 +34,7 @@ import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.ci.AttrMapper; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.dao.mapper.ci.CiViewMapper; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -76,7 +78,9 @@ public class GetCiAttrListApi extends PrivateApiComponentBase { @Param(name = "showType", type = ApiParamType.ENUM, rule = "all,list,detail", desc = "common.displaytype"), @Param(name = "allowEdit", type = ApiParamType.INTEGER, rule = "1,0", desc = "term.cmdb.allowedit"), @Param(name = "isRequired", type = ApiParamType.INTEGER, rule = "1,0", desc = "common.isrequired"), - @Param(name = "isSimple", type = ApiParamType.BOOLEAN, rule = "true,false", desc = "term.cmdb.issimpleattribute") + @Param(name = "isSimple", type = ApiParamType.BOOLEAN, rule = "true,false", desc = "term.cmdb.issimpleattribute"), + @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue") + }) @Output({ @Param(name = "Return", explode = AttrVo[].class) @@ -84,6 +88,12 @@ public class GetCiAttrListApi extends PrivateApiComponentBase { @Description(desc = "nmcaa.getciattrlistapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { + JSONArray defaultValue = jsonObj.getJSONArray("defaultValue"); + if (CollectionUtils.isNotEmpty(defaultValue)) { + List idList = defaultValue.toJavaList(Long.class); + List attrList = attrMapper.getAttrByIdList(idList); + return attrList; + } Long ciId = jsonObj.getLong("ciId"); if (ciId == null) { String ciName = jsonObj.getString("ciName"); diff --git a/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java b/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java index 4f2b9e5b8f646e20f36b36d8191628bbc3398776..9b49fa889bd162ce4bfbe745b8496c6bda3605a3 100644 --- a/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java @@ -16,16 +16,19 @@ package neatlogic.module.cmdb.api.customview; +import com.alibaba.fastjson.JSONArray; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.dto.customview.CustomViewAttrVo; import neatlogic.framework.cmdb.dto.customview.CustomViewConstAttrVo; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.exception.type.ParamNotExistsException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.framework.cmdb.auth.label.CMDB_BASE; import neatlogic.module.cmdb.dao.mapper.customview.CustomViewMapper; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -41,7 +44,7 @@ public class GetCustomViewAttrApi extends PrivateApiComponentBase { @Override public String getName() { - return "获取自定义视图属性列表"; + return "nmcac.getcustomviewattrapi.getname"; } @Override @@ -49,12 +52,30 @@ public class GetCustomViewAttrApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "id", type = ApiParamType.LONG, desc = "视图id", isRequired = true), @Param(name = "isHidden", type = ApiParamType.INTEGER, desc = "属性是否隐藏,1是,0否")}) - @Output({@Param(name = "attrList", explode = CustomViewAttrVo[].class), @Param(name = "constAttrList", explode = CustomViewConstAttrVo[].class)}) - @Description(desc = "获取自定义视图属性列表接口") + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "common.id"), + @Param(name = "isHidden", type = ApiParamType.INTEGER, desc = "common.ishidden,", help = "1是,0否"), + @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue") + }) + @Output({ + @Param(name = "attrList", explode = CustomViewAttrVo[].class), + @Param(name = "constAttrList", explode = CustomViewConstAttrVo[].class) + }) + @Description(desc = "nmcac.getcustomviewattrapi.getname") @Override public Object myDoService(JSONObject paramObj) throws Exception { + JSONArray defaultValue = paramObj.getJSONArray("defaultValue"); + if (CollectionUtils.isNotEmpty(defaultValue)) { + List uuidList = defaultValue.toJavaList(String.class); + List attrList = customViewMapper.getCustomViewAttrByUuidList(uuidList); + JSONObject returnObj = new JSONObject(); + returnObj.put("attrList", attrList); + return returnObj; + } Long id = paramObj.getLong("id"); + if (id == null) { + throw new ParamNotExistsException("id"); + } Integer isHidden = paramObj.getInteger("isHidden"); CustomViewConstAttrVo customViewConstAttrVo = new CustomViewConstAttrVo(id); CustomViewAttrVo customViewAttrVo = new CustomViewAttrVo(id); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java index c048eab7fb33ff11942628c7a467843efe9cf120..319e30f3d2effc68a96b2ac076080f1e714ab704 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java @@ -42,6 +42,8 @@ public interface CustomViewMapper { List getCustomViewAttrByCustomViewId(CustomViewAttrVo customViewAttrVo); + List getCustomViewAttrByUuidList(List uuidList); + List getCustomViewConstAttrByCustomViewId(CustomViewConstAttrVo customViewConstAttrVo); List getCustomViewLinkByCustomViewId(Long customViewId); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml index f4a78ce0ca811f782e681ca11e12a96563da0439..6fbc90d8f292e93bfe143dd5d287d24d1eac9d07 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml @@ -177,6 +177,34 @@ ORDER BY a.sort + +