|
@@ -0,0 +1,137 @@
|
|
|
+package com.jpsoft.smart.modules.mobile.controller;
|
|
|
+
|
|
|
+import com.jpsoft.smart.config.OSSConfig;
|
|
|
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
+import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.ValueOperations;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/personInfoApi")
|
|
|
+public class PersonInfoApiController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ValueOperations<String, Object> valueOperations;
|
|
|
+
|
|
|
+ @PostMapping("findByNameAndPhone")
|
|
|
+ @ApiOperation(value="通过姓名和手机号查询人员")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="name",value = "照片名称",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "phone",value = "电话号码", required = true,paramType="form")
|
|
|
+ })
|
|
|
+ public MessageResult<PersonInfo> findByNameAndPhone(String name,String phone){
|
|
|
+ MessageResult<PersonInfo> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ PersonInfo personInfo = personInfoService.findByNameAndPhone(name, phone);
|
|
|
+
|
|
|
+ messageResult.setData(personInfo);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("findByOpenId")
|
|
|
+ @ApiOperation(value="通过openId查询人员")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="openId",value = "微信openId",required = true,paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<PersonInfo> findByOpenId(String openId){
|
|
|
+ MessageResult<PersonInfo> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ PersonInfo personInfo = personInfoService.findByOpenId(openId);
|
|
|
+
|
|
|
+ messageResult.setData(personInfo);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("getVerifyCode")
|
|
|
+ @ApiOperation(value="获取验证码")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="personId",value = "人员编号",required = true,paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<String> getVerifyCode(Long personId){
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ if(!personInfoService.exist(personId)){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String code = "";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(code);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("mobile/upload")
|
|
|
+ @ApiOperation(value="人员照片上传")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="photoName",value = "照片名称",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
|
|
|
+ })
|
|
|
+ public MessageResult<String> upload(String photoName, MultipartFile photoFile){
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ String retFileUrl = OSSUtil.upload(ossConfig,"/person",photoName,photoFile.getInputStream());
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setData(retFileUrl);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
+
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+}
|