package com.product.mobile.core.controller;
import com.product.common.lang.StringUtils;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.mobile.core.config.MobileCoreCode;
import com.product.mobile.core.service.FaceMobileService;
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;
/**
* @Author cheng
* @Date 2024/8/15 10:19
* @Desc
*/
@RequestMapping("/api/mobile-face/")
@RestController
public class FaceMobileController extends AbstractBaseController {
@Resource
FaceMobileService faceMobileService;
/**
* 鑾峰彇琛ㄥ崟鎵€鏈夌粍浠剁殑瀛楁鏍规嵁涓氬姟琛ㄥ悕
*/
@PostMapping("/get-face-field-by-table/{version}")
@ApiVersion(1)
public String getFaceFieldByTable(HttpServletRequest request) {
try {
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
return BaseUtil.success(faceMobileService.getFaceFieldByTable(fse));
} catch (BaseException e) {
e.printStackTrace();
return error(e);
} catch (Exception e) {
e.printStackTrace();
return error(MobileCoreCode.GET_FACE_FIELD_FAIL, e);
}
}
/**
* 鑾峰彇琛ㄥ崟鎵€鏈夌粍浠剁殑瀛楁鏍规嵁flow_task 琛� uuid 鎴栬€� flow_detail 琛� uuid
*
* @param request
* @return
*/
@PostMapping("/get-face-field/{version}")
@ApiVersion(1)
public String getFaceField(HttpServletRequest request) {
try {
//涓嶉獙璇佷紶鍏ョ殑琛ㄥ悕 鍙兘浼氭槸 product_sys_flow_task/product_sys_flow_detail
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
// //閫氳繃瀹℃壒浠诲姟鐨剈uid鏉ユ煡琛ㄥ崟淇℃伅
// if (StringUtils.isEmpty(fse.getString("table_uuid")) && StringUtils.isEmpty(fse.getString("table_name"))) {
// return BaseUtil.success(faceMobileService.getFlowFaceField(fse));
// }else {
// //閫氳繃涓氬姟琛ㄤ俊鎭煡琛ㄥ崟淇℃伅
// return BaseUtil.success(faceMobileService.getFaceFieldByTable(fse));
// }
return BaseUtil.success(faceMobileService.getFaceConfig(fse));
} catch (BaseException e) {
e.printStackTrace();
return error(e);
} catch (Exception e) {
e.printStackTrace();
return error(MobileCoreCode.GET_FACE_FIELD_FAIL, e);
}
}
}