Ver código fonte

健康小屋-用户相关接口添加

huangzhiyong 6 anos atrás
pai
commit
16cd6de186

+ 3 - 1
svr/svr-base/src/main/resources/application.yml

@ -66,7 +66,9 @@ spring:
#    base-url: http://localhost:9411 #日志追踪的地址
#    base-url: http://localhost:9411 #日志追踪的地址
fastDFS:
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.19.103.54:80/
# 短信发送地址
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
---
---
spring:
spring:
  profiles: jwtest
  profiles: jwtest

+ 25 - 0
svr/svr-healthy-house/pom.xml

@ -122,6 +122,31 @@
			<groupId>org.springframework.security.oauth</groupId>
			<groupId>org.springframework.security.oauth</groupId>
			<artifactId>spring-security-oauth2</artifactId>
			<artifactId>spring-security-oauth2</artifactId>
		</dependency>
		</dependency>
		<!--   poi xml导入导出工具 start-->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<exclusions>
				<exclusion>
					<groupId>com.yihu.ehr</groupId>
					<artifactId>commons-util</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.apache.commons</groupId>
					<artifactId>commons-collections4</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
		</dependency>
		<!-- xlsx  依赖这个包 -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml-schemas</artifactId>
		</dependency>
		<!--   poi xml导入导出工具 end -->
	</dependencies>
	</dependencies>

+ 43 - 36
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java

@ -24,7 +24,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Date;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map;
/**
/**
@ -43,51 +42,31 @@ public class LoginController extends EnvelopRestEndpoint {
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    /******************************************    用户相关    **********************************/
    /******************************************    用户相关    **********************************/
    /**
     * 获取验证码
     * @param parameters
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/login/captcha")
    public ResponseEntity<HashMap> captcha(@RequestParam Map<String, String> parameters) throws  Exception{
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
    @ApiOperation(value = "发送短信验证码")
    @GetMapping(value = "/captcha/send")
    public ResponseEntity<HashMap> captcha(
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "msgType", value = "消息类型(login:登录验证,checkPhone:验证安全手机,resetPhone:重设安全手机", required = true)@RequestParam(required = true, name = "msgType") String msgType,
            @ApiParam(name = "username", value = "手机账号", required = true)@RequestParam(required = true, name = "username") String username ) throws  Exception{
        if (StringUtils.isEmpty(clientId)) {
            throw new InvalidRequestException("clientId");
        }
        }
        if (StringUtils.isEmpty(username)){
        if (StringUtils.isEmpty(username)){
            throw new InvalidRequestException("username");
            throw new InvalidRequestException("username");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(clientId, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        //发送短信获取验证码
        //发送短信获取验证码
        HttpHeaders reqHeaders = new HttpHeaders();
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("clientId", client_id);
        params.add("type", "login");
        params.add("to", username);
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HashMap<String, Object> result = restTemplate.postForObject("http://svr-base:10020/sms_gateway/send", httpEntity, HashMap.class);
        if (200 == (Integer) result.get("status")){
            Map<String, Object> sms =  (Map)result.get("obj");
            String captcha = (String) sms.get("captcha");
            Date deadline = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse((String) sms.get("deadline"));
            Long expire = (deadline.getTime() - System.currentTimeMillis()) / 1000;
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, expire.intValue());
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(result, headers, HttpStatus.OK);
        }
        throw new IllegalStateException((String) result.get("message"));
        ResponseEntity<HashMap> result = loginService.sendSms(clientId,msgType,username);
        return result;
    }
    }
    @GetMapping("/mobile/login")
    @GetMapping("/mobile/login")
    @ApiOperation(value = "手机登录注册")
    @ApiOperation(value = "【普通用户】-手机登录注册")
    public ObjEnvelop mobileLogin(
    public ObjEnvelop mobileLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
@ -107,7 +86,7 @@ public class LoginController extends EnvelopRestEndpoint {
    }
    }
    @PostMapping("/ijk/login")
    @PostMapping("/ijk/login")
    @ApiOperation(value = "i健康用户登陆")
    @ApiOperation(value = "【普通用户】-i健康用户登陆")
    public ObjEnvelop ijkLogin(
    public ObjEnvelop ijkLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
@ -142,7 +121,35 @@ public class LoginController extends EnvelopRestEndpoint {
    /***************************  管理员相关 **************************************/
    /***************************  管理员相关 **************************************/
    @GetMapping("/mobile/manage/login")
    @ApiOperation(value = "【管理员】-手机验证登录")
    public ObjEnvelop administratorMobileLogin(
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha) throws ManageException, ParseException {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
            User user = loginService.managerPhoneLogin(request,username);
            return ObjEnvelop.getSuccess("登录成功",user);
        } else {
            return ObjEnvelop.getError("验证码错误");
        }
    }
    @PostMapping("/manage/login")
    @ApiOperation(value = "【管理员】-用户账号登陆")
    public ObjEnvelop administratorLogin(
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
        User user = loginService.managerLogin(request,clientId,username, password);
        if (user !=null) {
            return ObjEnvelop.getSuccess("登录成功",user);
        }else {
            return ObjEnvelop.getError("登录失败");
        }
    }
}
}

