人脸库添加的修改
parent
f8dfb4f52d
commit
9d7af74009
|
@ -68,12 +68,13 @@ public class ResourcesController extends CommonResult {
|
||||||
@NoRepeatSubmitAnnotation(prefix = "Resources/faceLib")
|
@NoRepeatSubmitAnnotation(prefix = "Resources/faceLib")
|
||||||
public CommonResult addFaceLibrary(@ApiParam(required = true, name = "faceLibrary", value = "{\n" +
|
public CommonResult addFaceLibrary(@ApiParam(required = true, name = "faceLibrary", value = "{\n" +
|
||||||
" \"factoryName\": \"库名称\",\n" +
|
" \"factoryName\": \"库名称\",\n" +
|
||||||
" \"factoryType\": \"库类型\",\n" +
|
|
||||||
" \"remarks\": \"备注\"\n" +
|
" \"remarks\": \"备注\"\n" +
|
||||||
"}")@RequestBody FaceLibrary faceLibrary){
|
"}")@RequestBody FaceLibrary faceLibrary){
|
||||||
if (UtilValidate.isEmpty(faceLibrary.getFactoryName())){
|
if (UtilValidate.isEmpty(faceLibrary.getFactoryName())){
|
||||||
throw new DkException("库名称不能为空");
|
throw new DkException("库名称不能为空");
|
||||||
}
|
}
|
||||||
|
faceLibrary.setIdFactory(System.currentTimeMillis());
|
||||||
|
faceLibrary.setFactoryType("0");
|
||||||
faceLibrary.setIsValid(YNEnums.YES.code);
|
faceLibrary.setIsValid(YNEnums.YES.code);
|
||||||
faceLibrary.setCreateTime(new Date());
|
faceLibrary.setCreateTime(new Date());
|
||||||
faceLibrary.setUpdateTime(new Date());
|
faceLibrary.setUpdateTime(new Date());
|
||||||
|
|
|
@ -32,4 +32,6 @@ public interface FaceLibraryMapper extends BaseMapper<FaceLibrary> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getLibraryCount(@Param("idFactory") Long idFactory);
|
Integer getLibraryCount(@Param("idFactory") Long idFactory);
|
||||||
|
|
||||||
|
FaceLibrary getLibrary(@Param("factoryName") String factoryName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,19 +67,19 @@ public class FaceLibraryServiceImpl extends ServiceImpl<FaceLibraryMapper, FaceL
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public FaceLibrary addLibrary(FaceLibrary faceLibrary) {
|
public FaceLibrary addLibrary(FaceLibrary faceLibrary) {
|
||||||
try {
|
try {
|
||||||
FaceLibraryVO faceLibraryVO = new FaceLibraryVO();
|
if (faceLibraryMapper.getLibrary(faceLibrary.getFactoryName()) != null) {
|
||||||
faceLibraryVO.setName(faceLibrary.getFactoryName());
|
throw new DkException("库名称已存在");
|
||||||
if(UtilValidate.isNotEmpty(faceLibrary.getFactoryType())) {
|
}
|
||||||
faceLibraryVO.setType(faceLibrary.getFactoryType());
|
FaceLibraryVO faceLibraryVO = new FaceLibraryVO();
|
||||||
|
faceLibraryVO.setLibraryId(faceLibrary.getIdFactory().toString());
|
||||||
|
faceLibraryVO.setName(faceLibrary.getFactoryName());
|
||||||
|
String result = (String) httpUtil.post(link + ApiUrlEnum.FACELIB_POSTURL.getUrl(), faceLibraryVO, String.class);
|
||||||
|
if(! result.equals("ok")){
|
||||||
|
throw new DkException("算法端新增库失败");
|
||||||
}
|
}
|
||||||
ApiVO faceLibrary1 = (ApiVO) httpUtil.post(link+ ApiUrlEnum.FACELIB_POSTURL.getUrl(), faceLibraryVO, ApiVO.class);
|
|
||||||
/**调用API*/
|
|
||||||
String json = gson.toJson(faceLibrary1.getData());
|
|
||||||
FaceLibraryVO face = gson.fromJson(json, FaceLibraryVO.class);
|
|
||||||
faceLibrary.setIdFactory(Long.parseLong(face.getLibraryId()));
|
|
||||||
int insert = faceLibraryMapper.insert(faceLibrary);
|
int insert = faceLibraryMapper.insert(faceLibrary);
|
||||||
if(insert<0){
|
if(insert<0){
|
||||||
throw new DkException("新增库失败");
|
throw new DkException("MySQL新增库失败");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new DkException("新增库失败"+e.getMessage());
|
throw new DkException("新增库失败"+e.getMessage());
|
||||||
|
|
|
@ -25,7 +25,7 @@ spring:
|
||||||
druid:
|
druid:
|
||||||
#MySQL
|
#MySQL
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://192.168.1.127:3306/face_application?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://192.168.1.127:3306/face_application_23_3?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: Dkha123
|
password: Dkha123
|
||||||
initial-size: 10
|
initial-size: 10
|
||||||
|
|
|
@ -23,4 +23,16 @@
|
||||||
<select id="getLibraryCount" resultType="java.lang.Integer">
|
<select id="getLibraryCount" resultType="java.lang.Integer">
|
||||||
select COUNT(*) from portrait p where p.is_valid='Y'and p.id_factory= #{idFactory}
|
select COUNT(*) from portrait p where p.is_valid='Y'and p.id_factory= #{idFactory}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getLibrary" resultType="com.dkha.server.modules.entities.FaceLibrary">
|
||||||
|
SELECT
|
||||||
|
f.id_factory as idFactory,
|
||||||
|
f.factory_name as factoryName,
|
||||||
|
f.factory_type as factoryType,
|
||||||
|
f.remarks,
|
||||||
|
f.create_time as createTime
|
||||||
|
FROM
|
||||||
|
face_library f
|
||||||
|
WHERE
|
||||||
|
f.id_factory = #{factoryName}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue