|  |  | 
 |  |  | import com.zy.acs.common.utils.Utils; | 
 |  |  | import com.zy.acs.framework.common.Cools; | 
 |  |  | import com.zy.acs.framework.common.R; | 
 |  |  | import com.zy.acs.framework.exception.CoolException; | 
 |  |  | import com.zy.acs.manager.common.annotation.OperationLog; | 
 |  |  | import com.zy.acs.manager.common.domain.BaseParam; | 
 |  |  | import com.zy.acs.manager.common.domain.KeyValVo; | 
 |  |  | import com.zy.acs.manager.common.domain.PageParam; | 
 |  |  | import com.zy.acs.manager.common.utils.ExcelUtil; | 
 |  |  | import com.zy.acs.manager.manager.entity.Code; | 
 |  |  | import com.zy.acs.manager.manager.entity.CodeGap; | 
 |  |  | import com.zy.acs.manager.manager.entity.Route; | 
 |  |  | import com.zy.acs.manager.manager.service.CodeGapService; | 
 |  |  | import com.zy.acs.manager.manager.service.CodeService; | 
 |  |  | import com.zy.acs.manager.manager.service.RouteService; | 
 |  |  | import com.zy.acs.manager.manager.service.impl.CodeServiceImpl; | 
 |  |  | import com.zy.acs.manager.system.controller.BaseController; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private CodeService codeService; | 
 |  |  |     @Autowired | 
 |  |  |     private CodeGapService codeGapService; | 
 |  |  |     @Autowired | 
 |  |  |     private RouteService routeService; | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:code:list')") | 
 |  |  |     @PostMapping("/code/page") | 
 |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:code:remove')") | 
 |  |  |     @OperationLog("Delete Code") | 
 |  |  |     @PostMapping("/code/remove/{ids}") | 
 |  |  |     @Transactional | 
 |  |  |     public R remove(@PathVariable Long[] ids) { | 
 |  |  |         if (!codeService.removeByIds(Arrays.asList(ids))) { | 
 |  |  |             return R.error("Delete Fail"); | 
 |  |  |         for (Long id : ids) { | 
 |  |  |             Code code = codeService.getById(id); | 
 |  |  |             if (null == code) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             codeGapService.remove(new LambdaQueryWrapper<CodeGap>().eq(CodeGap::getCode0, code.getId()).or().eq(CodeGap::getCode1, code.getId())); | 
 |  |  |             routeService.remove(new LambdaQueryWrapper<Route>().eq(Route::getStartCode, code.getId()).or().eq(Route::getEndCode, code.getId())); | 
 |  |  |             if (!codeService.removeById(id)) { | 
 |  |  |                 throw new CoolException("failed to remove code"); | 
 |  |  |             } else { | 
 |  |  |                 CodeServiceImpl.CODE_ID_CACHE.remove(code.getId()); | 
 |  |  |                 CodeServiceImpl.CODE_DATA_CACHE.remove(code.getData()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok("Delete Success").add(ids); | 
 |  |  |     } |