人脸库添加的修改
This commit is contained in:
		
							parent
							
								
									f8dfb4f52d
								
							
						
					
					
						commit
						9d7af74009
					
				| @ -68,12 +68,13 @@ public class ResourcesController  extends CommonResult { | ||||
|     @NoRepeatSubmitAnnotation(prefix = "Resources/faceLib") | ||||
|     public CommonResult addFaceLibrary(@ApiParam(required = true, name = "faceLibrary", value = "{\n" + | ||||
|             "  \"factoryName\": \"库名称\",\n" + | ||||
|             "  \"factoryType\": \"库类型\",\n" + | ||||
|             "  \"remarks\": \"备注\"\n" + | ||||
|             "}")@RequestBody FaceLibrary faceLibrary){ | ||||
|         if (UtilValidate.isEmpty(faceLibrary.getFactoryName())){ | ||||
|             throw new DkException("库名称不能为空"); | ||||
|         } | ||||
|         faceLibrary.setIdFactory(System.currentTimeMillis()); | ||||
|         faceLibrary.setFactoryType("0"); | ||||
|         faceLibrary.setIsValid(YNEnums.YES.code); | ||||
|         faceLibrary.setCreateTime(new Date()); | ||||
|         faceLibrary.setUpdateTime(new Date()); | ||||
|  | ||||
| @ -32,4 +32,6 @@ public interface FaceLibraryMapper extends BaseMapper<FaceLibrary> { | ||||
|      * @return | ||||
|      */ | ||||
|      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) | ||||
|     public FaceLibrary addLibrary(FaceLibrary faceLibrary) { | ||||
|         try { | ||||
|             FaceLibraryVO faceLibraryVO = new FaceLibraryVO(); | ||||
|             faceLibraryVO.setName(faceLibrary.getFactoryName()); | ||||
|             if(UtilValidate.isNotEmpty(faceLibrary.getFactoryType())) { | ||||
|                 faceLibraryVO.setType(faceLibrary.getFactoryType()); | ||||
|             if (faceLibraryMapper.getLibrary(faceLibrary.getFactoryName()) != null) { | ||||
|                 throw new DkException("库名称已存在"); | ||||
|             } | ||||
|             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); | ||||
|             if(insert<0){ | ||||
|                 throw new DkException("新增库失败"); | ||||
|                 throw new DkException("MySQL新增库失败"); | ||||
|             } | ||||
|         }catch (Exception e){ | ||||
|             throw new DkException("新增库失败"+e.getMessage()); | ||||
|  | ||||
| @ -25,7 +25,7 @@ spring: | ||||
|     druid: | ||||
|       #MySQL | ||||
|       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 | ||||
|       password: Dkha123 | ||||
|       initial-size: 10 | ||||
|  | ||||
| @ -23,4 +23,16 @@ | ||||
|     <select id="getLibraryCount" resultType="java.lang.Integer"> | ||||
|         select COUNT(*)  from portrait p where p.is_valid='Y'and p.id_factory= #{idFactory} | ||||
|     </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> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user