+ 34 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java

@ -1,6 +1,7 @@
package com.yihu.jw.healthyhouse.controller.user;
package com.yihu.jw.healthyhouse.controller.user;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.healthyhouse.service.user.UserService;
@ -31,6 +32,8 @@ public class UserController  extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private UserService userService;
    private UserService userService;
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @GetMapping("/userList")
    @GetMapping("/userList")
    @ApiOperation(value = "获取用户列表")
    @ApiOperation(value = "获取用户列表")
@ -100,6 +103,37 @@ public class UserController  extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("更新用户使用设施次数成功");
        return ObjEnvelop.getSuccess("更新用户使用设施次数成功");
    }
    }
    @PostMapping("/updatePwd")
    @ApiOperation(value = "更新密码")
    public Envelop updatePwd(
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "oldPwd", value = "原密码", required = true)@RequestParam(required = true, name = "oldPwd") String oldPwd ,
            @ApiParam(name = "newPwd", value = "新密码", required = true)@RequestParam(required = true, name = "newPwd") String newPwd ) throws ManageException {
        userService.updatePwd(userId,oldPwd,newPwd);
        return ObjEnvelop.getSuccess("更新密码成功");
    }
    @PostMapping("/updatePhone")
    @ApiOperation(value = "更新安全手机号码")
    public Envelop updatePhone(
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "newPhone", value = "新安全手机号", required = true)@RequestParam(required = true, name = "newPhone") String newPhone ,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha ) throws ManageException {
        //验证码
        if (wlyyRedisVerifyCodeService.verification(clientId, newPhone, captcha)) {
            userService.updateSecurePhone(userId,newPhone);
            return ObjEnvelop.getSuccess("更新安全手机号码成功");
        } else {
            return ObjEnvelop.getError("验证码错误");
        }
    }
}
}

+ 3 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/UserDao.java

@ -38,4 +38,7 @@ public interface UserDao extends PagingAndSortingRepository<User, String>, JpaSp
    Long countAllByUserType(String userType);
    Long countAllByUserType(String userType);
    Long countAllByCreateTimeBetween(Date start,Date end);
    Long countAllByCreateTimeBetween(Date start,Date end);
    User findByLoginCodeAAndUserType(String loginCode,String userType);
}
}

+ 123 - 17
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/LoginService.java

