Commit 4f369cd6 authored by zsh's avatar zsh 🇨🇳

Merge branch 'Shen' into 'master'

Shen

See merge request !18
parents 24182b73 c30e13b6
...@@ -27,7 +27,7 @@ public class SwaggerConfig { ...@@ -27,7 +27,7 @@ public class SwaggerConfig {
@Bean @Bean
public Docket createRestApi() { public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
// .host("byyl.zjhmit.com") .host("byyl.zjhmit.com")
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.select() .select()
//加了ApiOperation注解的类,才生成接口文档 //加了ApiOperation注解的类,才生成接口文档
......
package io.hmit.controller; package io.hmit.controller;
import ch.qos.logback.core.pattern.ConverterUtil; import ch.qos.logback.core.pattern.ConverterUtil;
import com.alibaba.fastjson.JSON;
import io.hmit.annotation.Login; import io.hmit.annotation.Login;
import io.hmit.annotation.LoginUser; import io.hmit.annotation.LoginUser;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
...@@ -8,21 +9,23 @@ import io.hmit.common.utils.Result; ...@@ -8,21 +9,23 @@ import io.hmit.common.utils.Result;
import io.hmit.dto.OrgUserInfoDTO; import io.hmit.dto.OrgUserInfoDTO;
import io.hmit.dto.ServiceUserInfoDTO; import io.hmit.dto.ServiceUserInfoDTO;
import io.hmit.dto.UserInfoDTO; import io.hmit.dto.UserInfoDTO;
import io.hmit.dto.UserRegisterDTO;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO; import io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderEvaluationDTO;
import io.hmit.modules.serviceOrder.service.PensionOldFamilyService; import io.hmit.modules.serviceOrder.service.PensionOldFamilyService;
import io.hmit.service.UserService; import io.hmit.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List; import java.util.List;
/** /**
...@@ -75,4 +78,25 @@ public class UserController { ...@@ -75,4 +78,25 @@ public class UserController {
return new Result<ServiceUserInfoDTO>().ok(serviceUser); return new Result<ServiceUserInfoDTO>().ok(serviceUser);
} }
@GetMapping("checkIdCardNo")
@ApiOperation("注册身份证ID查询")
public Result<UserRegisterDTO> checkIdCardNo(@RequestParam("idCardNo") Long idCardNo){
UserRegisterDTO userRegisterDTO = userService.getUserInfoByIdCardNo(idCardNo);
return new Result<UserRegisterDTO>().ok(userRegisterDTO);
}
@PostMapping("registerUser")
@ApiOperation("注册用户")
public Result registerUser(@RequestBody String dto){
UserRegisterDTO userRegisterDTO = null;
try {
userRegisterDTO = JSON.parseObject(URLDecoder.decode(dto,"UTF-8"), UserRegisterDTO.class);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
userService.registerUser(userRegisterDTO);
return new Result();
}
} }
...@@ -3,6 +3,7 @@ package io.hmit.dao; ...@@ -3,6 +3,7 @@ package io.hmit.dao;
import io.hmit.common.dao.BaseDao; import io.hmit.common.dao.BaseDao;
import io.hmit.dto.OrgUserInfoDTO; import io.hmit.dto.OrgUserInfoDTO;
import io.hmit.dto.ServiceUserInfoDTO; import io.hmit.dto.ServiceUserInfoDTO;
import io.hmit.dto.UserRegisterDTO;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.UserRoleInfoDTO; import io.hmit.modules.serviceOrder.dto.UserRoleInfoDTO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -31,4 +32,6 @@ public interface UserDao extends BaseDao<UserEntity> { ...@@ -31,4 +32,6 @@ public interface UserDao extends BaseDao<UserEntity> {
List<UserRoleInfoDTO> getUserRoleInfo(Long userId); List<UserRoleInfoDTO> getUserRoleInfo(Long userId);
UserRegisterDTO getUserInfoByIdCardNo(Long idCardNo);
} }
package io.hmit.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author Eve
* @email mengmengeve@gmail.com
* @create 2021/1/27
*/
@Data
@ApiModel(value = "用户注册信息")
public class UserRegisterDTO {
@JsonIgnore
private Long id;
/**
* 用户名
*/
@ApiModelProperty(value = "姓名")
private String username;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String mobile;
/**
* 身份证号码
*/
@ApiModelProperty(value = "身份证号码")
private Long idCardNo;
/**
* 性别
*/
@ApiModelProperty(value = "性别")
private String gender;
/**
* 地址_地区
*/
@ApiModelProperty(value = "地址_地区")
private String addressArea;
/**
* 详细地址
*/
@ApiModelProperty(value = "详细地址")
private String address;
/**
* 所属社区Id
*/
@ApiModelProperty(value = "所属社区ID")
private Long communityId;
/**
* 所属社区名称
*/
@ApiModelProperty(value = "所属社区名称")
private String communityName;
/**
* 微信openid
*/
@ApiModelProperty(value = "微信openid")
private String openid;
/**
* 注册角色
*/
@ApiModelProperty(value = "注册角色")
private Long userRole;
}
...@@ -90,5 +90,9 @@ public class UserEntity implements Serializable { ...@@ -90,5 +90,9 @@ public class UserEntity implements Serializable {
* 所属社区Id * 所属社区Id
*/ */
private Long communityId; private Long communityId;
/**
* 身份证号码
*/
private Long idCardNo;
} }
...@@ -261,7 +261,7 @@ public class PensionOrderController { ...@@ -261,7 +261,7 @@ public class PensionOrderController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = "status", value = "订单状态: 0未接单 6待完成 3已取消 4待评价 留空全部", paramType = "query", dataType="int") , @ApiImplicitParam(name = "status", value = "订单状态: 6待完成 3已取消 4待评价 留空全部", paramType = "query", dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
}) })
......
...@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface RoleUserDao extends BaseDao<RoleUserEntity> { public interface RoleUserDao extends BaseDao<RoleUserEntity> {
} }
\ No newline at end of file
...@@ -31,16 +31,25 @@ public class PensionOldFamilyDTO implements Serializable { ...@@ -31,16 +31,25 @@ public class PensionOldFamilyDTO implements Serializable {
@ApiModelProperty(value = "家属id") @ApiModelProperty(value = "家属id")
private Long familyMemberId; private Long familyMemberId;
@ApiModelProperty(value = "家属姓名")
private String familyMemberName;
@ApiModelProperty(value = "家属与老人的关系") @ApiModelProperty(value = "家属与老人的关系")
private String familyMemberRole; private String familyMemberRole;
@ApiModelProperty(value = "性别")
private String gender;
@ApiModelProperty(value = "手机号") @ApiModelProperty(value = "手机号")
private String mobile; private String mobile;
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String idCardNo; private String idCardNo;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "地址_地区")
private String remark; private String addressArea;
@ApiModelProperty(value = "详细地址")
private String address;
} }
\ No newline at end of file
...@@ -12,4 +12,6 @@ import io.hmit.modules.serviceOrder.entity.RoleUserEntity; ...@@ -12,4 +12,6 @@ import io.hmit.modules.serviceOrder.entity.RoleUserEntity;
*/ */
public interface RoleUserService extends CrudService<RoleUserEntity, RoleUserDTO> { public interface RoleUserService extends CrudService<RoleUserEntity, RoleUserDTO> {
void addRelation(Long roleId, Long userId);
} }
\ No newline at end of file
...@@ -123,8 +123,10 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -123,8 +123,10 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
}else if (status != 6) { }else if (status != 6) {
list = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, status); list = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, status);
}else { }else {
List<PensionOrderDTO> list0 = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, 0);
List<PensionOrderDTO> list1 = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, 1); List<PensionOrderDTO> list1 = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, 1);
List<PensionOrderDTO> list2 = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, 5); List<PensionOrderDTO> list2 = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, 5);
list.addAll(list0);
list.addAll(list1); list.addAll(list1);
list.addAll(list2); list.addAll(list2);
} }
......
...@@ -33,4 +33,11 @@ public class RoleUserServiceImpl extends CrudServiceImpl<RoleUserDao, RoleUserEn ...@@ -33,4 +33,11 @@ public class RoleUserServiceImpl extends CrudServiceImpl<RoleUserDao, RoleUserEn
} }
@Override
public void addRelation(Long roleId, Long userId) {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setRoleId(roleId);
roleUserEntity.setUserId(userId);
insert(roleUserEntity);
}
} }
...@@ -2,10 +2,7 @@ package io.hmit.service; ...@@ -2,10 +2,7 @@ package io.hmit.service;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.service.BaseService; import io.hmit.common.service.BaseService;
import io.hmit.dto.LoginDTO; import io.hmit.dto.*;
import io.hmit.dto.OrgUserInfoDTO;
import io.hmit.dto.ServiceUserInfoDTO;
import io.hmit.dto.UserInfoDTO;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
...@@ -48,4 +45,8 @@ public interface UserService extends BaseService<UserEntity> { ...@@ -48,4 +45,8 @@ public interface UserService extends BaseService<UserEntity> {
ServiceUserInfoDTO getServiceUserByUserId(Long userId); ServiceUserInfoDTO getServiceUserByUserId(Long userId);
UserRegisterDTO getUserInfoByIdCardNo(Long idCardNo);
void registerUser(UserRegisterDTO dto);
} }
...@@ -9,24 +9,22 @@ import io.hmit.common.service.impl.BaseServiceImpl; ...@@ -9,24 +9,22 @@ import io.hmit.common.service.impl.BaseServiceImpl;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.validator.AssertUtils; import io.hmit.common.validator.AssertUtils;
import io.hmit.dao.UserDao; import io.hmit.dao.UserDao;
import io.hmit.dto.LoginDTO; import io.hmit.dto.*;
import io.hmit.dto.OrgUserInfoDTO;
import io.hmit.dto.ServiceUserInfoDTO;
import io.hmit.dto.UserInfoDTO;
import io.hmit.entity.TokenEntity; import io.hmit.entity.TokenEntity;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.UserRoleInfoDTO; import io.hmit.modules.serviceOrder.dto.UserRoleInfoDTO;
import io.hmit.modules.serviceOrder.service.PensionOldFamilyService; import io.hmit.modules.serviceOrder.service.PensionOldFamilyService;
import io.hmit.modules.serviceOrder.service.RoleUserService;
import io.hmit.service.TokenService; import io.hmit.service.TokenService;
import io.hmit.service.UserService; import io.hmit.service.UserService;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.ParseException;
import java.util.HashMap; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map; import java.util.stream.Collectors;
@Service @Service
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService { public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService {
...@@ -40,6 +38,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem ...@@ -40,6 +38,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Autowired @Autowired
private PensionOldFamilyService pensionOldFamilyService; private PensionOldFamilyService pensionOldFamilyService;
@Autowired
private RoleUserService roleUserService;
@Override @Override
public UserEntity getByMobile(String mobile) { public UserEntity getByMobile(String mobile) {
return baseDao.getUserByMobile(mobile); return baseDao.getUserByMobile(mobile);
...@@ -101,6 +102,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem ...@@ -101,6 +102,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
map.put("token", tokenEntity.getToken()); map.put("token", tokenEntity.getToken());
map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis()); map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
List<UserRoleInfoDTO> roles = userDao.getUserRoleInfo(user.getId()); List<UserRoleInfoDTO> roles = userDao.getUserRoleInfo(user.getId());
roles = roles.stream().distinct().collect(Collectors.toList());
map.put("roles", roles); map.put("roles", roles);
return map; return map;
...@@ -129,4 +131,55 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem ...@@ -129,4 +131,55 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return userDao.getServiceUserByUserId(userId); return userDao.getServiceUserByUserId(userId);
} }
@Override
public UserRegisterDTO getUserInfoByIdCardNo(Long idCardNo) {
return userDao.getUserInfoByIdCardNo(idCardNo);
}
@Override
public void registerUser(UserRegisterDTO dto) {
UserEntity reRegister = getByOpenId(dto.getOpenid());
if (null != reRegister) {
reRegister.setOpenid("");
updateById(reRegister);
}
UserRegisterDTO userRegisterDTO = getUserInfoByIdCardNo(dto.getIdCardNo());
UserEntity userEntity;
if (null != userRegisterDTO) {
userEntity = getUserByUserId(userRegisterDTO.getId());
userEntity.setOpenid(dto.getOpenid());
updateById(userEntity);
roleUserService.addRelation(dto.getUserRole(), userRegisterDTO.getId());
}else {
userEntity = new UserEntity();
userEntity.setUsername(dto.getUsername());
userEntity.setMobile(dto.getMobile());
userEntity.setPassword(DigestUtils.sha256Hex(dto.getIdCardNo().toString()));
userEntity.setAddress(dto.getAddress());
userEntity.setAddressArea(dto.getAddressArea());
userEntity.setCommunityId(dto.getCommunityId());
userEntity.setCreateDate(new Date());
userEntity.setIdCardNo(dto.getIdCardNo());
userEntity.setCommunityName(dto.getCommunityName());
userEntity.setHealthStatus("良好"); //TODO
String year = dto.getIdCardNo().toString().substring(6, 10);
String month = dto.getIdCardNo().toString().substring(10, 12);
String day = dto.getIdCardNo().toString().substring(12, 14);
String time = year+"-"+month+"-"+day;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
try {
date = sdf.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
userEntity.setBirthday(date);
userEntity.setGender(Integer.parseInt(dto.getIdCardNo().toString().substring(16, 17)) % 2 == 1 ? "男" : "女");
userEntity.setOpenid(dto.getOpenid());
insert(userEntity);
UserEntity byOpenId = getByOpenId(dto.getOpenid());
roleUserService.addRelation(dto.getUserRole(), byOpenId.getId());
}
}
} }
\ No newline at end of file
...@@ -39,4 +39,9 @@ ...@@ -39,4 +39,9 @@
WHERE tru.role_id = tr.id AND tru.user_id = #{userId}; WHERE tru.role_id = tr.id AND tru.user_id = #{userId};
</select> </select>
<select id="getUserInfoByIdCardNo" resultType="io.hmit.dto.UserRegisterDTO">
SELECT * FROM tb_user
WHERE tb_user.id_card_no = #{idCardNo};
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
</resultMap> </resultMap>
<select id="findByOldId" resultType="io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO"> <select id="findByOldId" resultType="io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO">
SELECT * FROM pension_old_family pof, tb_user tu SELECT tu.id, pof.old_id, pof.parent_role, pof.family_member_id, tu.username AS familyMemberName,
pof.family_member_role, tu.mobile, tu.id_card_no, tu.address_area, tu.address, tu.gender
FROM pension_old_family pof, tb_user tu
WHERE pof.family_member_id = tu.id and pof.old_id = #{oldId} WHERE pof.family_member_id = tu.id and pof.old_id = #{oldId}
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment