Commit f22a2117 by huangjinxin

fix:用户密码初始化

feat:用户组织获取
1 parent 7f9608db
package com.dituhui.pea.pojo.user;
import lombok.Data;
import java.io.Serializable;
@Data
public class OrgInfo implements Serializable {
/**
* 机构id
*/
private Integer id;
/**
* 机构名称
*/
private String name;
}
...@@ -2,6 +2,7 @@ package com.dituhui.pea.user; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.user;
import com.dituhui.pea.common.PageResult; import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.pojo.*; import com.dituhui.pea.pojo.*;
import com.dituhui.pea.pojo.user.OrgInfo;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
...@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.ThirdPartyEnum; import com.dituhui.pea.enums.ThirdPartyEnum;
import java.util.List;
/** /**
* 用户相关接口 * 用户相关接口
* *
...@@ -162,4 +165,14 @@ public interface IUser { ...@@ -162,4 +165,14 @@ public interface IUser {
@RequestMapping(value = "/pea-user/ban", method = RequestMethod.POST) @RequestMapping(value = "/pea-user/ban", method = RequestMethod.POST)
Result<Boolean> ban(@RequestBody UserInfoSearch search); Result<Boolean> ban(@RequestBody UserInfoSearch search);
/**
* 获取用户组织
*
* @param userId 查询条件
* @return
*/
@RequestMapping(value = "/pea-user/orgs", method = RequestMethod.GET)
Result<List<OrgInfo>> orgs(String userId);
} }
...@@ -3,6 +3,8 @@ package com.dituhui.pea.user.controller; ...@@ -3,6 +3,8 @@ package com.dituhui.pea.user.controller;
import com.dituhui.pea.common.PageResult; import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.pojo.*; import com.dituhui.pea.pojo.*;
import com.dituhui.pea.pojo.user.OrgInfo;
import com.dituhui.pea.user.dao.UserOrgDao;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -16,6 +18,8 @@ import com.dituhui.pea.user.service.UserService; ...@@ -16,6 +18,8 @@ import com.dituhui.pea.user.service.UserService;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import java.util.List;
/** /**
* 用户控制层 * 用户控制层
*/ */
...@@ -91,9 +95,9 @@ public class UserController implements IUser { ...@@ -91,9 +95,9 @@ public class UserController implements IUser {
if (StringUtils.isBlank(userInfo.getAccount())) { if (StringUtils.isBlank(userInfo.getAccount())) {
return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null); return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null);
} }
if (StringUtils.isBlank(userInfo.getPassword())) { // if (StringUtils.isBlank(userInfo.getPassword())) {
return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null); // return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null);
} // }
return userService.saveUser(userInfo); return userService.saveUser(userInfo);
} }
...@@ -156,4 +160,10 @@ public class UserController implements IUser { ...@@ -156,4 +160,10 @@ public class UserController implements IUser {
return Result.success(true); return Result.success(true);
} }
@Override
public Result<List<OrgInfo>> orgs(String userId) {
List<OrgInfo> orgInfos = userService.orgs(userId);
return Result.success(orgInfos);
}
} }
...@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import java.util.List;
/** /**
* 用户组织关联表 * 用户组织关联表
*/ */
...@@ -17,7 +19,7 @@ public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpe ...@@ -17,7 +19,7 @@ public interface UserOrgDao extends JpaRepository<UserOrgEntity, String>, JpaSpe
* @param id * @param id
* @return * @return
*/ */
UserOrgEntity findByUserId(String id); List<UserOrgEntity> findByUserId(String userId);
void deleteByUserId(String userId); void deleteByUserId(String userId);
} }
...@@ -13,6 +13,7 @@ import javax.persistence.criteria.Predicate; ...@@ -13,6 +13,7 @@ import javax.persistence.criteria.Predicate;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dituhui.pea.common.PageResult; import com.dituhui.pea.common.PageResult;
import com.dituhui.pea.pojo.*; import com.dituhui.pea.pojo.*;
import com.dituhui.pea.pojo.user.OrgInfo;
import com.dituhui.pea.user.dao.*; import com.dituhui.pea.user.dao.*;
import com.dituhui.pea.user.entity.*; import com.dituhui.pea.user.entity.*;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
...@@ -294,7 +295,7 @@ public class UserService { ...@@ -294,7 +295,7 @@ public class UserService {
} }
UserEntity userEntity = BeanUtil.copyProperties(userInfo, UserEntity.class); UserEntity userEntity = BeanUtil.copyProperties(userInfo, UserEntity.class);
// 密码MD5加密 // 密码MD5加密
userEntity.setPassword(SecureUtil.md5(userInfo.getPassword())); userEntity.setPassword(SecureUtil.md5(userEntity.getPhone().substring(userEntity.getPhone().length() - 6)));
// 保存用户信息 // 保存用户信息
userEntity = userDao.save(userEntity); userEntity = userDao.save(userEntity);
userInfo.setId(userEntity.getId()); userInfo.setId(userEntity.getId());
...@@ -772,4 +773,17 @@ public class UserService { ...@@ -772,4 +773,17 @@ public class UserService {
userDao.save(byId); userDao.save(byId);
} }
} }
public List<OrgInfo> orgs(String userId) {
List<OrgInfo> orgInfos = new ArrayList<>();
List<UserOrgEntity> byUserId = userOrgDao.findByUserId(userId);
if (CollectionUtils.isEmpty(byUserId)) {
return orgInfos;
}
byUserId.forEach(e -> {
OrgInfo orgInfo = new OrgInfo();
orgInfo.setId(e.getOrgId());
});
return orgInfos;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!