@ -1,11 +1,13 @@
package com.yihu.jw.healthyhouse.service.user;
package com.yihu.jw.healthyhouse.service.user;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import com.yihu.jw.util.security.MD5;
import com.yihu.jw.util.security.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
@ -14,6 +16,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Date;
import java.util.HashMap;
import java.util.HashMap;
@ -31,8 +34,14 @@ public class LoginService {
    private UserService userService;
    private UserService userService;
    @Autowired
    @Autowired
    private RestTemplate restTemplate;
    private RestTemplate restTemplate;
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @Value("${jw.smsUrl}")
    private String smsUrl;
    /**
    /**
     *  手机验证码方式登录并自动注册
     * 手机验证码方式登录并自动注册
     *
     * @param loginCode
     * @param loginCode
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -48,7 +57,7 @@ public class LoginService {
            user.setName(loginCode);
            user.setName(loginCode);
            user.setTelephone(loginCode);
            user.setTelephone(loginCode);
            user.setPassword(LoginInfo.DEFAULT_PASSWORD);
            user.setPassword(LoginInfo.DEFAULT_PASSWORD);
        }else {
        } else {
            //已注册用户更改用户状态
            //已注册用户更改用户状态
            user.setActivated(HouseUserContant.activated_active);
            user.setActivated(HouseUserContant.activated_active);
        }
        }
@ -58,26 +67,27 @@ public class LoginService {
        request.getSession().setAttribute(LoginInfo.LOGIN_CODE, user.getLoginCode());
        request.getSession().setAttribute(LoginInfo.LOGIN_CODE, user.getLoginCode());
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        user.setLastLoginTime(new Date());
        user.setLastLoginTime(new Date());
        userService.saveOrUpdate(user,LoginInfo.SAVE_TYPE_PHONE);
        userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
        return user;
        return user;
    }
    }
    /**
    /**
     * i健康账户登录&注册
     * i健康账户登录&注册
     *
     * @param loginCode
     * @param loginCode
     * @param password
     * @param password
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    @Transactional(noRollbackForClassName = "ManageException")
    @Transactional(noRollbackForClassName = "ManageException")
    public User iJklogin(HttpServletRequest request,String clientId, String loginCode, String password) throws ManageException {
    public User iJklogin(HttpServletRequest request, String clientId, String loginCode, String password) throws ManageException {
        //判断登陆信息是否正确
        //判断登陆信息是否正确
        User user = userService.findByCode(loginCode);
        User user = userService.findByCode(loginCode);
        if (user == null) {
        if (user == null) {
            //i健康登录认证
            //i健康登录认证
            Map<String, Object> data = oauthIjkLogin(clientId,loginCode, password);
            if (data!=null ) {
            Map<String, Object> data = oauthIjkLogin(clientId, loginCode, password);
            if (data != null) {
                user = new User();
                user = new User();
                user.setPassword(password);
                user.setPassword(password);
                user.setLoginCode((String) data.get("user"));
                user.setLoginCode((String) data.get("user"));
@ -86,13 +96,12 @@ public class LoginService {
                user.setIdCardNo((String) data.get("idcard"));
                user.setIdCardNo((String) data.get("idcard"));
                user.setTelephone((String) data.get("mobile"));
                user.setTelephone((String) data.get("mobile"));
            }else {
            } else {
                String message = "账号不存在";
                String message = "账号不存在";
                throw new ManageException(message);
                throw new ManageException(message);
            }
            }
        }
        }
        if (!user.getPassword().equals(MD5.GetMD5Code(password + user.getSalt()))) {
        if (!user.getPassword().equals(MD5.GetMD5Code(password + user.getSalt()))) {
            //保存登陆信息
            String message = "密码错误";
            String message = "密码错误";
            throw new ManageException(message);
            throw new ManageException(message);
        }
        }
@ -102,19 +111,20 @@ public class LoginService {
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        user.setActivated(HouseUserContant.activated_active);
        user.setActivated(HouseUserContant.activated_active);
        user.setLastLoginTime(new Date());
        user.setLastLoginTime(new Date());
        userService.saveOrUpdate(user,LoginInfo.SAVE_TYPE_IJK);
        userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
        return user;
        return user;
    }
    }
    /**
    /**
     *  i健康用户信息认证
     * i健康用户信息认证
     *
     * @param username
     * @param username
     * @param password
     * @param password
     * @return
     * @return
     * @throws ManageException
     * @throws ManageException
     */
     */
    public Map<String, Object> oauthIjkLogin(String clientId,String username, String password) throws ManageException{
    public Map<String, Object> oauthIjkLogin(String clientId, String username, String password) throws ManageException {
        HashMap<String, Object> userDetail = null;
        HashMap<String, Object> userDetail = null;
        HttpHeaders reqHeaders = new HttpHeaders();
        HttpHeaders reqHeaders = new HttpHeaders();
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
@ -125,17 +135,18 @@ public class LoginService {
        params.add("login_type", "1");
        params.add("login_type", "1");
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HashMap<String, Object> result = restTemplate.postForObject("http://svr-authentication:10260/oauth/login", httpEntity, HashMap.class);
        HashMap<String, Object> result = restTemplate.postForObject("http://svr-authentication:10260/oauth/login", httpEntity, HashMap.class);
        if (200 == (Integer) result.get("status")){
            userDetail =  (HashMap)result.get("obj");
        return userDetail;
        }else {
        if (200 == (Integer) result.get("status")) {
            userDetail = (HashMap) result.get("obj");
            return userDetail;
        } else {
            throw new ManageException("i健康用户认证失败");
            throw new ManageException("i健康用户认证失败");
        }
        }
    }
    }
    /**
    /**
     *  登出
     * 登出
     *
     * @param loginCode
     * @param loginCode
     * @param password
     * @param password
     * @return
     * @return
@ -160,10 +171,105 @@ public class LoginService {
        request.getSession().removeAttribute(LoginInfo.LOGIN_NAME);
        request.getSession().removeAttribute(LoginInfo.LOGIN_NAME);
        request.getSession().removeAttribute(LoginInfo.USER_ID);
        request.getSession().removeAttribute(LoginInfo.USER_ID);
        user.setActivated(HouseUserContant.activated_offline);
        user.setActivated(HouseUserContant.activated_offline);
        userService.saveOrUpdate(user,"systemLogin");
        userService.saveOrUpdate(user, "systemLogin");
        return user;
        return user;
    }
    }
    /**
     * 发送短信
     *
     * @param clientId 应用id
     * @param type     短信类型
     * @param phone    接收手机号码
     * @return
     */
    public ResponseEntity<HashMap> sendSms(String clientId, String type, String phone) throws ParseException, ManageException {
        //发送短信获取验证码
        HttpHeaders reqHeaders = new HttpHeaders();
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("clientId", clientId);
        params.add("type", type);
        params.add("to", phone);
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HashMap<String, Object> result = restTemplate.postForObject(smsUrl, httpEntity, HashMap.class);
        if (200 == (Integer) result.get("status")) {
            Map<String, Object> sms = (Map) result.get("obj");
            String captcha = (String) sms.get("captcha");
            Date deadline = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse((String) sms.get("deadline"));
            Long expire = (deadline.getTime() - System.currentTimeMillis()) / 1000;
            wlyyRedisVerifyCodeService.store(clientId, phone, captcha, expire.intValue());
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(result, headers, HttpStatus.OK);
        } else {
            throw new ManageException("验证码获取失败!");
        }
    }
    /**
     * 管理员手机登录
     *
     * @param request
     * @param loginCode 登录名
     * @return
     * @throws ManageException
     */
    @Transactional(noRollbackForClassName = "ManageException")
    public User managerPhoneLogin(HttpServletRequest request, String loginCode) throws ManageException {
        //判断管理员用户信息是否存在
        User user = userService.findByLoginCodeAAndUserType(loginCode, LoginInfo.USER_TYPE_AdminManager);
        if (user == null) {
            throw new ManageException("该管理员账号不存在!");
        } else {
            //已注册用户更改用户状态
            user.setActivated(HouseUserContant.activated_active);
            request.getSession().setAttribute(LoginInfo.IS_LOGIN, true);
            request.getSession().setAttribute(LoginInfo.TOKEN, ""); //TODO token是否添加
            request.getSession().setAttribute(LoginInfo.LOGIN_NAME, user.getName());
            request.getSession().setAttribute(LoginInfo.LOGIN_CODE, user.getLoginCode());
            request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
            user.setLastLoginTime(new Date());
            userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
        }
        return user;
    }
    /**
     * 管理员-账号密码登录
     *
     * @param request
     * @param clientId  应用id
     * @param loginCode 登录账号
     * @param password  密码
     * @return
     * @throws ManageException
     */
    @Transactional(noRollbackForClassName = "ManageException")
    public User managerLogin(HttpServletRequest request, String clientId, String loginCode, String password) throws ManageException {
        //判断登陆信息是否正确
        User user = userService.findByCode(loginCode);
        if (user == null) {
            String message = "该管理员账号不存在!";
            throw new ManageException(message);
        } else {
            if (!user.getPassword().equals(MD5.GetMD5Code(password + user.getSalt()))) {
                String message = "密码错误";
                throw new ManageException(message);
            }
            request.getSession().setAttribute(LoginInfo.IS_LOGIN, true);
            request.getSession().setAttribute(LoginInfo.TOKEN, ""); //TODO token是否添加
            request.getSession().setAttribute(LoginInfo.LOGIN_NAME, user.getName());
            request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
            user.setActivated(HouseUserContant.activated_active);
            user.setLastLoginTime(new Date());
            userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
            return user;
        }
    }
}
}

