123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package com.persagy.proxy.object.controller;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.util.StrUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.persagy.dmp.common.utils.JsonHelper;
- import com.persagy.proxy.adm.request.AdmCreateRequest;
- import com.persagy.proxy.adm.request.AdmQueryCriteria;
- import com.persagy.proxy.adm.request.AdmResponse;
- import com.persagy.proxy.adm.utils.AdmContextUtil;
- import com.persagy.proxy.object.model.AdmISpace;
- import com.persagy.proxy.object.service.IAdmISpaceService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * Adm 模型空间 API
- * @author lvxy
- * @date 2021/8/16
- */
- @RestController
- @RequestMapping("/object/ispace")
- public class AdmISpaceController {
- @Autowired
- private IAdmISpaceService service;
- /**
- * 统计
- *
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/count")
- public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
- request.setName(AdmISpace.OBJ_TYPE);
- request.setOnlyCount(true);
- return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
- }
- /**
- * 创建
- * @param AdmISpace
- * @return
- * @throws Exception
- */
- @PostMapping("/create")
- public AdmResponse create(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace) throws Exception {
- List<AdmISpace> vos = CollUtil.newArrayList(AdmISpace.getContent());
- ensureDataInfos(vos);
- vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmISpace.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 根据ID删除
- * @param vos
- * @return
- * @throws Exception
- */
- @PostMapping("/delete")
- public AdmResponse delete( @RequestBody List<AdmISpace> vos) throws Exception {
- service.doDelete(AdmContextUtil.toDmpContext(), vos);
- return AdmResponse.success();
- }
- /**
- * 更新分区对象信息
- * @param AdmISpace
- * @return
- * @throws Exception
- */
- @PostMapping("/update")
- public AdmResponse update(@RequestBody AdmCreateRequest<AdmISpace> AdmISpace) throws Exception {
- List<AdmISpace> vos = CollUtil.newArrayList(AdmISpace.getContent());
- ensureDataInfos(vos);
- vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmISpace.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 补偿处理对象属性
- * @param vos
- */
- private void ensureDataInfos(List<AdmISpace> vos) {
- if(CollUtil.isEmpty(vos)) {
- return;
- }
- for(AdmISpace vo:vos) {
- if(StrUtil.isBlank(vo.getName())) {
- vo.setName(vo.getLocalName());
- }
- vo.setClassCode(AdmISpace.OBJ_TYPE);
- }
- }
- /**
- * 根据楼层id查询元空间数据
- * @param param:请求参数
- */
- @PostMapping("/query")
- public AdmResponse query(@RequestBody JSONObject param) throws Exception {
- AdmQueryCriteria request = JsonHelper.toSingleEntity(param, AdmQueryCriteria.class);
- request.setName(AdmISpace.OBJ_TYPE);
- if (StrUtil.isNotBlank(param.getString("floorId"))){
- String filters = " floorId = '"+param.getString("floorId")+"' ";
- request.addFilters(filters);
- }
- AdmResponse admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
- admResponse.setMessage(param.getString("floorId"));
- return admResponse;
- }
- }
|