WxController.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. package com.boot.security.server.controller;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.PostMapping;
  8. import org.springframework.web.bind.annotation.RequestBody;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import org.springframework.web.multipart.MultipartFile;
  14. import com.alibaba.fastjson.JSON;
  15. import com.alibaba.fastjson.JSONObject;
  16. import com.boot.security.server.annotation.LogAnnotation;
  17. import com.boot.security.server.dao.CusSelfInfoDao;
  18. import com.boot.security.server.dao.TCertificateDao;
  19. import com.boot.security.server.dao.TServiceHisDao;
  20. import com.boot.security.server.dao.TWorkHisDao;
  21. import com.boot.security.server.model.CusSelfInfo;
  22. import com.boot.security.server.service.CusService;
  23. import com.boot.security.server.service.ResumeService;
  24. import com.boot.security.server.service.WxService;
  25. import com.boot.security.server.utils.BaseController;
  26. import io.swagger.annotations.Api;
  27. import io.swagger.annotations.ApiImplicitParam;
  28. import io.swagger.annotations.ApiImplicitParams;
  29. import io.swagger.annotations.ApiOperation;
  30. /**
  31. * 微信小程序相关接口
  32. *
  33. * @author mdd
  34. *
  35. */
  36. @Api(tags = "微信")
  37. @RestController
  38. @RequestMapping("/wx")
  39. public class WxController extends BaseController{
  40. private static final Logger log = LoggerFactory.getLogger("adminLogger");
  41. @Autowired
  42. private WxService wxService;
  43. @Autowired
  44. private CusService cusService;
  45. @Autowired
  46. private ResumeService resumeService;
  47. @Autowired
  48. private TCertificateDao tCertificateDao;
  49. @Autowired
  50. private TServiceHisDao tServiceHisDao;
  51. @Autowired
  52. private CusSelfInfoDao cusSelfInfoDao;
  53. @Autowired
  54. private TWorkHisDao tWorkHisDao;
  55. @LogAnnotation
  56. @PostMapping("/saveCusSelfInfo")
  57. @ApiOperation(value = "用户基本信息保存(修改)接口")
  58. public String saveCusSelfInfo(@RequestBody String json) {
  59. // 微信用户基本信息保存接口
  60. log.info("微信用户基本信息保存接口>>>>>>>>>>>"+json);
  61. return cusService.saveCus(json);
  62. }
  63. @LogAnnotation
  64. @PostMapping("/createQRCode")
  65. @ApiOperation(value = "生成二维码")
  66. public String createQRCode(@RequestBody String json) {
  67. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  68. JSONObject jo=JSONObject.parseObject(json);
  69. String path = jo.getString("path");
  70. String width = jo.getString("width");
  71. String scene = jo.getString("scene");
  72. paramMap.put("openId", jo.getString("openid"));
  73. paramMap.put("token", jo.getString("token"));
  74. paramMap.put("path", path);
  75. paramMap.put("width", width);
  76. paramMap.put("scene", scene);
  77. // 微信服务鉴权
  78. String auth = wxService.commenAuth(paramMap);
  79. JSONObject jsonObject = JSON.parseObject(auth);
  80. if(!"0".equals((String)jsonObject.get("code"))) {
  81. return auth;
  82. }
  83. log.info("前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  84. return wxService.createQRCode(path,width,scene);
  85. }
  86. @LogAnnotation
  87. @PostMapping("/login")
  88. @ApiOperation(value = "微信用户登录",notes="前端通过临时登录凭证code获取session_key和openid等")
  89. @ApiImplicitParams({
  90. @ApiImplicitParam(name="json",value="临时登录凭证code",required=true,dataType="String",paramType="body")
  91. })
  92. public String login(@RequestBody String json) {
  93. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  94. JSONObject jo=JSONObject.parseObject(json);
  95. paramMap.put("code", jo.getString("code"));
  96. paramMap.put("encryptedData", jo.getString("encryptedData"));
  97. paramMap.put("iv", jo.getString("iv"));
  98. log.info("前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  99. return wxService.wxLogin(paramMap);
  100. }
  101. @LogAnnotation
  102. @PostMapping("/getVerifyCode")
  103. @ApiOperation(value = "获取短信验证码接口",notes="获取短信验证码")
  104. public String getVerifyCode(@RequestBody String json) {
  105. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  106. JSONObject jo=JSONObject.parseObject(json);
  107. paramMap.put("openId", jo.getString("openid"));
  108. paramMap.put("phone", jo.getString("mobile"));
  109. log.info("获取短信验证码接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  110. return wxService.getVerifyCode(paramMap);
  111. }
  112. @LogAnnotation
  113. @PostMapping("/bindMobile")
  114. @ApiOperation(value = "用户手机号绑定接口",notes="用户手机号绑定接口")
  115. public String bindMobile(@RequestBody String json) {
  116. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  117. JSONObject jo=JSONObject.parseObject(json);
  118. paramMap.put("iv",jo.getString("iv"));
  119. paramMap.put("sessionKey",jo.getString("sessionKey"));
  120. paramMap.put("encryptedData",jo.getString("encryptedData"));
  121. paramMap.put("openId", jo.getString("openid"));
  122. paramMap.put("token", jo.getString("token"));
  123. log.info("用户手机号绑定接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  124. return wxService.bindMobile(paramMap);
  125. }
  126. @LogAnnotation
  127. @ApiOperation(value = "上传文件接口",notes="上传文件接口")
  128. @RequestMapping(value="/uploadFile", method=RequestMethod.POST)
  129. public String uploadFile(@RequestParam("file") MultipartFile file,@RequestParam String openid,@RequestParam String token) throws Exception{
  130. //JSONObject jo=JSONObject.parseObject(json);
  131. return wxService.uploadFile(file,openid,token);
  132. }
  133. @LogAnnotation
  134. @PostMapping("/auditCheck")
  135. @ApiOperation(value = "大V认证接口",notes="大V认证接口")
  136. public String auditCheck(@RequestBody String json) throws Exception{
  137. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  138. JSONObject jo=JSONObject.parseObject(json);
  139. paramMap.put("openId", jo.getString("openid"));
  140. paramMap.put("token", jo.getString("token"));
  141. paramMap.put("picPath", jo.getString("picPath"));
  142. log.info("大V认证接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  143. return wxService.auditCheck(paramMap);
  144. }
  145. @LogAnnotation
  146. @PostMapping("/getDictByType")
  147. @ApiOperation(value = "根据类型获取字典列表",notes="根据类型获取字典列表")
  148. public String getDictByType(@RequestBody String json) throws Exception{
  149. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  150. JSONObject jo=JSONObject.parseObject(json);
  151. paramMap.put("openId", jo.getString("openid"));
  152. paramMap.put("token", jo.getString("token"));
  153. paramMap.put("type", jo.getString("type"));
  154. log.info("获取字典列表接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  155. return wxService.getDictByType(paramMap);
  156. }
  157. @LogAnnotation
  158. @PostMapping("/addCert")
  159. @ApiOperation(value = "添加证书接口",notes="添加证书接口")
  160. public String addCert(@RequestBody String json) throws Exception{
  161. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  162. JSONObject jo=JSONObject.parseObject(json);
  163. paramMap.put("openId", jo.getString("openid"));
  164. paramMap.put("token", jo.getString("token"));
  165. paramMap.put("certPath", jo.getString("certPath"));
  166. paramMap.put("certName", jo.getString("certName"));
  167. paramMap.put("id", jo.getString("id"));
  168. log.info("保存证书接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  169. return cusService.addCert(paramMap);
  170. }
  171. @LogAnnotation
  172. @PostMapping("/delCert")
  173. @ApiOperation(value = "删除证书接口",notes="删除证书接口")
  174. public String delCert(@RequestBody String json) throws Exception{
  175. Map<String,Object> resultMap = new HashMap<String,Object>();
  176. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  177. JSONObject jo=JSONObject.parseObject(json);
  178. paramMap.put("openId", jo.getString("openid"));
  179. paramMap.put("token", jo.getString("token"));
  180. paramMap.put("id", jo.getString("id"));
  181. log.info("删除证书接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  182. // 微信服务鉴权
  183. String auth = wxService.commenAuth(paramMap);
  184. JSONObject jsonObject = JSON.parseObject(auth);
  185. if(!"0".equals((String)jsonObject.get("code"))) {
  186. return auth;
  187. }
  188. int delete = tCertificateDao.delete(jo.getString("id"));
  189. if(1==delete) {
  190. // 证书删除成功
  191. resultMap.put("data", "");
  192. resultMap.put("code", "0");
  193. resultMap.put("msg", "删除成功");
  194. log.info("证书删除成功---------end-------");
  195. }else {
  196. // 证书删除失败
  197. resultMap.put("data", "");
  198. resultMap.put("code", "1");
  199. resultMap.put("msg", "删除失败");
  200. log.info("证书删除失败-----end-------");
  201. }
  202. return JSON.toJSONString(resultMap);
  203. }
  204. @LogAnnotation
  205. @PostMapping("/addSkill")
  206. @ApiOperation(value = "添加/修改技能接口",notes="添加/修改技能接口")
  207. public String addSkill(@RequestBody String json) throws Exception{
  208. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  209. JSONObject jo=JSONObject.parseObject(json);
  210. paramMap.put("openId", jo.getString("openid"));
  211. paramMap.put("token", jo.getString("token"));
  212. paramMap.put("skillCodes", jo.getString("skillCodes"));
  213. log.info("保存技能接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  214. return cusService.addSkill(paramMap);
  215. }
  216. @LogAnnotation
  217. @PostMapping("/detail")
  218. @ApiOperation(value = "我的简历/预览简历接口",notes="我的简历/预览简历接口")
  219. public String detail(@RequestBody String json) throws Exception{
  220. Map<String,Object> resultMap = new HashMap<String,Object>();
  221. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  222. JSONObject jo=JSONObject.parseObject(json);
  223. paramMap.put("openId", jo.getString("openid"));
  224. paramMap.put("token", jo.getString("token"));
  225. log.info("我的简历/预览简历接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  226. // 微信服务鉴权
  227. String auth = wxService.commenAuth(paramMap);
  228. JSONObject jsonObject = JSON.parseObject(auth);
  229. if(!"0".equals((String)jsonObject.get("code"))) {
  230. return auth;
  231. }
  232. CusSelfInfo byOpenId = cusSelfInfoDao.getByOpenId(jo.getString("openid"));
  233. if(byOpenId!=null) {
  234. return resumeService.getDetail(byOpenId.getId(),jo.getString("openid"));
  235. }else {
  236. resultMap.put("code", "1");
  237. resultMap.put("msg", "查询客户基本信息失败!");
  238. resultMap.put("data", "");
  239. }
  240. return JSON.toJSONString(resultMap);
  241. }
  242. @LogAnnotation
  243. @PostMapping("/addService")
  244. @ApiOperation(value = "添加服役履历接口",notes="添加服役履历接口")
  245. public String addService(@RequestBody String json) throws Exception{
  246. log.info("添加服役履历接口>>>>>>>>>>>"+json);
  247. return cusService.addService(json);
  248. }
  249. @LogAnnotation
  250. @PostMapping("/delService")
  251. @ApiOperation(value = "删除服役履历接口",notes="删除服役履历接口")
  252. public String delService(@RequestBody String json) throws Exception{
  253. Map<String,Object> resultMap = new HashMap<String,Object>();
  254. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  255. JSONObject jo=JSONObject.parseObject(json);
  256. paramMap.put("openId", jo.getString("openid"));
  257. paramMap.put("token", jo.getString("token"));
  258. paramMap.put("id", jo.getString("id"));
  259. log.info("删除服役履历接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  260. // 微信服务鉴权
  261. String auth = wxService.commenAuth(paramMap);
  262. JSONObject jsonObject = JSON.parseObject(auth);
  263. if(!"0".equals((String)jsonObject.get("code"))) {
  264. return auth;
  265. }
  266. int delete = tServiceHisDao.delete(jo.getString("id"));
  267. if(1==delete) {
  268. // 证书删除成功
  269. resultMap.put("data", "");
  270. resultMap.put("code", "0");
  271. resultMap.put("msg", "删除成功");
  272. log.info("服役履历删除成功---------end-------");
  273. }else {
  274. // 证书删除失败
  275. resultMap.put("data", "");
  276. resultMap.put("code", "1");
  277. resultMap.put("msg", "删除失败");
  278. log.info("服役履历删除失败-----end-------");
  279. }
  280. return JSON.toJSONString(resultMap);
  281. }
  282. @LogAnnotation
  283. @PostMapping("/addWork")
  284. @ApiOperation(value = "添加社会工作经历接口",notes="添加社会工作经历接口")
  285. public String addWork(@RequestBody String json) throws Exception{
  286. log.info("添加社会工作经历接口>>>>>>>>>>>"+json);
  287. return cusService.addWork(json);
  288. }
  289. @LogAnnotation
  290. @PostMapping("/delWork")
  291. @ApiOperation(value = "删除社会工作经历接口",notes="删除社会工作经历接口")
  292. public String delWork(@RequestBody String json) throws Exception{
  293. Map<String,Object> resultMap = new HashMap<String,Object>();
  294. HashMap<String,Object> paramMap = new HashMap<String,Object>();
  295. JSONObject jo=JSONObject.parseObject(json);
  296. paramMap.put("openId", jo.getString("openid"));
  297. paramMap.put("token", jo.getString("token"));
  298. paramMap.put("id", jo.getString("id"));
  299. log.info("删除社会工作经历接口--前台请求报文>>>>>>>>>>>"+JSON.toJSONString(paramMap));
  300. // 微信服务鉴权
  301. String auth = wxService.commenAuth(paramMap);
  302. JSONObject jsonObject = JSON.parseObject(auth);
  303. if(!"0".equals((String)jsonObject.get("code"))) {
  304. return auth;
  305. }
  306. int delete = tWorkHisDao.delete(jo.getString("id"));
  307. if(1==delete) {
  308. // 证书删除成功
  309. resultMap.put("data", "");
  310. resultMap.put("code", "0");
  311. resultMap.put("msg", "删除成功");
  312. log.info("删除社会工作经历成功---------end-------");
  313. }else {
  314. // 证书删除失败
  315. resultMap.put("data", "");
  316. resultMap.put("code", "1");
  317. resultMap.put("msg", "删除失败");
  318. log.info("删除社会工作经历失败-----end-------");
  319. }
  320. return JSON.toJSONString(resultMap);
  321. }
  322. }