+ 39 - 5
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java

@ -40,8 +40,8 @@ public class UserService {
        return userDao.findByLoginCode(code);
        return userDao.findByLoginCode(code);
    }
    }
    public User findByName(String username) {
        return userDao.findByName(username);
    public User findByLoginCodeAAndUserType(String loginCode,String userType) {
        return userDao.findByLoginCodeAAndUserType(loginCode,userType);
    }
    }
@ -146,9 +146,15 @@ public class UserService {
        }
        }
    }
    }
    /**
     * 更新设施使用次数
     * @param userId            用户id
     * @param facilityId    设施id
     * @throws ManageException
     */
    @Transactional
    @Transactional
    public void updateFacilityUse(String id, String facilityId) throws ManageException {
        User user1 = findById(id);
    public void updateFacilityUse(String userId, String facilityId) throws ManageException {
        User user1 = findById(userId);
        if (user1==null) {
        if (user1==null) {
            throw new ManageException("该账号不存在");
            throw new ManageException("该账号不存在");
        }
        }
@ -157,6 +163,34 @@ public class UserService {
        //TODO 设施的使用次数更新
        //TODO 设施的使用次数更新
    }
    }
    @Transactional
    public void updatePwd(String userId, String oldPwd,String newPwd) throws ManageException {
        User user = findById(userId);
        if (user==null) {
            throw new ManageException("该账号不存在");
        }
        if (!user.getPassword().equals(MD5.GetMD5Code(oldPwd + user.getSalt()))) {
            //保存登陆信息
            String message = "原密码错误";
            throw new ManageException(message);
        }
        String password = MD5.GetMD5Code(newPwd + user.getSalt());
        user.setPassword(password);
        userDao.save(user);
    }
    @Transactional
    public void updateSecurePhone(String userId, String phone) throws ManageException {
        User user = findById(userId);
        if (user==null) {
            throw new ManageException("该账号不存在");
        }
        user.setTelephone(phone);
        userDao.save(user);
    }
    /**
    /**
     * 获取 用户统计信息
     * 获取 用户统计信息
@ -178,7 +212,7 @@ public class UserService {
        result.put("totalCount",totalCount);
        result.put("totalCount",totalCount);
        result.put("newCount",newCount);
        result.put("newCount",newCount);
        result.put("activeCount",activeCount);
        result.put("activeCount",activeCount);
        result.put("activeCount",activeCount);
        result.put("usePricilityCount",usePricilityCount);
        return result;
        return result;
    }
    }

+ 30 - 0
wlyy-parent-pom/pom.xml

@ -95,6 +95,7 @@
        <version.spring-boot-admin>1.5.7</version.spring-boot-admin>
        <version.spring-boot-admin>1.5.7</version.spring-boot-admin>
        <version.zxing>3.2.0</version.zxing>
        <version.zxing>3.2.0</version.zxing>
        <version.fastdfs>1.25</version.fastdfs>
        <version.fastdfs>1.25</version.fastdfs>
        <version.poi>3.17</version.poi>
        <!-- Version end -->
        <!-- Version end -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -264,6 +265,35 @@
                <classifier>GA</classifier>
                <classifier>GA</classifier>
            </dependency>
            </dependency>
            <!--   poi xml导入导出工具 start-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${version.poi}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.yihu.ehr</groupId>
                        <artifactId>commons-util</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-collections4</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>${version.poi}</version>
            </dependency>
            <!-- xlsx  依赖这个包 -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml-schemas</artifactId>
                <version>${version.poi}</version>
            </dependency>
            <!--   poi xml导入导出工具 end -->
            <!-- Zipkin 日志追踪 -->
            <!-- Zipkin 日志追踪 -->
            <!--<dependency>
            <!--<dependency>
                <groupId>io.zipkin.java</groupId>
                <groupId>io.zipkin.java</groupId>