123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- package com.wechat.controller;
- import java.util.List;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.validation.Valid;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import com.wechat.common.Constants;
- import com.wechat.common.utils.StringsUtils;
- import com.wechat.global.base.BaseController;
- import com.wechat.global.message.InfoMsg;
- import com.wechat.model.dbEntity.MdeIntvContacts;
- import com.wechat.model.dbEntity.MdeUser;
- import com.wechat.model.dto.InterviewDetailDto;
- import com.wechat.model.dto.IntvContactsDto;
- import com.wechat.model.dto.WxBaseUserInfoDto;
- import com.wechat.model.requestDto.InterviewConfirmReq;
- import com.wechat.model.requestDto.InterviewCreateReq;
- import com.wechat.model.requestDto.InterviewHisReq;
- import com.wechat.model.requestDto.InterviewRefuseReq;
- import com.wechat.model.requestDto.InterviewUpdateReq;
- import com.wechat.model.responseDto.DPResp;
- import com.wechat.model.responseDto.ResultEntity;
- import com.wechat.model.responseDto.WxMiniCode2SessionResp;
- import com.wechat.service.CommonService;
- import com.wechat.service.InterviewService;
- import com.wechat.service.MdeUserService;
- import com.wechat.service.WeiXinProgService;
- /**
- * @author jadyn
- * @version 创建时间:2020年6月28日 下午4:32:51
- * 面试相关接口
- */
- @Controller
- @RequestMapping(value = "interview")
- public class InterviewController extends BaseController{
- @Resource
- private InterviewService intvService;
-
- @Resource
- private CommonService commonService;
- @Resource
- private WeiXinProgService wxProgService;
-
- @Resource
- private MdeUserService userService;
-
- /**
- * 提交面试邀请
- *
- * @param
- * @return
- */
- @RequestMapping(value = "createIntvInfo", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> createIntvInfo(@RequestBody @Valid InterviewCreateReq intvReq, HttpServletRequest request){
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
-
- //创建面试邀请信息
- int count = intvService.createIntv(request,intvReq,userCode);
- if(count == 0) {
- resp.setMsg(InfoMsg.ERROR_SAVE_FIELD);
- }
- return resp;
- }
-
- /**
- * 获取面试邀请信息
- *
- * @param
- * @return
- */
- @RequestMapping(value = "getIntvInfo", method = RequestMethod.GET)
- @ResponseBody
- public ResultEntity<InterviewDetailDto> getIntvInfo(@RequestParam String intvId, HttpServletRequest request) {
- ResultEntity<InterviewDetailDto> resp = new ResultEntity<InterviewDetailDto>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
- //获取当前登录用户的身份标识[0-个人;1-企业]
- String identityFlag = commonService.getIdentityFlag(request);
-
- String publisher = null;
- String interviewee = null;
-
- if(Constants.IDENTITY_P.equals(identityFlag))
- {
- interviewee = userCode;
- } else {
- publisher = userCode;
- }
-
- //获取面试邀请信息
- resp.setResult(intvService.getIntvDetail(publisher,interviewee,intvId));
- return resp;
- }
-
-
- /**
- * 修改联系人
- *
- * @param
- * @return
- */
- @RequestMapping(value = "updateContacts", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> updateContacts(@RequestBody MdeIntvContacts req, HttpServletRequest request) throws Exception {
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
-
- //修改联系人
- int count = intvService.updateContacts(req,userCode);
- if(count == 0) {
- resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
- }
- return resp;
- }
-
- /**
- * 获取联系人
- *
- * @param
- * @return
- */
- @RequestMapping(value = "getContacts", method = RequestMethod.GET)
- @ResponseBody
- public ResultEntity<List<IntvContactsDto>> getContacts(HttpServletRequest request) throws Exception {
- ResultEntity<List<IntvContactsDto>> resp = new ResultEntity<List<IntvContactsDto>>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
-
- //获取联系人列表
- resp.setResult(intvService.getContacts(userCode));
-
- return resp;
- }
-
- /**
- * 删除联系人
- *
- * @param
- * @return
- */
- @RequestMapping(value = "delContact", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> delContact(@RequestParam Integer contId, HttpServletRequest request) throws Exception {
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
-
- //修改联系人
- int count = intvService.delContact(contId,userCode);
- if(count < 1) {
- resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
- }
- return resp;
- }
-
- /**
- * 修改面试预约时间
- *
- * @param
- * @return
- */
- @RequestMapping(value = "updateIntvTimes", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> updateIntvTimes(@RequestBody @Valid InterviewUpdateReq intvUpdReq, HttpServletRequest request) {
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
-
- //获取当前登录用户的身份标识[0-个人;1-企业]
- String identityFlag = commonService.getIdentityFlag(request);
-
- //修改面试预约时间
- intvService.updateIntvTimes(intvUpdReq, userCode, identityFlag);
-
- //发送信息提示
- intvService.sendIntvChangeTimeMsg(intvUpdReq,identityFlag);
- return resp;
- }
-
- /**
- * 确认面试时间
- *
- * @param
- * @return
- */
- @RequestMapping(value = "confirmIntvTime", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> confirmIntvTime(@RequestBody @Valid InterviewConfirmReq confirmReq, HttpServletRequest request){
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
- //确认面试时间
- intvService.confirmIntvTime(confirmReq, userCode);
-
- // 发送通知(企业和个人)-异步处理
- // 个人用户信息
- MdeUser personUser = userService.getFullInfo(confirmReq.getInterviewee());
- // 企业用户信息
- MdeUser enterpriseUser = userService.getFullInfo(confirmReq.getPublisher());
-
- intvService.sendIntvConfirmMsgAsync(confirmReq,personUser,enterpriseUser);
- return resp;
- }
-
- /**
- * 拒绝面试
- *
- * @param
- * @return
- */
- @RequestMapping(value = "refuseIntv", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> refuseIntv(@RequestBody @Valid InterviewRefuseReq refuseReq, HttpServletRequest request){
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前登录用户
- String userCode = commonService.getUserCode(request);
- //拒绝面试
- int count = intvService.refuseIntv(refuseReq, userCode);
- if(count < 1) {
- resp.setMsg(InfoMsg.ERROR_DATA_UPDATE);
- } else {
- try {
- //发送信息
- intvService.sendRefuseIntvMsg(refuseReq,commonService.getUserInfo(userCode));
- } catch (Exception e) {
- log.error("*************拒绝面试信息发送异常*************",e);
- }
-
- }
- return resp;
- }
-
-
- /**
- * 获取拒绝理由下拉列表
- *
- */
- @RequestMapping(value = "getRefuseReasonList", method = RequestMethod.GET)
- @ResponseBody
- public ResultEntity<List<DPResp>> getRefuseReasonList() {
- ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
- List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
- rest.setResult(prepareFlagList);
- return rest;
- }
-
-
- /**
- * 获取视频面试时长
- *
- */
- @RequestMapping(value = "markIntvTimes", method = RequestMethod.GET)
- @ResponseBody
- public ResultEntity<List<DPResp>> markIntvTimes() {
- ResultEntity<List<DPResp>> rest = new ResultEntity<List<DPResp>>();
- List<DPResp> prepareFlagList = commonService.getDictByType("refuse_reasons",Constants.LANG_CN);
- rest.setResult(prepareFlagList);
- return rest;
- }
-
-
- /**
- * 记录使用记录-Start
- *
- * @param
- * @return
- */
- @RequestMapping(value = "setInterviewHis", method = RequestMethod.POST)
- @ResponseBody
- public ResultEntity<String> setInterviewHis(@RequestBody @Valid InterviewHisReq req, HttpServletRequest request) throws Exception {
- ResultEntity<String> resp = new ResultEntity<String>();
-
- //获取当前用户信息
- WxMiniCode2SessionResp wxResp = wxProgService.getJscodeToSession(req.getCode());
- if(StringsUtils.isEmpty(wxResp.getOpenid()))
- {
- //调用小程序登陆出错
- log.error("**************调用小程序登陆出错【jscode2session】【"+wxResp.getErrmsg()+"】*********************");
- resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
- } else {
- //缓存中获取openid等信息
- WxBaseUserInfoDto wxBUser = wxProgService.getSessionKey(wxResp.getOpenid());
- if (wxBUser == null)
- {
- //非登录小程序用户
- log.error("**************小程序非登录状态OpenId【"+wxResp.getOpenid()+"】*********************");
- resp.setMsg(InfoMsg.ERROR_AUZ_FAILED);
- } else {
- // 记录使用记录
- String usedId = intvService.setInterviewHis(req,wxBUser.getUserCode(),wxBUser.getIdentityFlag());
- resp.setResult(usedId);
- }
- }
- return resp;
- }
-
-
-
-
- }
|