文章目录
总体设计
数据库设计
项目结构
服务器项目结构
客户端项目结构
项目代码
controller代码
CitizenIdentityApiContriller.java
- **** 身份逻辑验证之后,会返回相应的查询结构
- /此为本人自己查阅资料的劳动成果,转载请注明链接/
package com.mp.api.controller;
import com.mp.api.constant.InvokerEnum;
import com.mp.api.constant.OperationEnum;
import com.mp.api.dto.ResponseDTO;
import com.mp.api.entity.CitizenIdentity;
import com.mp.api.entity.Member;
import com.mp.api.service.CitizenIdentityService;
import com.mp.api.service.MemberService;
import com.mp.api.util.VerifyUtil;
import com.mp.api.vo.CitizenIdentityVO;
import com.mp.api.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.Objects;
/**
-
@ Author :MP…
-
@ Date :Created in 18:08 2019/6/28
-
@ Description:公民身份信息控制器
-
@ Modified By:
-
@Version: $
*/
@RestController
@RequestMapping("/citizen-identity")
@Api(value = “CitizenIdentityApiContriller”, tags = {“公民身份信息查询接口”})
public class CitizenIdentityApiContriller {@Autowired
private MemberService memberService;
@Autowired
private CitizenIdentityService citizenIdentityService;/**
- @Description: 根据公民姓名和身份证号查询身份信息
- @Param: [citizenIdentityVO]
- @return: ResponseDTO<ResponseVO>
- @Author: MP.
- @Date: 2019/6/28
*/
@RequestMapping(value = “”, method = {RequestMethod.GET, RequestMethod.POST})
@ApiOperation(value = “查询公民身份信息”, notes = “根据公民姓名和身份证号查询公民身份信息”)
public ResponseDTO<ResponseVO> getCitizenIdentity(@ApiParam(name = “citizenIdentityVO”, value = “公民身份查询参数对象”, required = true) @Valid CitizenIdentityVO citizenIdentityVO) {
//查询会员编号是否正确
Member member = memberService.getMemberByMemberNo(citizenIdentityVO.getMemberNo());
if (Objects.isNull(member)) {
return ResponseDTO.fail(InvokerEnum.AUTH_FAIL);
}
//检查签名
if (!VerifyUtil.checkSign(citizenIdentityVO, member.getSecretKey())) {
return ResponseDTO.fail(InvokerEnum.SIGN_FAIL);
}
//查询公民身份信息
CitizenIdentity citizenIdentity = citizenIdentityService.getCitizenIdentityByIdNo(citizenIdentityVO.getIdNo());
if (Objects.isNull(citizenIdentity)) {
return ResponseDTO.success(ResponseVO.fail(OperationEnum.NOT_EXISTS));
}
if (!Objects.equals(citizenIdentityVO.getName(), citizenIdentity.getName())) {
return ResponseDTO.success(ResponseVO.fail(OperationEnum.NOT_MATCH));
}
return ResponseDTO.success(ResponseVO.success(citizenIdentity));
}
}
service层代码
MemberServiceImpl.java
- ****;
- package com.mp.api.service.impl;
import com.mp.api.entity.Member;
import com.mp.api.mapper.MemberMapper;
import com.mp.api.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
-
@ Author :MP…
-
@ Date :Created in 15:03 2019/6/29
-
@ Description:身份信息服务接口
-
@ Modified By:
-
@Version: $
*/
@Service
public class MemberServiceImpl implements MemberService {@Autowired
private MemberMapper memberMapper;@Override
public Member getMemberByMemberNo(String memberNo) {
return memberMapper.getMemberByMemberNo(memberNo);
}
}
CitizenIdentityServiceImpl .java
/此为本人自己查阅资料的劳动成果,转载请注明链接/
package com.mp.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mp.api.entity.CitizenIdentity;
import com.mp.api.mapper.CitizenIdentityMapper;
import com.mp.api.service.CitizenIdentityService;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
-
@ Author :MP…
-
@ Date :Created in 18:55 2019/6/28
-
@ Description:公民身份信息服务实现类
-
@ Modified By:
-
@Version: $
*/
@Service
public class CitizenIdentityServiceImpl extends ServiceImpl<CitizenIdentityMapper, CitizenIdentity> implements CitizenIdentityService {
@Override
public CitizenIdentity getCitizenIdentityByIdNo(String idNo) {return baseMapper.getCitizenIdentityByIdNo(idNo);
}
}
dao层
CitizenIdentityMapper.java
- package com.mp.api.mapper;
import com.mp.api.entity.CitizenIdentity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
/**
-
@ Author :MP…
-
@ Date :Created in 18:31 2019/6/28
-
@ Description:公民身份信息 Mapper 接口
-
@ Modified By:
-
@Version: $
*/
public interface CitizenIdentityMapper extends BaseMapper {/**
- 根据身份证号查询身份信息
- @param idNo
- @return com.lx.api.entity.CitizenIdentity
- @author zhuwenbin
- @since 2019/3/1 14:52
*/
@Select(“select * from citizen_identity where id_no = #{idNo}”)
CitizenIdentity getCitizenIdentityByIdNo(String idNo);
}