InterviewController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. package com.wechat.controller;
  2. import java.util.List;
  3. import javax.annotation.Resource;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.validation.Valid;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.RequestBody;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import com.wechat.common.Constants;
  13. import com.wechat.common.utils.StringsUtils;
  14. import com.wechat.global.base.BaseController;
  15. import com.wechat.global.message.InfoMsg;
  16. import com.wechat.model.dbEntity.MdeIntvContacts;
  17. import com.wechat.model.dbEntity.MdeUser;
  18. import com.wechat.model.dto.InterviewDetailDto;
  19. import com.wechat.model.dto.IntvContactsDto;
  20. import com.wechat.model.dto.WxBaseUserInfoDto;
  21. import com.wechat.model.requestDto.InterviewConfirmReq;
  22. import com.wechat.model.requestDto.InterviewCreateReq;
  23. import com.wechat.model.requestDto.InterviewHisReq;
  24. import com.wechat.model.requestDto.InterviewRefuseReq;
  25. import com.wechat.model.requestDto.InterviewUpdateReq;
  26. import com.wechat.model.responseDto.DPResp;
  27. import com.wechat.model.responseDto.ResultEntity;
  28. import com.wechat.model.responseDto.WxMiniCode2SessionResp;
  29. import com.wechat.service.CommonService;
  30. import com.wechat.service.InterviewService;
  31. import com.wechat.service.MdeUserService;
  32. import com.wechat.service.WeiXinProgService;
  33. /**
  34. * @author jadyn
  35. * @version 创建时间:2020年6月28日 下午4:32:51
  36. * 面试相关接口
  37. */
  38. @Controller
  39. @RequestMapping(value = "interview")
  40. public class InterviewController extends BaseController{
  41. @Resource
  42. private InterviewService intvService;
  43. @Resource
  44. private CommonService commonService;
  45. @Resource
  46. private WeiXinProgService wxProgService;
  47. @Resource
  48. private MdeUserService userService;
  49. /**
  50. * 提交面试邀请
  51. *
  52. * @param
  53. * @return
  54. */
  55. @RequestMapping(value = "createIntvInfo", method = RequestMethod.POST)
  56. @ResponseBody
  57. public ResultEntity<String> createIntvInfo(@RequestBody @Valid InterviewCreateReq intvReq, HttpServletRequest request){
  58. ResultEntity<String> resp = new ResultEntity<String>();
  59. //获取当前登录用户
  60. String userCode = commonService.getUserCode(request);
  61. //创建面试邀请信息
  62. int count = intvService.createIntv(request,intvReq,userCode);
  63. if(count == 0) {
  64. resp.setMsg(InfoMsg.ERROR_SAVE_FIELD);
  65. }
  66. return resp;
  67. }
  68. /**
  69. * 获取面试邀请信息
  70. *
  71. * @param
  72. * @return
  73. */
  74. @RequestMapping(value = "getIntvInfo", method = RequestMethod.GET)
  75. @ResponseBody
  76. public ResultEntity<InterviewDetailDto> getIntvInfo(@RequestParam String intvId, HttpServletRequest request) {
  77. ResultEntity<InterviewDetailDto> resp = new ResultEntity<InterviewDetailDto>();
  78. //获取当前登录用户
  79. String userCode = commonService.getUserCode(request);
  80. //获取当前登录用户的身份标识[0-个人;1-企业]
  81. String identityFlag = commonService.getIdentityFlag(request);
  82. String publisher = null;
  83. String interviewee = null;
  84. if(Constants.IDENTITY_P.equals(identityFlag))
  85. {
  86. interviewee = userCode;
  87. } else {
  88. publisher = userCode;
  89. }
  90. //获取面试邀请信息
  91. resp.setResult(intvService.getIntvDetail(publisher,interviewee,intvId));
  92. return resp;
  93. }
  94. /**
  95. * 修改联系人
  96. *
  97. * @param
  98. * @return
  99. */
  100. @RequestMapping(value = "updateContacts", method = RequestMethod.POST)
  101. @ResponseBody
  102. public ResultEntity<String> updateContacts(@RequestBody MdeIntvContacts req, HttpServletRequest request) throws Exception {
  103. ResultEntity<String> resp = new ResultEntity<String>();
  104. //获取当前登录用户
  105. String userCode = commonService.getUserCode(request);
  106. //修改联系人
  107. int count = intvService.updateContacts(req,userCode);
  108. if(count == 0) {
  109. resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
  110. }
  111. return resp;
  112. }
  113. /**
  114. * 获取联系人
  115. *
  116. * @param
  117. * @return
  118. */
  119. @RequestMapping(value = "getContacts", method = RequestMethod.GET)
  120. @ResponseBody
  121. public ResultEntity<List<IntvContactsDto>> getContacts(HttpServletRequest request) throws Exception {
  122. ResultEntity<List<IntvContactsDto>> resp = new ResultEntity<List<IntvContactsDto>>();
  123. //获取当前登录用户
  124. String userCode = commonService.getUserCode(request);
  125. //获取联系人列表
  126. resp.setResult(intvService.getContacts(userCode));
  127. return resp;
  128. }
  129. /**
  130. * 删除联系人
  131. *
  132. * @param
  133. * @return
  134. */
  135. @RequestMapping(value = "delContact", method = RequestMethod.POST)
  136. @ResponseBody
  137. public ResultEntity<String> delContact(@RequestParam Integer contId, HttpServletRequest request) throws Exception {
  138. ResultEntity<String> resp = new ResultEntity<String>();
  139. //获取当前登录用户
  140. String userCode = commonService.getUserCode(request);
  141. //修改联系人
  142. int count = intvService.delContact(contId,userCode);
  143. if(count < 1) {
  144. resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
  145. }
  146. return resp;
  147. }
  148. /**
  149. * 修改面试预约时间
  150. *
  151. * @param
  152. * @return
  153. */
  154. @RequestMapping(value = "updateIntvTimes", method = RequestMethod.POST)
  155. @ResponseBody
  156. public ResultEntity<String> updateIntvTimes(@RequestBody @Valid InterviewUpdateReq intvUpdReq, HttpServletRequest request) {
  157. ResultEntity<String> resp = new ResultEntity<String>();
  158. //获取当前登录用户
  159. String userCode = commonService.getUserCode(request);
  160. //获取当前登录用户的身份标识[0-个人;1-企业]
  161. String identityFlag = commonService.getIdentityFlag(request);
  162. //修改面试预约时间
  163. intvService.updateIntvTimes(intvUpdReq, userCode, identityFlag);
  164. //发送信息提示
  165. intvService.sendIntvChangeTimeMsg(intvUpdReq,identityFlag);
  166. return resp;
  167. }
  168. /**
  169. * 确认面试时间
  170. *
  171. * @param
  172. * @return
  173. */
  174. @RequestMapping(value = "confirmIntvTime", method = RequestMethod.POST)
  175. @ResponseBody
  176. public ResultEntity<String> confirmIntvTime(@RequestBody @Valid InterviewConfirmReq confirmReq, HttpServletRequest request){
  177. ResultEntity<String> resp = new ResultEntity<String>();
  178. //获取当前登录用户
  179. String userCode = commonService.getUserCode(request);
  180. //确认面试时间
  181. intvService.confirmIntvTime(confirmReq, userCode);
  182. // 发送通知(企业和个人)-异步处理
  183. // 个人用户信息
  184. MdeUser personUser = userService.getFullInfo(confirmReq.getInterviewee());
  185. // 企业用户信息
  186. MdeUser enterpriseUser = userService.getFullInfo(confirmReq.getPublisher());
  187. intvService.sendIntvConfirmMsgAsync(confirmReq,personUser,enterpriseUser);
  188. return resp;
  189. }
  190. /**
  191. * 拒绝面试
  192. *
  193. * @param
  194. * @return
  195. */
  196. @RequestMapping(value = "refuseIntv", method = RequestMethod.POST)
  197. @ResponseBody
  198. public ResultEntity<String> refuseIntv(@RequestBody @Valid InterviewRefuseReq refuseReq, HttpServletRequest request){
  199. ResultEntity<String> resp = new ResultEntity<String>();
  200. //获取当前登录用户
  201. String userCode = commonService.getUserCode(request);
  202. //拒绝面试
  203. int count = intvService.refuseIntv(refuseReq, userCode);
  204. if(count < 1) {
  205. resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
  206. } else {
  207. try {
  208. //发送信息
  209. intvService.sendRefuseIntvMsg(refuseReq,commonService.getUserInfo(userCode));
  210. } catch (Exception e) {
  211. log.error("*************拒绝面试信息发送异常*************",e);
  212. }
  213. }
  214. return resp;
  215. }
  216. /**
  217. * 获取拒绝理由下拉列表
  218. *
  219. */
  220. @RequestMapping(value = "getRefuseReasonList", method = RequestMethod.GET)
  221. @ResponseBody
  222. public ResultEntity<List<DPResp>> getRefuseReasonList() {
  223. ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
  224. List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
  225. rest.setResult(prepareFlagList);
  226. return rest;
  227. }
  228. /**
  229. * 获取视频面试时长
  230. *
  231. */
  232. @RequestMapping(value = "markIntvTimes", method = RequestMethod.GET)
  233. @ResponseBody
  234. public ResultEntity<List<DPResp>> markIntvTimes() {
  235. ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
  236. List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
  237. rest.setResult(prepareFlagList);
  238. return rest;
  239. }
  240. /**
  241. * 记录使用记录-Start
  242. *
  243. * @param
  244. * @return
  245. */
  246. @RequestMapping(value = "setInterviewHis", method = RequestMethod.POST)
  247. @ResponseBody
  248. public ResultEntity<String> setInterviewHis(@RequestBody @Valid InterviewHisReq req, HttpServletRequest request) throws Exception {
  249. ResultEntity<String> resp = new ResultEntity<String>();
  250. //获取当前用户信息
  251. WxMiniCode2SessionResp wxResp = wxProgService.getJscodeToSession(req.getCode());
  252. if(StringsUtils.isEmpty(wxResp.getOpenid()))
  253. {
  254. //调用小程序登陆出错
  255. log.error("**************调用小程序登陆出错【jscode2session】【"+wxResp.getErrmsg()+"】*********************");
  256. resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
  257. } else {
  258. //缓存中获取openid等信息
  259. WxBaseUserInfoDto wxBUser = wxProgService.getSessionKey(wxResp.getOpenid());
  260. if (wxBUser == null)
  261. {
  262. //非登录小程序用户
  263. log.error("**************小程序非登录状态OpenId【"+wxResp.getOpenid()+"】*********************");
  264. resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
  265. } else {
  266. // 记录使用记录
  267. String usedId = intvService.setInterviewHis(req,wxBUser.getUserCode(),wxBUser.getIdentityFlag());
  268. resp.setResult(usedId);
  269. }
  270. }
  271. return resp;
  272. }
  273. }