PublicController.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. package com.goafanti.common.controller;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.OutputStream;
  7. import java.util.UUID;
  8. import javax.annotation.Resource;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.beans.factory.annotation.Value;
  14. import org.springframework.context.annotation.Scope;
  15. import org.springframework.stereotype.Controller;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.ResponseBody;
  19. import com.goafanti.achievement.service.AchievementService;
  20. import com.goafanti.admin.service.AftFileService;
  21. import com.goafanti.common.bo.Result;
  22. import com.goafanti.common.constant.ErrorConstants;
  23. import com.goafanti.common.enums.UserType;
  24. import com.goafanti.common.model.User;
  25. import com.goafanti.common.service.DistrictGlossoryService;
  26. import com.goafanti.common.service.FieldGlossoryService;
  27. import com.goafanti.common.service.IndustryCategoryService;
  28. import com.goafanti.common.utils.LoggerUtils;
  29. import com.goafanti.common.utils.MobileMessageUtils;
  30. import com.goafanti.common.utils.PasswordUtil;
  31. import com.goafanti.common.utils.PictureUtils;
  32. import com.goafanti.common.utils.TimeUtils;
  33. import com.goafanti.common.utils.VerifyCodeUtils;
  34. import com.goafanti.core.shiro.token.TokenManager;
  35. import com.goafanti.demand.bo.DemandListBo;
  36. import com.goafanti.demand.service.DemandService;
  37. import com.goafanti.portal.bo.AchievementObject;
  38. import com.goafanti.user.service.UserIdentityService;
  39. import com.goafanti.user.service.UserService;
  40. @Controller
  41. @Scope(value = "prototype")
  42. @RequestMapping("/open")
  43. public class PublicController extends BaseController {
  44. @Value(value = "${accessKey}")
  45. private String accessKey = null;
  46. @Value(value = "${accessSecret}")
  47. private String accessSecret = null;
  48. @Value(value = "${upload.path}")
  49. private String uploadPath = null;
  50. @Value(value = "${upload.private.path}")
  51. private String uploadPrivatePath = null;
  52. @Value(value = "${static.host}")
  53. private String staticHost = null;
  54. @Value(value = "${mobileCodeTemplate}")
  55. private String mobileCodeTemplate = null;
  56. @Resource
  57. private UserService userService;
  58. @Resource
  59. private AftFileService aftFileService;
  60. @Resource
  61. private FieldGlossoryService fieldGlossoryService;
  62. @Autowired
  63. private IndustryCategoryService industryCategoryService;
  64. @Autowired
  65. private DistrictGlossoryService districtGlossoryService;
  66. @Autowired
  67. private UserIdentityService userIdentityService;
  68. @Autowired
  69. private AchievementService achievementService;
  70. @Autowired
  71. private DemandService demandService;
  72. @Value(value = "${patentTemplate}")
  73. private String patentTemplate = null;
  74. @Resource(name = "passwordUtil")
  75. private PasswordUtil passwordUtil;
  76. /**
  77. * 获取验证码
  78. *
  79. * @param response
  80. */
  81. @RequestMapping(value = "/getVCode", method = RequestMethod.GET)
  82. public void getVCode(HttpServletResponse response, HttpServletRequest request) {
  83. try {
  84. response.setHeader("Pragma", "No-cache");
  85. response.setHeader("Cache-Control", "no-cache");
  86. response.setDateHeader("Expires", 0);
  87. response.setContentType("image/jpg");
  88. // 生成随机字串
  89. String verifyCode = VerifyCodeUtils.generateVerifyCode(4);
  90. // 存入Shiro会话session
  91. TokenManager.setVal2Session(VerifyCodeUtils.V_CODE, verifyCode.toLowerCase());
  92. // 生成图片
  93. int w = 146, h = 33;
  94. VerifyCodeUtils.outputImage(w, h, response.getOutputStream(), verifyCode);
  95. } catch (Exception e) {
  96. LoggerUtils.fmtError(getClass(), e, "获取验证码异常:%s", e.getMessage());
  97. }
  98. }
  99. /**
  100. * 手机验证码
  101. *
  102. * @param mobile
  103. * @param sign
  104. * 是否用与找回密码
  105. * @param type
  106. * @return
  107. */
  108. @RequestMapping(value = "/getMCode", method = RequestMethod.GET)
  109. @ResponseBody
  110. public Result getMcode(String mobile, boolean sign, String verificationCode) {
  111. Result res = new Result();
  112. // 用于找回密码
  113. if (sign) {
  114. if (null == userService.selectByMobieAndType(mobile.trim(),null)) {
  115. res.getError().add(buildError(ErrorConstants.NON_REGISTER, "", "该用户未注册!"));
  116. return res;
  117. }
  118. }
  119. /*if (!sign) {
  120. if (StringUtils.isBlank(verificationCode)) {
  121. res.getError().add(buildError(ErrorConstants.VCODE_EMPTY_ERROR, "", "图像验证码不能为空!"));
  122. return res;
  123. }
  124. if (!VerifyCodeUtils.verifyCode(verificationCode)) {
  125. res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "", "图形验证码输入错误!"));
  126. return res;
  127. }
  128. }
  129. */
  130. if (TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == null
  131. || TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == "") {
  132. sendMessage(mobile, res,VerifyCodeUtils.M_CODE);
  133. } else if (TimeUtils.checkOverTime("getMCode")) {
  134. VerifyCodeUtils.clearMobileCode();
  135. VerifyCodeUtils.clearMobileCodeTime();
  136. sendMessage(mobile, res,VerifyCodeUtils.M_CODE);
  137. } else {
  138. res.getError().add(buildError(ErrorConstants.MCODE_FREQUENCY_ERROR, "", "手机验证码发送频繁!"));
  139. }
  140. return res;
  141. }
  142. /**
  143. *
  144. * @param mobile
  145. * @param res
  146. * @return
  147. */
  148. private Result sendMessage(String mobile, Result res,String codeType) {
  149. String mobileVerifyCode = VerifyCodeUtils.generateMobileVerifyCode(6); // 生成随机字串
  150. if(VerifyCodeUtils.M_CODE.equals(codeType)){
  151. TokenManager.setVal2Session(VerifyCodeUtils.M_CODE, mobileVerifyCode);// 存入Shiro会话session
  152. TokenManager.setVal2Session(VerifyCodeUtils.M_CODE_TIME, System.currentTimeMillis());
  153. }else if(VerifyCodeUtils.RESET_CODE.equals(codeType)){
  154. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE, mobileVerifyCode);// 存入Shiro会话session
  155. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE_TIME, System.currentTimeMillis());
  156. }
  157. String paramString = "{\"code\":\"" + mobileVerifyCode + "\",\"product\":\"技淘网\"}";
  158. String ret = MobileMessageUtils.sendMessage(mobileCodeTemplate, paramString, mobile, accessKey, accessSecret);
  159. if (StringUtils.isNotBlank(ret)) {
  160. res.getError().add(buildError(ErrorConstants.M_CODE_ERROR));
  161. }
  162. return res;
  163. }
  164. /**
  165. * 下载图片
  166. *
  167. * @param response
  168. * @param path
  169. * @param request
  170. */
  171. @RequestMapping(value = "/downLoadPicture", method = RequestMethod.GET)
  172. public Result downLoadPicture(HttpServletResponse response, String path, HttpServletRequest request) {
  173. Result res = new Result();
  174. if (StringUtils.isBlank(path)) {
  175. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT));
  176. return res;
  177. }
  178. String filename = Long.toString(System.nanoTime()) + ".jpg";
  179. InputStream in = null;
  180. OutputStream out = null;
  181. byte[] buffer = new byte[8 * 1024];
  182. String fileSaveRootPath = "";
  183. try {
  184. fileSaveRootPath = uploadPrivatePath + path;
  185. File file = new File(fileSaveRootPath);
  186. in = new FileInputStream(file);
  187. out = response.getOutputStream();
  188. // 设置文件MIME类型
  189. response.setContentType("application/octet-stream");
  190. response.setHeader("Content-Disposition", "attachment; filename=" + filename);
  191. for (;;) {
  192. int bytes = in.read(buffer);
  193. if (bytes == -1) {
  194. break;
  195. }
  196. out.write(buffer, 0, bytes);
  197. }
  198. } catch (IOException e) {
  199. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  200. } finally {
  201. try {
  202. if (null != in) {
  203. in.close();
  204. }
  205. } catch (IOException e) {
  206. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  207. }
  208. try {
  209. if (null != out) {
  210. out.close();
  211. }
  212. } catch (IOException e) {
  213. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  214. }
  215. }
  216. return res;
  217. }
  218. /**
  219. * 删除图片文件(public图片)
  220. *
  221. * @param path
  222. * @return
  223. */
  224. @RequestMapping(value = "/deleteUploadPicture", method = RequestMethod.POST)
  225. public boolean deleteUploadPicture(String path) {
  226. boolean flag = false;
  227. path = uploadPath + path;
  228. File file = new File(path);
  229. // 判断目录或文件是否存在
  230. if (!file.exists() || !file.isFile()) { // 不存在返回 false
  231. return flag;
  232. } else {
  233. return file.delete();
  234. }
  235. }
  236. /**
  237. * 获取并输出private图片
  238. */
  239. @RequestMapping(value = "/writeImage", method = RequestMethod.GET)
  240. public void writeImage(HttpServletResponse response, HttpServletRequest request, String path) {
  241. try {
  242. String realPath = uploadPrivatePath + path;
  243. PictureUtils.outputImage(response, realPath);
  244. } catch (IOException e) {
  245. LoggerUtils.fmtError(getClass(), e, "获取图片异常:%s", e.getMessage());
  246. }
  247. }
  248. /**
  249. * 下载文件
  250. *
  251. * @param res
  252. * @param fileName
  253. * @param response
  254. * @param path
  255. * @param request
  256. * @return
  257. */
  258. @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
  259. public Result downloadFile(String fileName, HttpServletResponse response, String path) {
  260. Result res = new Result();
  261. return handleDownloadFile(response, fileName, path, res);
  262. }
  263. /**
  264. * 下载模版文件
  265. *
  266. * @param response
  267. * @return
  268. */
  269. @RequestMapping(value = "/downloadTemplateFile", method = RequestMethod.GET)
  270. public Result downloadTemplateFile(HttpServletResponse response, String sign) {
  271. Result res = new Result();
  272. String fileName = "";
  273. String path = aftFileService.selectAftFileBySign(sign).getFilePath();
  274. String suffix = path.substring(path.lastIndexOf("."));
  275. if (sign.equals("patent_prory_statement")) {
  276. fileName = "专利代理委托书模版" + suffix;
  277. } else {
  278. fileName = System.nanoTime() + " ";
  279. }
  280. if (!StringUtils.isBlank(path)) {
  281. return handleDownloadFile(response, fileName, path, res);
  282. } else {
  283. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "下载文件不存在!"));
  284. return res;
  285. }
  286. }
  287. private Result handleDownloadFile(HttpServletResponse response, String fileName, String path, Result res) {
  288. String fileSaveRootPath = uploadPrivatePath + path;
  289. InputStream in = null;
  290. OutputStream out = null;
  291. byte[] buffer = new byte[8 * 1024];
  292. try {
  293. File file = new File(fileSaveRootPath);
  294. in = new FileInputStream(file);
  295. out = response.getOutputStream();
  296. response.setContentType("multipart/form-data");
  297. fileName = java.net.URLEncoder.encode(fileName, "UTF-8");
  298. response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
  299. for (;;) {
  300. int bytes = in.read(buffer);
  301. if (bytes == -1) {
  302. break;
  303. }
  304. out.write(buffer, 0, bytes);
  305. }
  306. } catch (IOException e) {
  307. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  308. } finally {
  309. try {
  310. in.close();
  311. } catch (IOException e) {
  312. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  313. }
  314. try {
  315. out.close();
  316. } catch (IOException e) {
  317. LoggerUtils.fmtError(getClass(), e, "IO错误:%s", e.getMessage());
  318. }
  319. }
  320. return res;
  321. }
  322. @RequestMapping(value = "/findIndustryCategory", method = RequestMethod.GET)
  323. @ResponseBody
  324. public Result findIndustryCategory(String id, String noCache) {
  325. Integer pid = 0;
  326. if (StringUtils.isNumeric(id)) {
  327. try {
  328. pid = Integer.parseInt(id);
  329. } catch (Exception e) {
  330. pid = 0;
  331. }
  332. }
  333. if (StringUtils.isNotBlank(noCache)) {
  334. industryCategoryService.clear(pid);
  335. }
  336. return new Result().data(industryCategoryService.list(pid));
  337. }
  338. @RequestMapping(value = "/findDistrict", method = RequestMethod.GET)
  339. @ResponseBody
  340. public Result findDistrictGlossory(String id, String noCache) {
  341. Integer pid = 0;
  342. if (StringUtils.isNumeric(id)) {
  343. try {
  344. pid = Integer.parseInt(id);
  345. } catch (Exception e) {
  346. pid = 0;
  347. }
  348. }
  349. if (StringUtils.isNotBlank(noCache)) {
  350. districtGlossoryService.clear(pid);
  351. }
  352. return new Result().data(districtGlossoryService.list(pid));
  353. }
  354. /**
  355. *
  356. * @param mobileCode
  357. * @return
  358. */
  359. @RequestMapping(value = "/checkMCode", method = RequestMethod.POST)
  360. @ResponseBody
  361. public Result checkMCode(String mobileCode) {
  362. Result res = new Result();
  363. if (StringUtils.isBlank(mobileCode)) {
  364. res.getError().add(buildError(ErrorConstants.MCODE_EMPTY_ERROR, "", "手机验证码"));
  365. return res;
  366. }
  367. if (TimeUtils.checkOverTime(VerifyCodeUtils.M_CODE)) {
  368. res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "", "手机验证码超时失效!"));
  369. VerifyCodeUtils.clearMobileCode();
  370. VerifyCodeUtils.clearMobileCodeTime();
  371. return res;
  372. }
  373. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
  374. res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "", "手机验证码错误"));
  375. return res;
  376. }
  377. // resetCode
  378. if (res.getError().isEmpty()) {
  379. String resetCode = UUID.randomUUID().toString();
  380. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE, resetCode);
  381. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE_TIME, System.currentTimeMillis());
  382. res.setData(resetCode);
  383. }
  384. return res;
  385. }
  386. /**
  387. * 重置密码
  388. *
  389. * @param resetCode
  390. * @param mobile
  391. * @param type
  392. * @param newPwd
  393. * @return
  394. */
  395. @RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
  396. @ResponseBody
  397. public Result resetPwd(String resetCode, String mobile, Integer type, String newPwd) {
  398. Result res = new Result();
  399. if (TimeUtils.checkOverTime(VerifyCodeUtils.M_CODE)) {
  400. res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
  401. cleanCodeSession();
  402. return res;
  403. }
  404. if(null == TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE)){
  405. res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
  406. cleanCodeSession();
  407. return res;
  408. }else if(!TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE).equals(resetCode)){
  409. res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "", "验证码错误,请重新获取验证码!"));
  410. cleanCodeSession();
  411. return res;
  412. }
  413. if (StringUtils.isBlank(newPwd)) {
  414. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
  415. return res;
  416. }
  417. if (StringUtils.isBlank(mobile)) {
  418. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "mobile"));
  419. return res;
  420. }
  421. if (!UserType.ORGANIZATION.getCode().equals(type) && !UserType.PERSONAL.getCode().equals(type)) {
  422. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "type"));
  423. return res;
  424. }
  425. User user = userService.selectByMobieAndType(mobile, type);
  426. if (null == user) {
  427. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "mobile"));
  428. return res;
  429. }
  430. user.setPassword(newPwd);
  431. user.setPassword(passwordUtil.getEncryptPwd(user));
  432. userService.updateByPrimaryKeySelective(user);
  433. VerifyCodeUtils.clearResetCode();
  434. VerifyCodeUtils.clearResetCodeTime();
  435. return res;
  436. }
  437. @RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
  438. @ResponseBody
  439. public Result resetPassword(String userName,String newPwd,String resetCode) {
  440. Result res=new Result();
  441. if (TimeUtils.checkOverTime(VerifyCodeUtils.M_CODE)) {
  442. res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
  443. cleanCodeSession();
  444. return res;
  445. }
  446. if(null == TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE)){
  447. res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
  448. cleanCodeSession();
  449. return res;
  450. }else if(!TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE).equals(resetCode)){
  451. res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "", "验证码错误,请重新获取验证码!"));
  452. cleanCodeSession();
  453. return res;
  454. }
  455. if (StringUtils.isBlank(newPwd)) {
  456. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
  457. return res;
  458. }
  459. if (StringUtils.isBlank(userName)) {
  460. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户名"));
  461. return res;
  462. }
  463. User user=userService.selectByNameAndType(userName, null);
  464. user.setPassword(newPwd);
  465. userService.updateByPrimaryKeySelective(user);
  466. return res;
  467. }
  468. /**
  469. *
  470. * @param mobileCode
  471. * @return
  472. */
  473. @RequestMapping(value = "/checkMNCode", method = RequestMethod.POST)
  474. @ResponseBody
  475. public Result checkMNCode(String mobileCode,String userName,String mobile) {
  476. Result res = new Result();
  477. if (StringUtils.isBlank(mobileCode)) {
  478. res.getError().add(buildError(ErrorConstants.MCODE_EMPTY_ERROR, "", "手机验证码"));
  479. return res;
  480. }
  481. if (StringUtils.isBlank(mobile)) {
  482. res.getError().add(buildError(ErrorConstants.MCODE_EMPTY_ERROR, "", "手机号"));
  483. return res;
  484. }
  485. if (StringUtils.isBlank(userName)) {
  486. res.getError().add(buildError(ErrorConstants.MCODE_EMPTY_ERROR, "", "用户名"));
  487. return res;
  488. }
  489. if (TimeUtils.checkOverTime(VerifyCodeUtils.M_CODE)) {
  490. res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "", "手机验证码超时失效!"));
  491. VerifyCodeUtils.clearMobileCode();
  492. VerifyCodeUtils.clearMobileCodeTime();
  493. return res;
  494. }
  495. if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
  496. res.getError().add(buildError(ErrorConstants.MCODE_ERROR, "", "手机验证码错误"));
  497. return res;
  498. }
  499. User user=userService.selectByNameAndType(userName, null);
  500. if(user==null || user.getMobile()==null || !user.getMobile().equals(mobile))
  501. {
  502. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "手机号或用户名错误"));
  503. return res;
  504. }
  505. // resetCode
  506. if (res.getError().isEmpty()) {
  507. String resetCode = UUID.randomUUID().toString();
  508. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE, resetCode);
  509. TokenManager.setVal2Session(VerifyCodeUtils.RESET_CODE_TIME, System.currentTimeMillis());
  510. res.setData(resetCode);
  511. }
  512. return res;
  513. }
  514. private void cleanCodeSession() {
  515. VerifyCodeUtils.clearResetCode();
  516. VerifyCodeUtils.clearResetCodeTime();
  517. VerifyCodeUtils.clearMobileCode();
  518. VerifyCodeUtils.clearMobileCodeTime();
  519. }
  520. @RequestMapping(value = "/getRegisterMCode", method = RequestMethod.GET )
  521. @ResponseBody
  522. public Result getRegisterMCode(String mobile){
  523. Result res = new Result();
  524. if (TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == null
  525. || TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == "") {
  526. sendMessage(mobile, res,VerifyCodeUtils.M_CODE);
  527. } else if (TimeUtils.checkOverTime("getMCode")) {
  528. VerifyCodeUtils.clearMobileCode();
  529. VerifyCodeUtils.clearMobileCodeTime();
  530. sendMessage(mobile, res,VerifyCodeUtils.M_CODE);
  531. } else {
  532. res.getError().add(buildError(ErrorConstants.MCODE_FREQUENCY_ERROR, "", "手机验证码发送频繁!"));
  533. }
  534. return res;
  535. }
  536. @RequestMapping(value = "/getResetMCode", method = RequestMethod.GET )
  537. @ResponseBody
  538. public Result getResetMCode(String mobile, Integer type) {
  539. Result res = new Result();
  540. if (null == userService.selectByMobieAndType(mobile.trim(), type)) {
  541. res.getError().add(buildError(ErrorConstants.NON_REGISTER, "", "该用户未注册!"));
  542. return res;
  543. }
  544. if (TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE_TIME) == null
  545. || TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE_TIME) == "") {
  546. sendMessage(mobile, res,VerifyCodeUtils.RESET_CODE);
  547. } else if (TimeUtils.checkOverTime("resetCode")) {
  548. VerifyCodeUtils.clearMobileCode();
  549. VerifyCodeUtils.clearMobileCodeTime();
  550. sendMessage(mobile, res,VerifyCodeUtils.RESET_CODE);
  551. } else {
  552. res.getError().add(buildError(ErrorConstants.MCODE_FREQUENCY_ERROR, "", "手机验证码发送频繁!"));
  553. }
  554. return res;
  555. }
  556. /** 省市区查询 **/
  557. @RequestMapping(value = "/listAllProvince" , method = RequestMethod.POST)
  558. @ResponseBody
  559. public Result listAllProvince(){
  560. Result res = new Result();
  561. res.setData(districtGlossoryService.getProvince());
  562. return res;
  563. }
  564. @RequestMapping(value="/industryList", method = RequestMethod.GET)
  565. @ResponseBody
  566. public Result getIndustryList() {
  567. Result result=new Result();
  568. result.setData(userIdentityService.selectIndustryReletively());
  569. return result;
  570. }
  571. @RequestMapping(value="/achievementList", method = RequestMethod.GET)
  572. @ResponseBody
  573. public Result getAchievements(AchievementObject achievementObject,Integer pageNo,Integer pageSize) {
  574. Result result=new Result();
  575. result.setData(achievementService.getAchievementObjects(achievementObject, pageNo, pageSize));
  576. return result;
  577. }
  578. @RequestMapping(value="/demandList", method = RequestMethod.GET)
  579. @ResponseBody
  580. public Result getDemands(DemandListBo demandListBo,Integer pageNo,Integer pageSize) {
  581. Result result=new Result();
  582. result.setData(demandService.getDemandObjects(demandListBo, pageNo, pageSize));
  583. return result;
  584. }
  585. }