数据删除同步接口
							parent
							
								
									e04341415c
								
							
						
					
					
						commit
						5154d18206
					
				| @ -0,0 +1,37 @@ | ||||
| package com.glxp.api.idc.controller; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| 
 | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.ResponseBody; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| 
 | ||||
| import com.glxp.api.common.res.BaseResponse; | ||||
| import com.glxp.api.common.util.ResultVOUtils; | ||||
| import com.glxp.api.idc.service.DeleteService; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * 中继服务接口 | ||||
|  */ | ||||
| 
 | ||||
| @RestController | ||||
| public class DeleteController { | ||||
|     @Resource | ||||
|     DeleteService deleteService; | ||||
| 
 | ||||
|     @RequestMapping(value = "/spssync/common/delete") | ||||
|     @ResponseBody | ||||
|     public BaseResponse delete(HttpServletRequest request, @RequestBody Map<String, Object> params) { | ||||
|         if(deleteService.syncDelete(params)) | ||||
|             return ResultVOUtils.success(); | ||||
|         return ResultVOUtils.error(9999, "失败"); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| package com.glxp.api.idc.service; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| /*数据中继删除数据处理*/ | ||||
| public interface DeleteService { | ||||
| 
 | ||||
| 	boolean syncDelete(String tableName,String uniqueColumn,String value); | ||||
| 	boolean syncDelete(Map<String,Object> params); | ||||
| } | ||||
| @ -0,0 +1,52 @@ | ||||
| package com.glxp.api.idc.service.impl; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.jdbc.core.JdbcTemplate; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import com.glxp.api.dao.idc.DbDao; | ||||
| import com.glxp.api.idc.service.DeleteService; | ||||
| import com.glxp.api.util.CustomUtil; | ||||
| 
 | ||||
| 
 | ||||
| /*连通检测*/ | ||||
| @Service | ||||
| public class DeleteServiceImpl implements DeleteService { | ||||
|     private static final Logger logger = LoggerFactory.getLogger(DeleteServiceImpl.class); | ||||
|     @Resource | ||||
|     private JdbcTemplate jdbcTemplate; | ||||
|     @Resource | ||||
|     private DbDao dbDao; | ||||
|      | ||||
|     @Override | ||||
|     public boolean syncDelete(String tableName,String uniqueColumn,String uniqueValue) { | ||||
|         Map<String,Object> map = new HashMap<>(); | ||||
|         map.put("tableName", tableName); | ||||
|         map.put("uniqueColumn", uniqueColumn); | ||||
|         map.put("uniqueValue", uniqueValue); | ||||
|         return syncDelete(map); | ||||
|     } | ||||
|     @Override | ||||
|     public boolean syncDelete(Map<String,Object> params) { | ||||
|         createTable(); | ||||
|         String sql = "insert into idc_delete (id,tableName,uniqueColumn,uniqueValue,updateTime) values ('"+CustomUtil.getId()+"','"+params.get("tableName")+"','"+params.get("uniqueColumn")+"','"+params.get("uniqueValue")+"',now())"; | ||||
|         if(dbDao.save(sql)>0) | ||||
|             return true; | ||||
|         return false; | ||||
|     } | ||||
|      | ||||
|     private void createTable() { | ||||
|         try { | ||||
|             jdbcTemplate.execute("create table idc_delete (id varchar(36),tableName varchar(100),uniqueColumn varchar(60),uniqueValue varchar(200),updateTime datetime,PRIMARY KEY (id))"); | ||||
| 
 | ||||
|         } catch (Exception e) { | ||||
| 
 | ||||
|         } | ||||
|      } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue