|
@@ -109,7 +109,7 @@ public class UserController extends BaseController {
|
|
|
resultJson.put("userId", userEntity.getId());
|
|
|
resultJson.put("petName", userEntity.getPetName());
|
|
|
resultJson.put("phone", userEntity.getPhone());
|
|
|
- resultJson.put("modelPhone", userEntity.getModelPhone());
|
|
|
+ resultJson.put("model", userEntity.getModel());
|
|
|
resultJson.put("institutionNo", userEntity.getInstitutionNo());
|
|
|
resultJson.put("gId", userEntity.getGId());
|
|
|
resultJson.put("gender", userEntity.getGender());
|
|
@@ -138,316 +138,6 @@ public class UserController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //----------------------------公网版接口begin--------------------------------------------------------------------------------
|
|
|
-
|
|
|
- @SafetyProcess
|
|
|
- @GetMapping("/authCode")
|
|
|
- @ApiOperation(value = "向手机发送验证码")
|
|
|
- public Result authCode(String phone) {
|
|
|
- if (StringUtils.isEmpty(phone)) {
|
|
|
- return failBadRequest();
|
|
|
- } else {
|
|
|
- SendMessageUtil sendMessageUtil = new SendMessageUtil();
|
|
|
- String authCode = sendMessageUtil.sendMessage(phone);
|
|
|
- String beginTime = DateUtil.getNowTime(DateUtil.DEFAULT_FILE_DATE);
|
|
|
- // 创建返回的json对象
|
|
|
- JSONObject resultJson = new JSONObject(true);
|
|
|
- resultJson.put("beginTime", beginTime);
|
|
|
- resultJson.put("authCode", authCode);
|
|
|
- resultJson.put("phone", phone);
|
|
|
- return success(resultJson);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 公网版注册用户
|
|
|
- *
|
|
|
- * @param json
|
|
|
- * @return
|
|
|
- */
|
|
|
- @SafetyProcess
|
|
|
- @PostMapping("/saveUser1")
|
|
|
- @Deprecated
|
|
|
- @ApiOperation("公网版注册用户")
|
|
|
- public Result saveUserInfo(@RequestBody String json) throws Exception {
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonData = JSONObject.parseObject(data);
|
|
|
- String authCode = jsonData.getString("authCode");
|
|
|
- JSONObject jsonVerification = jsonData.getJSONObject("verification");
|
|
|
- String jsonPhone = jsonVerification.getString("phone");
|
|
|
- String jsonAuthCode = jsonVerification.getString("authCode");
|
|
|
- String jsonBeginTime = jsonVerification.getString("beginTime");
|
|
|
- JSONObject jsonUserEntity = jsonData.getJSONObject("data");
|
|
|
- UserEntity userEntity = jsonUserEntity.toJavaObject(UserEntity.class);
|
|
|
- userEntity.setInstitutionNo(Constant.WEB_INSTITUTION_CODE);
|
|
|
- userEntity.setInstitutionName(Constant.WEB_INSTITUTION_NAME);
|
|
|
- userEntity.setGId("0");
|
|
|
- userEntity.setModelPhone("0");
|
|
|
- userEntity.setUserStatus(UserStatus.PASS.getType());
|
|
|
- System.out.println(userEntity);
|
|
|
- if (StringUtils.isEmpty(authCode) || StringUtils.isEmpty( userEntity.getPhone() ) || StringUtils.isEmpty( userEntity.getPassword())
|
|
|
- || StringUtils.isEmpty( userEntity.getGender() ) || StringUtils.isEmpty(userEntity.getPetName())
|
|
|
- || StringUtils.isEmpty( userEntity.getBirthday())) {
|
|
|
- return fail("", "请按要求填写所需信息");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(jsonBeginTime) || StringUtils.isEmpty(jsonAuthCode) ) {
|
|
|
- return fail("", "请重新获取验证码");
|
|
|
- }
|
|
|
- //计算时间差---分钟
|
|
|
- int diff = DateUtil.getDistanceByUnit(DateUtil.parseDate(jsonBeginTime), DateUtil.getCurrentDate(), 2);
|
|
|
- if (diff < 0 || diff > 5) {
|
|
|
- return fail("", "验证码已失效");
|
|
|
- }
|
|
|
- if (jsonAuthCode.equals(authCode) && jsonPhone.equals(userEntity.getPhone())) {
|
|
|
- UserEntity userInfo = this.userService.findPhone(userEntity.getPhone());
|
|
|
- if (userInfo == null) {
|
|
|
- this.userService.save(userEntity);
|
|
|
- return success();
|
|
|
- } else {
|
|
|
- return fail("", "账号已注册");
|
|
|
- }
|
|
|
- } else {
|
|
|
- return fail("", "验证码错误");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @SafetyProcess
|
|
|
- @PostMapping("/webLogin1")
|
|
|
- @Deprecated
|
|
|
- @ApiOperation(value = "公网版用户登录")
|
|
|
- public Result webUserLogin(@RequestBody String json) throws Exception {
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
- if (!jsonObject.containsKey("phone") || !jsonObject.containsKey("password")) {
|
|
|
- return fail("", "手机号或密码不能为空");
|
|
|
- }
|
|
|
- String password = jsonObject.getString("password");
|
|
|
- String phone = jsonObject.getString("phone");
|
|
|
- if (StringUtils.isEmpty(password) || StringUtils.isEmpty(phone)) {
|
|
|
- return fail("", "手机号或密码不能为空");
|
|
|
- }
|
|
|
- UserEntity userEntity = this.userService.findPhone(phone);
|
|
|
- if (userEntity != null && userEntity.getPassword().equals(password)) {
|
|
|
- //生成token
|
|
|
- HashMap<String, String> payload = new HashMap<>();
|
|
|
- payload.put("userPhone", userEntity.getPhone());
|
|
|
- payload.put("userId", userEntity.getId());
|
|
|
- payload.put("petName", userEntity.getPetName());
|
|
|
- payload.put("groupId", userEntity.getGId());
|
|
|
- payload.put("institutionNo", userEntity.getInstitutionNo());
|
|
|
- payload.put("type", userEntity.getRoleType());
|
|
|
- String token = JWTUtil.getToken(payload);
|
|
|
- // 创建返回的json对象
|
|
|
- JSONObject resultJson = new JSONObject();
|
|
|
- resultJson.put("userId", userEntity.getId());
|
|
|
- resultJson.put("petName", userEntity.getPetName());
|
|
|
- resultJson.put("phone", userEntity.getPhone());
|
|
|
- resultJson.put("institutionNo", userEntity.getInstitutionNo());
|
|
|
- resultJson.put("gId", userEntity.getGId());
|
|
|
- resultJson.put("gender", userEntity.getGender());
|
|
|
- resultJson.put("birthday", userEntity.getBirthday());
|
|
|
- resultJson.put("profession", userEntity.getProfession());
|
|
|
- resultJson.put("modelPhone", userEntity.getModelPhone());
|
|
|
- resultJson.put("type", userEntity.getRoleType());
|
|
|
- resultJson.put("token", token);
|
|
|
- return success(resultJson);
|
|
|
- } else {
|
|
|
- return fail("", "手机号或密码错误");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 公网版忘记密码后修改密码
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @SafetyProcess
|
|
|
- @PostMapping("/webUpdatePassword1")
|
|
|
- @Deprecated
|
|
|
- @ApiOperation("公网版忘记密码后修改密码 --->forgotPassword")
|
|
|
- public Result webUpdatePassword(@RequestBody String json) throws Exception {
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonData = JSONObject.parseObject(data);
|
|
|
- String phone = jsonData.getString("phone");
|
|
|
- String password = jsonData.getString("password");
|
|
|
- String authCode = jsonData.getString("authCode");
|
|
|
- JSONObject jsonVerification = jsonData.getJSONObject("verification");
|
|
|
- String jsonPhone = jsonVerification.getString("phone");
|
|
|
- String jsonAuthCode = jsonVerification.getString("authCode");
|
|
|
- String jsonBeginTime = jsonVerification.getString("beginTime");
|
|
|
- if (authCode == null || phone == null || password == null) {
|
|
|
- return fail("", "请按要求填写所需信息");
|
|
|
- }
|
|
|
- UserEntity userEntity = this.userService.findPhone(phone);
|
|
|
- if (userEntity == null) {
|
|
|
- return fail("", "请先注册");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(jsonBeginTime ) || StringUtils.isEmpty(jsonAuthCode) ) {
|
|
|
- return fail("", "请重新获取验证码");
|
|
|
- }
|
|
|
- //计算时间差---分钟
|
|
|
- int diff = DateUtil.getDistanceByUnit(DateUtil.parseDate(jsonBeginTime), DateUtil.getCurrentDate(), 2);
|
|
|
- if (diff < 0 || diff > 5) {
|
|
|
- return fail("", "验证码已失效");
|
|
|
- }
|
|
|
- if (jsonAuthCode.equals(authCode) && jsonPhone.equals(phone)) {
|
|
|
- //this.userService.updatePassword(phone, password, "10009");
|
|
|
- return success();
|
|
|
- } else {
|
|
|
- return fail("", "验证码错误");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //----------------------------公网版接口end--------------------------------------------------------------------------------
|
|
|
-
|
|
|
- //----------------------------局域网版接口begin--------------------------------------------------------------------------------
|
|
|
-
|
|
|
- /**
|
|
|
- * 局域网注册用户
|
|
|
- *
|
|
|
- * @param json
|
|
|
- * @return
|
|
|
- */
|
|
|
- @SafetyProcess
|
|
|
- @Deprecated
|
|
|
- @PostMapping("/LANSaveUserInfo1")
|
|
|
- @ApiOperation("局域网注册用户")
|
|
|
- public Result LANSaveUserInfo(@RequestBody String json) throws Exception {
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonData = JSONObject.parseObject(data);
|
|
|
- JSONObject jsonUserEntity = jsonData.getJSONObject("data");
|
|
|
- UserEntity userEntity = jsonUserEntity.toJavaObject(UserEntity.class);
|
|
|
- userEntity.setInstitutionNo(Constant.LAN_INSTITUTION_CODE);
|
|
|
- userEntity.setInstitutionName(Constant.LAN_INSTITUTION_NAME);
|
|
|
- userEntity.setGId("0");
|
|
|
- userEntity.setModelPhone("0");
|
|
|
- userEntity.setUserStatus(UserStatus.PASS.getType());
|
|
|
- if (StringUtils.isEmpty(userEntity.getPhone()) || StringUtils.isEmpty( userEntity.getPassword())
|
|
|
- || StringUtils.isEmpty( userEntity.getGender()) || StringUtils.isEmpty( userEntity.getPetName())
|
|
|
- || StringUtils.isEmpty( userEntity.getBirthday()) ) {
|
|
|
- return fail("", "请按要求填写所需信息");
|
|
|
- }
|
|
|
- UserEntity userInfo = this.userService.findPhone(userEntity.getPhone());
|
|
|
- if (userInfo == null) {
|
|
|
- this.userService.save(userEntity);
|
|
|
- return success(userEntity);
|
|
|
- } else {
|
|
|
- return fail("", "手机号已注册");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @SafetyProcess
|
|
|
- @PostMapping("/LANLogin1")
|
|
|
- @Deprecated
|
|
|
- @ApiOperation(value = "局域网用户登录")
|
|
|
- public Result LANLogin(@RequestBody String json, @ApiIgnore HttpSession session) throws Exception {
|
|
|
-
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
- if (!jsonObject.containsKey("phone") || !jsonObject.containsKey("password") || !jsonObject.containsKey("type")) {
|
|
|
- return fail("", "账号或密码或用户类型不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- String password = (String) jsonObject.get("password");
|
|
|
- String phone = (String) jsonObject.get("phone");
|
|
|
- //type = 1 是普通用户;type = 2 是超级管理员
|
|
|
- String type = (String) jsonObject.get("type");
|
|
|
- if (password.equals("") || phone.equals("") || type.equals("")) {
|
|
|
- return fail("", "账号或密码或用户类型不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- if (type.equals("1")) {
|
|
|
- UserEntity userEntity = this.userService.findPhone(phone);
|
|
|
- if (userEntity != null && userEntity.getPassword().equals(password)) {
|
|
|
- //生成token
|
|
|
- HashMap<String, String> payload = new HashMap<>();
|
|
|
- payload.put("userPhone", userEntity.getPhone());
|
|
|
- payload.put("userId", userEntity.getId());
|
|
|
- payload.put("petName", userEntity.getPetName());
|
|
|
- payload.put("groupId", userEntity.getGId());
|
|
|
- payload.put("institutionNo", userEntity.getInstitutionNo());
|
|
|
- payload.put("type", "user");
|
|
|
- String token = JWTUtil.getToken(payload);
|
|
|
- // 创建返回的json对象
|
|
|
- JSONObject resultJson = new JSONObject();
|
|
|
- resultJson.put("userId", userEntity.getId());
|
|
|
- resultJson.put("petName", userEntity.getPetName());
|
|
|
- resultJson.put("phone", userEntity.getPhone());
|
|
|
- resultJson.put("institutionNo", userEntity.getInstitutionNo());
|
|
|
- resultJson.put("gId", userEntity.getGId());
|
|
|
- resultJson.put("gender", userEntity.getGender());
|
|
|
- resultJson.put("birthday", userEntity.getBirthday());
|
|
|
- resultJson.put("profession", userEntity.getProfession());
|
|
|
- resultJson.put("modelPhone", userEntity.getModelPhone());
|
|
|
- resultJson.put("type", "user");
|
|
|
- resultJson.put("token", token);
|
|
|
- return success(resultJson);
|
|
|
- } else {
|
|
|
- return fail("", "账号或密码错误");
|
|
|
- }
|
|
|
- } else {
|
|
|
- UserEntity byInstitutionNoAndLoginName = this.userService.findPhoneAndInstitutionNo( phone,"10010");
|
|
|
- if (byInstitutionNoAndLoginName != null) {
|
|
|
- //生成token
|
|
|
- HashMap<String, String> payload = new HashMap<>();
|
|
|
- payload.put("userPhone", byInstitutionNoAndLoginName.getPhone());
|
|
|
- payload.put("userId", byInstitutionNoAndLoginName.getId());
|
|
|
- payload.put("petName", byInstitutionNoAndLoginName.getInstitutionName());
|
|
|
- payload.put("institutionNo", byInstitutionNoAndLoginName.getInstitutionNo());
|
|
|
- payload.put("type", "superAdmin");
|
|
|
- String token = JWTUtil.getToken(payload);
|
|
|
- // 创建返回的json对象
|
|
|
- JSONObject resultJson = new JSONObject();
|
|
|
- resultJson.put("InstitutionEntity", byInstitutionNoAndLoginName);
|
|
|
- resultJson.put("type", "superAdmin");
|
|
|
- if (byInstitutionNoAndLoginName.getPassword().equals(password)) {
|
|
|
- resultJson.put("token", token);
|
|
|
- return success(resultJson);
|
|
|
- } else {
|
|
|
- return fail(resultJson, "账号或密码错误");
|
|
|
- }
|
|
|
- } else {
|
|
|
- return fail("", "账号错误");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改密码
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- */
|
|
|
- @SafetyProcess
|
|
|
- @Deprecated
|
|
|
- @PostMapping("/LANUpdatePassword1")
|
|
|
- @ApiOperation("修改密码--->forgotPassword")
|
|
|
- public Result LANUpdatePassword(@RequestBody String json) throws Exception {
|
|
|
- String data = AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data"));
|
|
|
- JSONObject jsonData = JSONObject.parseObject(data);
|
|
|
- String phone = jsonData.getString("phone");
|
|
|
- String password = jsonData.getString("password");
|
|
|
- if (phone == null || password == null) {
|
|
|
- return fail("", "请按要求填写所需信息");
|
|
|
- }
|
|
|
- UserEntity userEntity = this.userService.findPhone(phone);
|
|
|
- if (userEntity == null) {
|
|
|
- return fail("", "请先注册");
|
|
|
- } else {
|
|
|
- //this.userService.updatePassword(phone, password, "10010");
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //----------------------------局域网版接口end--------------------------------------------------------------------------------
|
|
|
-
|
|
|
/**
|
|
|
* 修改密码
|
|
|
*
|
|
@@ -504,9 +194,7 @@ public class UserController extends BaseController {
|
|
|
if (userEntity == null) {
|
|
|
return fail("", "请先注册");
|
|
|
} else {
|
|
|
- //this.userService.updatePassword(phone, DigestUtils.md5DigestAsHex(Constant.DEFAULT_PASSWORD.getBytes(StandardCharsets.UTF_8)), institutionNo);
|
|
|
userEntity.setPassword(DigestUtils.md5DigestAsHex(Constant.DEFAULT_PASSWORD.getBytes(StandardCharsets.UTF_8)));
|
|
|
- //userEntity.setUserStatus(UserStatus.UPDATE.getType());
|
|
|
userService.save(userEntity);
|
|
|
|
|
|
return success();
|
|
@@ -602,7 +290,7 @@ public class UserController extends BaseController {
|
|
|
UserEntity userEntity = jsonUserEntity.toJavaObject(UserEntity.class);
|
|
|
System.out.println(userEntity);
|
|
|
userEntity.setGId("0");
|
|
|
- userEntity.setModelPhone("0");
|
|
|
+ userEntity.setModel("0");
|
|
|
//判断机构编号是否存在
|
|
|
InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(userEntity.getInstitutionNo());
|
|
|
if (institutionEntity == null) {
|
|
@@ -720,7 +408,7 @@ public class UserController extends BaseController {
|
|
|
if (userEntity == null){
|
|
|
return fail("用户不存在");
|
|
|
}
|
|
|
- userEntity.setModelPhone(newModelPhone);
|
|
|
+ userEntity.setModel(newModelPhone);
|
|
|
userEntity.setPetName(petName);
|
|
|
userEntity.setGender(gender);
|
|
|
userEntity.setBirthday(birthday);
|