|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.acs.common.utils.GsonUtils; | 
|---|
|  |  |  | 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.manager.common.annotation.OperationLog; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.acs.manager.common.domain.PageParam; | 
|---|
|  |  |  | import com.zy.acs.manager.common.utils.ExcelUtil; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.Route; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.CodeService; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.RouteService; | 
|---|
|  |  |  | import com.zy.acs.manager.system.controller.BaseController; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.regex.Matcher; | 
|---|
|  |  |  | import java.util.regex.Pattern; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RouteService routeService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CodeService codeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:route:list')") | 
|---|
|  |  |  | @PostMapping("/route/page") | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/route/import") | 
|---|
|  |  |  | public R importBatch(@RequestBody List<Map<String, Object>> list) { | 
|---|
|  |  |  | Date now = new Date();  Long userId = getLoginUserId(); | 
|---|
|  |  |  | String regex = "([a-zA-Z]+)\\("; | 
|---|
|  |  |  | Pattern pattern = Pattern.compile(regex); | 
|---|
|  |  |  | for (Map<String, Object> map : list) { | 
|---|
|  |  |  | Map<String, Object> one = new HashMap<>(); | 
|---|
|  |  |  | for (Map.Entry<String, Object> entry : map.entrySet()) { | 
|---|
|  |  |  | String key = entry.getKey(); | 
|---|
|  |  |  | Matcher matcher = pattern.matcher(key); | 
|---|
|  |  |  | if (matcher.find()) { | 
|---|
|  |  |  | key = matcher.group(1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | key = Utils.toCamelCase(key); | 
|---|
|  |  |  | one.put(key, entry.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Route route = Cools.conver(one, Route.class); | 
|---|
|  |  |  | System.out.println(GsonUtils.toJson(route)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|