package com.product.face.controller;
|
|
import com.drew.metadata.Face;
|
import com.product.core.cache.DataPoolCacheImpl;
|
import com.product.core.config.CoreConst;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.face.config.ErrorCode;
|
import com.product.face.config.FaceConst;
|
import com.product.face.service.FaceDesignService;
|
import com.product.face.service.ide.IFaceDesignService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
import com.product.util.support.AbstractBaseController;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.*;
|
|
/**
|
* @Author cheng
|
* @Date 2023/4/21 17:43
|
* @Desc 表单设计
|
*/
|
@RestController
|
@RequestMapping("/api/face-design")
|
public class FaceDesignController extends AbstractBaseController {
|
|
@Resource
|
private IFaceDesignService faceDesignService;
|
|
/**
|
* 表单列表左侧树
|
*
|
* @return
|
*/
|
@PostMapping("/tree-face/{version}")
|
@ApiVersion(1)
|
public String faceListTree() {
|
DataTableEntity tableInfoData = DataPoolCacheImpl.getInstance().getCacheData("所有表信息");
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
if (!DataTableEntity.isEmpty(tableInfoData)) {
|
for (int i = 0; i < tableInfoData.getRows(); i++) {
|
FieldSetEntity fse = tableInfoData.getFieldSetEntity(i);
|
Map<String, Object> record = new HashMap<>();
|
String tableName = fse.getString(FaceConst.FIELD_TABLE_NAME);
|
String value = fse.getString(FaceConst.UUID);
|
String tableType = fse.getString(FaceConst.FIELD_TABLE_TYPE);
|
String tableDescription = fse.getString("table_description");
|
record.put("value", value);
|
record.put(FaceConst.FIELD_TABLE_NAME, tableName);
|
record.put(FaceConst.FIELD_TABLE_TYPE, tableType);
|
record.put("table_description", tableDescription);
|
resultList.add(record);
|
}
|
resultList.sort(Comparator.comparing(o -> o.get(FaceConst.FIELD_TABLE_TYPE).toString()));
|
}
|
return success(resultList);
|
}
|
|
|
/**
|
* 查询表单设计数据详情
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/find-face-config/{version}")
|
@ApiVersion(1)
|
public String findFaceConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
|
String uuid = fse.getUUID();
|
return faceDesignService.getFaceConfigInfo(uuid);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_FACE_FAIL, e);
|
}
|
}
|
|
/**
|
* 保存表单设计数据
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/save-face/{version}")
|
@ApiVersion(1)
|
public String saveFaceData(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
|
IFaceDesignService proxy = getProxy();
|
return OK_List(proxy.saveFaceData(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_FACE_FAIL, e);
|
}
|
}
|
|
/**
|
* 删除表单设计
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/delete-face/{version}")
|
@ApiVersion(1)
|
public String deleteFace(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG);
|
IFaceDesignService proxy = getProxy();
|
proxy.deleteFace(fse);
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.DELETE_FACE_FAIL, e);
|
}
|
}
|
|
/**
|
* 获取事务代理
|
*
|
* @return
|
*/
|
private IFaceDesignService getProxy() {
|
return (IFaceDesignService) getProxyInstance(faceDesignService);
|
}
|
|
|
}
|