AdminDemandApiController.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. package com.goafanti.admin.controller;
  2. import java.io.IOException;
  3. import java.lang.reflect.Field;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.List;
  7. import java.util.UUID;
  8. import javax.annotation.Resource;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import javax.validation.Valid;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.validation.BindingResult;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import org.springframework.web.multipart.MultipartFile;
  19. import com.alibaba.fastjson.JSON;
  20. import com.goafanti.admin.service.AftFileService;
  21. import com.goafanti.common.bo.Result;
  22. import com.goafanti.common.constant.AFTConstants;
  23. import com.goafanti.common.constant.ErrorConstants;
  24. import com.goafanti.common.controller.CertifyApiController;
  25. import com.goafanti.common.enums.AchievementImportFields;
  26. import com.goafanti.common.enums.AttachmentType;
  27. import com.goafanti.common.enums.DeleteStatus;
  28. import com.goafanti.common.enums.DemandAuditStatus;
  29. import com.goafanti.common.enums.DemandDataCategory;
  30. import com.goafanti.common.enums.DemandFields;
  31. import com.goafanti.common.enums.DemandImportFields;
  32. import com.goafanti.common.enums.DemandOrderStatus;
  33. import com.goafanti.common.enums.DemandReleaseStatus;
  34. import com.goafanti.common.enums.DemandSwitchSign;
  35. import com.goafanti.common.model.AftFile;
  36. import com.goafanti.common.model.Demand;
  37. import com.goafanti.common.model.DemandOrder;
  38. import com.goafanti.common.utils.LoggerUtils;
  39. import com.goafanti.common.utils.StringUtils;
  40. import com.goafanti.core.shiro.token.TokenManager;
  41. import com.goafanti.demand.bo.DemandImportBo;
  42. import com.goafanti.demand.bo.InputDemand;
  43. import com.goafanti.demand.service.DemandOrderService;
  44. import com.goafanti.demand.service.DemandService;
  45. import com.goafanti.user.service.UserService;
  46. @RestController
  47. @RequestMapping(value = "/api/admin/demand")
  48. public class AdminDemandApiController extends CertifyApiController {
  49. @Resource
  50. private DemandService demandService;
  51. @Resource
  52. private UserService userService;
  53. @Resource
  54. private AftFileService aftFileService;
  55. @Resource
  56. private DemandOrderService demandOrderService;
  57. /**
  58. * 科技需求匹配科技成果
  59. */
  60. @RequestMapping(value = "/matchAchievement", method = RequestMethod.POST)
  61. public Result matchAchievement(String id) {
  62. Result res = new Result();
  63. if (StringUtils.isBlank(id)) {
  64. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "成果ID"));
  65. return res;
  66. }
  67. Demand d = demandService.selectByPrimaryKey(id);
  68. if (null == d || !DemandReleaseStatus.RELEASED.getCode().equals(d.getReleaseStatus())
  69. || !DeleteStatus.UNDELETE.getCode().equals(d.getDeletedSign())
  70. || !DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())) {
  71. res.getError().add(buildError("", "当前状态无法匹配!"));
  72. return res;
  73. }
  74. res.setData(demandService.updateMatchAchievement(d));
  75. return res;
  76. }
  77. /**
  78. * 批量导入科技需求
  79. */
  80. @SuppressWarnings("unchecked")
  81. @RequestMapping(value = "/importDemand", method = RequestMethod.POST)
  82. public Result importDemand(@RequestParam(name = "data", required = false) String d) {
  83. Result res = new Result();
  84. List<DemandImportBo> data = JSON.parseArray(d, DemandImportBo.class);
  85. if (data == null || data.isEmpty()) {
  86. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "导入数据"));
  87. return res;
  88. }
  89. if (data.size() > AFTConstants.IMPORTMAXLENTH) {
  90. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "导入数据量"));
  91. return res;
  92. }
  93. res = disposeImportDemand(res, data);
  94. if (!res.getError().isEmpty()) {
  95. return res;
  96. }
  97. data = (List<DemandImportBo>) res.getData();
  98. demandService.insertImport(data);
  99. return res;
  100. }
  101. /**
  102. * 成果需求匹配列表
  103. */
  104. @RequestMapping(value = "/achievementDemand", method = RequestMethod.GET)
  105. public Result achievementDemand(String id) {
  106. Result res = new Result();
  107. res.setData(demandService.selectAchievementDemandListByDemandId(id));
  108. return res;
  109. }
  110. /**
  111. * 上传技术需求批量导入Excel模板
  112. *
  113. * @param req
  114. * @return
  115. */
  116. @RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST)
  117. public Result uploadPatentTemplate(HttpServletRequest req, String sign) {
  118. Result res = new Result();
  119. String fileName = "";
  120. List<MultipartFile> files = getFiles(req);
  121. MultipartFile mf = files.get(0);
  122. String suffix = mf.getOriginalFilename().substring(mf.getOriginalFilename().lastIndexOf("."));
  123. if (suffix.equals(".xls") || suffix.equals(".xlsx")) {
  124. AttachmentType attachmentType = AttachmentType.getField(sign);
  125. if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
  126. fileName = sign + suffix;
  127. } else {
  128. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  129. return res;
  130. }
  131. String name = handleFile(res, req, fileName, files, mf);
  132. res.setData(name);
  133. if (!StringUtils.isBlank(name) && null == aftFileService.selectAftFileBySign(sign)) {
  134. AftFile f = new AftFile();
  135. f.setId(UUID.randomUUID().toString());
  136. f.setFileName(AttachmentType.DEMAND_TEMPLATE.getDesc());
  137. f.setUid(TokenManager.getAdminId());
  138. f.setComment(AttachmentType.DEMAND_TEMPLATE.getDesc());
  139. f.setSign(sign);
  140. f.setFilePath("/admin/" + fileName);
  141. f.setDeleletedSign(DeleteStatus.UNDELETE.getCode());
  142. aftFileService.insert(f);
  143. }
  144. } else {
  145. res.getError().add(buildError(ErrorConstants.FILE_PATTERN_ERROR, "文件格式错误,请重新上传!"));
  146. }
  147. return res;
  148. }
  149. /**
  150. * 下载技术需求批量导入Excel模板
  151. *
  152. * @param response
  153. * @return
  154. */
  155. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  156. public Result downloadTemplateFile(HttpServletResponse response, String sign) {
  157. Result res = new Result();
  158. AttachmentType attachmentType = AttachmentType.getField(sign);
  159. if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
  160. String fileName = "";
  161. AftFile af = aftFileService.selectAftFileBySign(sign);
  162. if (null == af) {
  163. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  164. } else {
  165. String path = af.getFilePath();
  166. String suffix = path.substring(path.lastIndexOf("."));
  167. fileName = AttachmentType.DEMAND_TEMPLATE.getDesc() + suffix;
  168. downloadFile(response, fileName, path);
  169. }
  170. } else {
  171. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  172. }
  173. return res;
  174. }
  175. /**
  176. * 个人用户--需求列表
  177. */
  178. @RequestMapping(value = "/userList", method = RequestMethod.GET)
  179. public Result userList(String employerName, Integer auditStatus, Integer province, Integer serialNumber, String name, String keyword,
  180. Integer infoSources, Integer demandType, String validityPeriodStartDate, String validityPeriodEndDate,
  181. String username, Integer status, Integer releaseStatus, String releaseDateStartDate,
  182. String releaseDateEndDate, String pageNo, String pageSize) {
  183. Result res = new Result();
  184. Integer pNo = 1;
  185. Integer pSize = 10;
  186. if (StringUtils.isNumeric(pageSize)) {
  187. pSize = Integer.parseInt(pageSize);
  188. }
  189. if (StringUtils.isNumeric(pageNo)) {
  190. pNo = Integer.parseInt(pageNo);
  191. }
  192. res.setData(demandService.selectUserDemandManageList(employerName, auditStatus, province, serialNumber, name, keyword,
  193. infoSources, demandType, validityPeriodStartDate, validityPeriodEndDate, username, status,
  194. releaseStatus, releaseDateStartDate, releaseDateEndDate, pNo, pSize));
  195. return res;
  196. }
  197. /**
  198. * 组织用户--需求列表
  199. */
  200. @RequestMapping(value = "/orgList", method = RequestMethod.GET)
  201. public Result orgList(String employerName, Integer auditStatus, Integer province, Integer serialNumber, String name, String keyword,
  202. Integer infoSources, Integer demandType, String validityPeriodStartDate, String validityPeriodEndDate,
  203. String unitName, Integer status, Integer releaseStatus, String releaseDateStartDate,
  204. String releaseDateEndDate, String pageNo, String pageSize) {
  205. Result res = new Result();
  206. Integer pNo = 1;
  207. Integer pSize = 10;
  208. if (StringUtils.isNumeric(pageSize)) {
  209. pSize = Integer.parseInt(pageSize);
  210. }
  211. if (StringUtils.isNumeric(pageNo)) {
  212. pNo = Integer.parseInt(pageNo);
  213. }
  214. res.setData(demandService.selectOrgDemandManageList(employerName, auditStatus, province, serialNumber, name, keyword,
  215. infoSources, demandType, validityPeriodStartDate, validityPeriodEndDate, unitName, status,
  216. releaseStatus, releaseDateStartDate, releaseDateEndDate, pNo, pSize));
  217. return res;
  218. }
  219. /**
  220. * 新增需求
  221. */
  222. @RequestMapping(value = "/apply", method = RequestMethod.POST)
  223. public Result userApply(@Valid InputDemand demand, BindingResult bindingResult,
  224. @RequestParam(name = "keywords[]", required = false) String[] keywords,
  225. String validityPeriodFormattedDate) {
  226. Result res = new Result();
  227. if (bindingResult.hasErrors()) {
  228. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  229. DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
  230. return res;
  231. }
  232. if (StringUtils.isBlank(demand.getEmployerId()) && StringUtils.isBlank(demand.getEmployerName())){
  233. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求雇主", "需求雇主"));
  234. return res;
  235. }
  236. res = disposeDemand(res, demand, keywords);
  237. if (!res.getError().isEmpty()) {
  238. return res;
  239. }
  240. Demand d = new Demand();
  241. BeanUtils.copyProperties(demand, d);
  242. demandService.saveUserDemand(d, validityPeriodFormattedDate, keywords);
  243. return res;
  244. }
  245. /**
  246. * 个人需求详情
  247. */
  248. @RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
  249. public Result userDemandDetail(String id) {
  250. Result res = new Result();
  251. if (StringUtils.isBlank(id)) {
  252. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  253. return res;
  254. }
  255. res.setData(demandService.selectUserDemandDetail(id));
  256. return res;
  257. }
  258. /**
  259. * 组织用户详情
  260. */
  261. @RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
  262. public Result orgDemandDetail(String id) {
  263. Result res = new Result();
  264. if (StringUtils.isBlank(id)) {
  265. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  266. return res;
  267. }
  268. res.setData(demandService.selectOrgDemandDetail(id));
  269. return res;
  270. }
  271. /**
  272. * 需求管理--获取个人用户下拉
  273. */
  274. @RequestMapping(value = "/userNames", method = RequestMethod.GET)
  275. public Result getUserNames() {
  276. Result res = new Result();
  277. res.setData(userService.selectDemandUserNames());
  278. return res;
  279. }
  280. /**
  281. * 需求管理--获取组织用户下拉
  282. */
  283. @RequestMapping(value = "/unitNames", method = RequestMethod.GET)
  284. public Result getUnitNames() {
  285. Result res = new Result();
  286. res.setData(userService.selectDemandUnitNames());
  287. return res;
  288. }
  289. /**
  290. * 需求资料--图片上传
  291. */
  292. @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
  293. public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
  294. Result res = new Result();
  295. if (StringUtils.isBlank(uid)) {
  296. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
  297. return res;
  298. }
  299. AttachmentType attachmentType = AttachmentType.getField(sign);
  300. if (attachmentType == AttachmentType.DEMAND_PICTURE) {
  301. res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
  302. } else {
  303. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  304. }
  305. return res;
  306. }
  307. /**
  308. * 需求资料--文本文件上传
  309. */
  310. @RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
  311. public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
  312. Result res = new Result();
  313. if (StringUtils.isBlank(uid)) {
  314. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
  315. return res;
  316. }
  317. AttachmentType attachmentType = AttachmentType.getField(sign);
  318. if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
  319. res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
  320. } else {
  321. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  322. }
  323. return res;
  324. }
  325. /**
  326. * 修改需求
  327. */
  328. @RequestMapping(value = "/update", method = RequestMethod.POST)
  329. public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult, Integer switchSign,
  330. @RequestParam(name = "keywords[]", required = false) String[] keywords,
  331. String validityPeriodFormattedDate) {
  332. Result res = new Result();
  333. if (bindingResult.hasErrors()) {
  334. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  335. DemandFields.getFieldDesc(bindingResult.getFieldError().getField())));
  336. return res;
  337. }
  338. if (StringUtils.isBlank(demand.getId())) {
  339. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  340. return res;
  341. }
  342. if (StringUtils.isBlank(demand.getEmployerId()) && StringUtils.isBlank(demand.getEmployerName())){
  343. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求雇主", "需求雇主"));
  344. return res;
  345. }
  346. if (!DemandSwitchSign.CLOSE.getCode().equals(switchSign)
  347. && !DemandSwitchSign.OPEN.getCode().equals(switchSign)) {
  348. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "开关标记"));
  349. return res;
  350. }
  351. if (!DemandAuditStatus.CREATE.getCode().equals(demand.getAuditStatus())
  352. && !DemandAuditStatus.SUBMIT.getCode().equals(demand.getAuditStatus())
  353. && !DemandAuditStatus.UNAUDITED.getCode().equals(demand.getAuditStatus())) {
  354. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "当前状态无法提交审核!"));
  355. return res;
  356. }
  357. res = disposeDemand(res, demand, keywords);
  358. if (!res.getError().isEmpty()) {
  359. return res;
  360. }
  361. Demand d = new Demand();
  362. BeanUtils.copyProperties(demand, d);
  363. res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords, switchSign));
  364. return res;
  365. }
  366. /**
  367. * 需求撤消发布(下架)
  368. */
  369. @RequestMapping(value = "/offShelf", method = RequestMethod.POST)
  370. public Result offShelf(String id) {
  371. Result res = new Result();
  372. if (StringUtils.isBlank(id)) {
  373. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  374. return res;
  375. }
  376. Demand d = demandService.selectByPrimaryKey(id);
  377. if (null == d) {
  378. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  379. return res;
  380. }
  381. res.setData(demandService.updateReleaseStatus(d));
  382. return res;
  383. }
  384. /**
  385. * 下载需求文件--文本文件
  386. */
  387. @RequestMapping(value = "/download", method = RequestMethod.GET)
  388. public Result download(HttpServletResponse response, String id) {
  389. Result res = new Result();
  390. if (StringUtils.isEmpty(id)) {
  391. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  392. return res;
  393. }
  394. Demand d = demandService.selectByPrimaryKey(id);
  395. if (null == d) {
  396. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  397. return res;
  398. }
  399. downloadUnPrivateFile(response, d.getTextFileDownloadFileName(), d.getTextFileUrl());
  400. return res;
  401. }
  402. /**
  403. * 删除需求(个人&团体)
  404. */
  405. @RequestMapping(value = "/delete", method = RequestMethod.POST)
  406. public Result delete(@RequestParam(name = "ids[]", required = false) String[] ids) {
  407. Result res = new Result();
  408. if (ids == null || ids.length != 1) {
  409. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  410. } else {
  411. List<DemandOrder> list = demandOrderService.selectDemandOrderByDemandId(ids[0]);
  412. for (DemandOrder order : list) {
  413. if (!DemandOrderStatus.CREATE.getCode().equals(order.getStatus())) {
  414. res.getError().add(buildError("", "当前科技需求有订单,无法删除!"));
  415. return res;
  416. }
  417. }
  418. res.setData(demandService.deleteByPrimaryKey(Arrays.asList(ids)));
  419. }
  420. return res;
  421. }
  422. private Result disposeDemand(Result res, InputDemand demand, String[] keywords) {
  423. if (StringUtils.isBlank(demand.getName())) {
  424. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
  425. return res;
  426. }
  427. if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())
  428. && !DemandDataCategory.ORGDEMAND.getCode().equals(demand.getDataCategory())) {
  429. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "数据类型"));
  430. return res;
  431. }
  432. if (StringUtils.isBlank(demand.getKeyword())) {
  433. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  434. return res;
  435. }
  436. if (null == keywords || keywords.length < 1) {
  437. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
  438. return res;
  439. }
  440. if (null == demand.getInfoSources()) {
  441. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到信息来源", "信息来源"));
  442. return res;
  443. }
  444. if (null == demand.getIndustryCategoryA()) {
  445. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到行业类别", "行业类别"));
  446. return res;
  447. }
  448. if (null == demand.getDemandType()) {
  449. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求类型", "需求类型"));
  450. return res;
  451. }
  452. if (StringUtils.isBlank(demand.getProblemDes())) {
  453. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到问题说明", "问题说明"));
  454. return res;
  455. }
  456. for (int i = 0; i < keywords.length; i++) {
  457. if (AFTConstants.KEYWORDLENTH < keywords[i].length()) {
  458. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "关键词长度"));
  459. return res;
  460. }
  461. }
  462. return res;
  463. }
  464. private String handleFile(Result res, HttpServletRequest req, String fileName, List<MultipartFile> files,
  465. MultipartFile mf) {
  466. if (!files.isEmpty()) {
  467. try {
  468. mf.transferTo(toAdminPrivateFile(fileName));
  469. LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
  470. } catch (IllegalStateException | IOException e) {
  471. LoggerUtils.error(getClass(), "文件上传失败", e);
  472. res.getError().add(buildError("", "文件上传失败!"));
  473. return "";
  474. }
  475. } else {
  476. res.getError().add(buildError("", "文件上传失败!"));
  477. return "";
  478. }
  479. return fileName;
  480. }
  481. private Result disposeImportDemand(Result res, List<DemandImportBo> data) {
  482. Field[] field = DemandImportBo.class.getDeclaredFields();
  483. for (DemandImportBo bo : data) {
  484. for (Field f : field) {
  485. try {
  486. Object fo = f.get(bo);
  487. f.setAccessible(true);
  488. String fn = f.getName();
  489. if (!fn.equals("keywords") && (fo == null || "".equals(fo))) {
  490. res.getError().add(
  491. buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", DemandImportFields.getFieldDesc(fn)));
  492. return res;
  493. }
  494. } catch (IllegalArgumentException | IllegalAccessException e) {
  495. }
  496. }
  497. String[] keywords = bo.getKeyword().trim().split(",|,");
  498. if (null == keywords || keywords.length < 1) {
  499. res.getError()
  500. .add(buildError(ErrorConstants.PARAM_ERROR, "", AchievementImportFields.KEYWORD.getDesc()));
  501. return res;
  502. }
  503. List<String> list = new ArrayList<>();
  504. for (String s : keywords) {
  505. if (!StringUtils.isBlank(s)) {
  506. list.add(s.trim());
  507. }
  508. }
  509. bo.setKeywords(list);
  510. }
  511. res.setData(data);
  512. return res;
  513. }
  514. }