Ver código fonte

增加人员信息查询方法。

zhengqiang 5 anos atrás
pai
commit
bc88ef8012

+ 7 - 3
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java

@@ -10,9 +10,13 @@ import com.jpsoft.smart.modules.common.dto.Sort;
 public interface PersonInfoDAO {
 	int insert(PersonInfo entity);
 	int update(PersonInfo entity);
-	int exist(String id);
-	PersonInfo get(String id);
-	int delete(String id);
+	int exist(Long id);
+	PersonInfo get(Long id);
+	int delete(Long id);
 	List<PersonInfo> list();
 	List<PersonInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+
+    PersonInfo findByNameAndPhone(String name, String phone);
+
+	PersonInfo findByOpenId(String openId);
 }

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonInfo.java

@@ -19,7 +19,7 @@ public class PersonInfo {
 	/**
 	 *编号
 	 */
-        @ApiModelProperty(value = "编号")
+	@ApiModelProperty(value = "编号")
 	private Long id;
 	/**
 	 *企业编号

+ 6 - 3
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonInfoService.java

@@ -7,11 +7,14 @@ import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.common.dto.Sort;
 
 public interface PersonInfoService {
-	PersonInfo get(String id);
-	boolean exist(String id);
+	PersonInfo get(Long id);
+	boolean exist(Long id);
 	int insert(PersonInfo model);
 	int update(PersonInfo model);
-	int delete(String id);
+	int delete(Long id);
 	List<PersonInfo> list();
 	Page<PersonInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
+
+    PersonInfo findByNameAndPhone(String name, String phone);
+	PersonInfo findByOpenId(String openId);
 }

+ 13 - 3
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonInfoServiceImpl.java

@@ -20,7 +20,7 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	private PersonInfoDAO personInfoDAO;
 
 	@Override
-	public PersonInfo get(String id) {
+	public PersonInfo get(Long id) {
 		// TODO Auto-generated method stub
 		return personInfoDAO.get(id);
 	}
@@ -40,13 +40,13 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	}
 
 	@Override
-	public int delete(String id) {
+	public int delete(Long id) {
 		// TODO Auto-generated method stub
 		return personInfoDAO.delete(id);
 	}
 
 	@Override
-	public boolean exist(String id) {
+	public boolean exist(Long id) {
 		// TODO Auto-generated method stub
 		int count = personInfoDAO.exist(id);
 		
@@ -67,4 +67,14 @@ public class PersonInfoServiceImpl implements PersonInfoService {
         
         return page;
 	}
+
+	@Override
+	public PersonInfo findByNameAndPhone(String name, String phone) {
+		return personInfoDAO.findByNameAndPhone(name,phone);
+	}
+
+	@Override
+	public PersonInfo findByOpenId(String openId) {
+		return personInfoDAO.findByOpenId(openId);
+	}
 }

+ 8 - 0
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -183,4 +183,12 @@
             ${sort.name} ${sort.order}
         </foreach>
     </select>
+    <select id="findByNameAndPhone" resultMap="PersonInfoMap">
+        select * from  base_person_info
+        where name_=#{name} and phone_=#{phone} limit 1
+    </select>
+    <select id="findByOpenId" resultMap="PersonInfoMap">
+        select * from  base_person_info
+        where open_id=#{openId} limit 1
+    </select>
 </mapper>

+ 10 - 0
lapi/src/main/resources/logback-spring.xml

@@ -11,6 +11,16 @@
             <charset>UTF-8</charset>
         </encoder>
     </appender>
+    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>D:\\Logs\\logfile.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>D:\\Logs\\logfile.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <MaxHistory>30</MaxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${pattern}</pattern>
+        </encoder>
+    </appender>
     <root level="WARN">
         <appender-ref ref="STDOUT" />
     </root>

+ 137 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -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;
+    }
+}

+ 12 - 4
web/src/main/resources/application.yml

@@ -131,11 +131,19 @@ doorApi:
   apiId: bl63d49fae22bf5cca
   apiKey: e52e545cb4d6c98a8a7e68b0718d3f63
 
+#oss:
+#  accessKeyId: LTAILGOo7bwpkvnq
+#  accessKeySecret: ZGsaTO5klbSHxULr2Q3s2PiqKDzN15
+#  endpoint: http://oss-cn-hangzhou.aliyuncs.com
+#  bucketName: wzzgh2out
+#  urlPrefix: http://vod.wzgh.org
+#  objectPre: smart
+
 oss:
-  accessKeyId: LTAILGOo7bwpkvnq
-  accessKeySecret: ZGsaTO5klbSHxULr2Q3s2PiqKDzN15
+  accessKeyId: LTAIXIyrXmjgOXQa
+  accessKeySecret: B0RS3zHLct8OKKIDu2HREaVx6RXgWL
   endpoint: http://oss-cn-hangzhou.aliyuncs.com
-  bucketName: wzzgh2out
-  urlPrefix: http://vod.wzgh.org
+  bucketName: rccs
+  urlPrefix: http://rccs.oss-cn-hangzhou.aliyuncs.com
   objectPre: smart