Commit 900781d347fc5cb095e17b9d563711ef2e557b73

Authored by 王富生
1 parent 58c89ed5

提交

src/main/java/com/zteits/oa/api/base/constants/ErrorType.java
@@ -4,7 +4,8 @@ import com.zteits.oa.api.base.bean.ErrorCode; @@ -4,7 +4,8 @@ import com.zteits.oa.api.base.bean.ErrorCode;
4 4
5 public enum ErrorType implements ErrorCode { 5 public enum ErrorType implements ErrorCode {
6 6
7 - AUTH_PASS_ERROR("2000", "账号密码不匹配"), 7 + AUTH_LOGIN_ERROR("1999", "登录账号不匹配"),
  8 + AUTH_PASS_ERROR("2000", "登录密码不匹配"),
8 AUTH_ROLE_EMPTY("2001", "账号无有效角色"), 9 AUTH_ROLE_EMPTY("2001", "账号无有效角色"),
9 AUTH_IMGCODE_ERROR("2002", "验证码错误"), 10 AUTH_IMGCODE_ERROR("2002", "验证码错误"),
10 AUTH_TOKEN_NOT_EXISTS("2003", "授权令牌不存在或已失效"), 11 AUTH_TOKEN_NOT_EXISTS("2003", "授权令牌不存在或已失效"),
src/main/java/com/zteits/oa/api/base/constants/SessionEnum.java 0 → 100644
  1 +package com.zteits.oa.api.base.constants;
  2 +
  3 +/**
  4 + * Copyright: Copyright (c) 2017 zteits
  5 + *
  6 + * @ClassName: com.clouds.common.constants
  7 + * @Description: 存在session里面变量
  8 + * @version: v1.0.0
  9 + * @author: atao
  10 + * @date: 2017/6/21 上午11:08
  11 + * Modification History:
  12 + * Date Author Version Description
  13 + * ---------------------------------------------------------*
  14 + * 2017/6/21 atao v1.0.0 创建
  15 + */
  16 +public enum SessionEnum {
  17 + //验证码
  18 + IMAGE_CODE("imageCode"),
  19 + //user 与 session 关联关系
  20 + USER_SESSION_REL("user:session"),
  21 + //user 对象
  22 + USER_INFO("user:info"),
  23 + //登录密码输错次数
  24 + PASS_WRONG_NUM("pass:wrong:num");
  25 +
  26 +
  27 +
  28 + private String key;
  29 +
  30 + SessionEnum(String key) {
  31 + this.key = key;
  32 + }
  33 +
  34 + public String key() {
  35 + return this.key;
  36 + }
  37 +
  38 +}
src/main/java/com/zteits/oa/api/dto/asraop/LoginOathRes.java 0 → 100644
  1 +package com.zteits.oa.api.dto.asraop;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * 登陆授权response.<br/>
  7 + *
  8 + * Copyright: Copyright (c) 2017 ZTE-ITS
  9 + *
  10 + * @ClassName: AmountUtils.java
  11 + * @Description:
  12 + * @version: v1.0.0
  13 + * @author: wangfs
  14 + * @date: 2018年7月31日 Modification History: Date Author Version Description
  15 + * ---------------------------------------------------------* 2018年7月31日
  16 + * wangfs v1.0.0 创建
  17 + */
  18 +public class LoginOathRes implements Serializable {
  19 +
  20 + /**
  21 + *
  22 + */
  23 + private static final long serialVersionUID = 5163928629505501899L;
  24 + /**
  25 + * 认证令牌 必填
  26 + */
  27 + private String accessToken;
  28 + /**
  29 + * 认证令牌过期时间 必填
  30 + */
  31 + private Long expiresIn;
  32 + /**
  33 + * 用户ID
  34 + */
  35 + private Long opId;
  36 +
  37 + /**登录工号*/
  38 + private String loginCode;
  39 +
  40 + /**
  41 + * 用户名
  42 + *
  43 + * @return
  44 + */
  45 + private String userName;
  46 +
  47 +
  48 +
  49 + /** 角色ID */
  50 + private Long roleId;
  51 + /** 地市ID */
  52 + private Long cityId;
  53 + /** 地市名称 */
  54 + private String cityName;
  55 + public String getAccessToken() {
  56 + return accessToken;
  57 + }
  58 + public void setAccessToken(String accessToken) {
  59 + this.accessToken = accessToken;
  60 + }
  61 + public Long getExpiresIn() {
  62 + return expiresIn;
  63 + }
  64 + public void setExpiresIn(Long expiresIn) {
  65 + this.expiresIn = expiresIn;
  66 + }
  67 + public String getUserName() {
  68 + return userName;
  69 + }
  70 + public void setUserName(String userName) {
  71 + this.userName = userName;
  72 + }
  73 + public Long getOpId() {
  74 + return opId;
  75 + }
  76 + public void setOpId(Long opId) {
  77 + this.opId = opId;
  78 + }
  79 + public String getLoginCode() {
  80 + return loginCode;
  81 + }
  82 + public void setLoginCode(String loginCode) {
  83 + this.loginCode = loginCode;
  84 + }
  85 + public Long getRoleId() {
  86 + return roleId;
  87 + }
  88 + public void setRoleId(Long roleId) {
  89 + this.roleId = roleId;
  90 + }
  91 + public Long getCityId() {
  92 + return cityId;
  93 + }
  94 + public void setCityId(Long cityId) {
  95 + this.cityId = cityId;
  96 + }
  97 + public String getCityName() {
  98 + return cityName;
  99 + }
  100 + public void setCityName(String cityName) {
  101 + this.cityName = cityName;
  102 + }
  103 +
  104 +
  105 +
  106 +
  107 +
  108 +}
src/main/java/com/zteits/oa/api/dto/asraop/param/AsraOpQueryReq.java
@@ -9,14 +9,21 @@ public class AsraOpQueryReq extends BaseRequest{ @@ -9,14 +9,21 @@ public class AsraOpQueryReq extends BaseRequest{
9 */ 9 */
10 private static final long serialVersionUID = 7249746348000980054L; 10 private static final long serialVersionUID = 7249746348000980054L;
11 11
  12 + /**主键*/
  13 + private Long id;
  14 +
12 /**登录工号*/ 15 /**登录工号*/
13 private String loginCode; 16 private String loginCode;
  17 +
  18 + /**登录密码*/
  19 + private String loginPassword;
14 20
15 /**操作员姓名*/ 21 /**操作员姓名*/
16 private String opName; 22 private String opName;
17 23
18 /**员工邮箱*/ 24 /**员工邮箱*/
19 private String email; 25 private String email;
  26 +
20 27
21 public String getLoginCode() { 28 public String getLoginCode() {
22 return loginCode; 29 return loginCode;
@@ -42,9 +49,20 @@ public class AsraOpQueryReq extends BaseRequest{ @@ -42,9 +49,20 @@ public class AsraOpQueryReq extends BaseRequest{
42 this.email = email; 49 this.email = email;
43 } 50 }
44 51
45 - @Override  
46 - public String toString() {  
47 - return "AsraOpQueryReq [loginCode=" + loginCode + ", opName=" + opName + ", email=" + email + "]"; 52 + public Long getId() {
  53 + return id;
  54 + }
  55 +
  56 + public void setId(Long id) {
  57 + this.id = id;
  58 + }
  59 +
  60 + public String getLoginPassword() {
  61 + return loginPassword;
  62 + }
  63 +
  64 + public void setLoginPassword(String loginPassword) {
  65 + this.loginPassword = loginPassword;
48 } 66 }
49 67
50 68
src/main/java/com/zteits/oa/api/dto/asraop/param/LoginOauthReq.java 0 → 100644
  1 +package com.zteits.oa.api.dto.asraop.param;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +
  6 +public class LoginOauthReq implements Serializable{
  7 +
  8 + /**
  9 + *
  10 + */
  11 + private static final long serialVersionUID = -5932514971605837490L;
  12 +
  13 + /**登陆账号.*/
  14 + private String loginCode;
  15 +
  16 + /**密码.*/
  17 + private String passWord;
  18 +
  19 +
  20 +
  21 + public String getLoginCode() {
  22 + return loginCode;
  23 + }
  24 +
  25 + public void setLoginCode(String loginCode) {
  26 + this.loginCode = loginCode == null ? null : loginCode.trim();
  27 + }
  28 +
  29 + public String getPassWord() {
  30 + return passWord;
  31 + }
  32 +
  33 + public void setPassWord(String passWord) {
  34 + this.passWord = passWord == null ? null : passWord.trim();
  35 + }
  36 +
  37 + @Override
  38 + public String toString() {
  39 + return "LoginOauthReq [loginCode=" + loginCode + ", passWord=" + passWord + "]";
  40 + }
  41 +
  42 +
  43 +
  44 +
  45 +
  46 +}
src/main/java/com/zteits/oa/api/service/report/query/AsraOpRueryService.java
@@ -32,4 +32,12 @@ public interface AsraOpRueryService { @@ -32,4 +32,12 @@ public interface AsraOpRueryService {
32 * 2018年7月30日 wangfs.<br/> 32 * 2018年7月30日 wangfs.<br/>
33 */ 33 */
34 BizResult<PageBean<AsraOpDTO>> queryAsraOpForPage(AsraOpQueryReq asraOpQueryReq); 34 BizResult<PageBean<AsraOpDTO>> queryAsraOpForPage(AsraOpQueryReq asraOpQueryReq);
  35 + /**
  36 + * 获取员工信息.<br/>
  37 + * @param asraOpQueryRe
  38 + * @return
  39 + * 2018年7月31日 wangfs.<br/>
  40 + */
  41 + BizResult<AsraOpDTO> queryAsraOp(AsraOpQueryReq asraOpQueryRe);
  42 +
35 } 43 }
src/main/java/com/zteits/oa/configuration/WebMvcConfig.java
@@ -24,19 +24,19 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter { @@ -24,19 +24,19 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
24 /** 24 /**
25 * 实现登陆拦截.<br/> 25 * 实现登陆拦截.<br/>
26 */ 26 */
27 - @Override  
28 - public void addInterceptors(InterceptorRegistry registry) {  
29 - InterceptorRegistration addInterceptor = null;//registry.addInterceptor();  
30 -  
31 - addInterceptor.excludePathPatterns("/error");  
32 -  
33 - addInterceptor.excludePathPatterns("/login**");  
34 -  
35 - addInterceptor.addPathPatterns("/**");  
36 -  
37 -  
38 -  
39 - } 27 +// @Override
  28 +// public void addInterceptors(InterceptorRegistry registry) {
  29 +// InterceptorRegistration addInterceptor = null;//registry.addInterceptor();
  30 +//
  31 +// addInterceptor.excludePathPatterns("/error");
  32 +//
  33 +// addInterceptor.excludePathPatterns("/login**");
  34 +//
  35 +// addInterceptor.addPathPatterns("/**");
  36 +//
  37 +//
  38 +//
  39 +// }
40 40
41 41
42 } 42 }
src/main/java/com/zteits/oa/report/biz/AsraOpRueryServiceImpl.java
@@ -2,6 +2,7 @@ package com.zteits.oa.report.biz; @@ -2,6 +2,7 @@ package com.zteits.oa.report.biz;
2 2
3 import org.slf4j.Logger; 3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory; 4 import org.slf4j.LoggerFactory;
  5 +import org.springframework.beans.BeanUtils;
5 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
7 8
@@ -51,5 +52,20 @@ public class AsraOpRueryServiceImpl implements AsraOpRueryService { @@ -51,5 +52,20 @@ public class AsraOpRueryServiceImpl implements AsraOpRueryService {
51 logger.info("---end查询分页员工信息.."); 52 logger.info("---end查询分页员工信息..");
52 return new BizResult<PageBean<AsraOpDTO>>(pageBean); 53 return new BizResult<PageBean<AsraOpDTO>>(pageBean);
53 } 54 }
  55 + /**
  56 + * 获取员工信息.<br/>
  57 + * @param asraOpQueryRe
  58 + * @return
  59 + * 2018年7月31日 wangfs.<br/>
  60 + */
  61 + @Override
  62 + public BizResult<AsraOpDTO> queryAsraOp(AsraOpQueryReq asraOpQueryRe) {
  63 + AsraOpDTO asraOpDTO = new AsraOpDTO();
  64 + AsraOp queryAsraOp = asraOpDao.queryAsraOp(asraOpQueryRe);
  65 + if(queryAsraOp != null){
  66 + BeanUtils.copyProperties(queryAsraOp, asraOpDTO);
  67 + }
  68 + return new BizResult<AsraOpDTO>(asraOpDTO);
  69 + }
54 70
55 } 71 }
src/main/java/com/zteits/oa/report/dao/AsraOpDao.java
1 package com.zteits.oa.report.dao; 1 package com.zteits.oa.report.dao;
2 2
3 import com.github.pagehelper.PageInfo; 3 import com.github.pagehelper.PageInfo;
  4 +import com.zteits.oa.api.base.bean.BizResult;
  5 +import com.zteits.oa.api.dto.asraop.AsraOpDTO;
4 import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; 6 import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;
5 import com.zteits.oa.report.domain.AsraOp; 7 import com.zteits.oa.report.domain.AsraOp;
6 8
@@ -13,4 +15,12 @@ public interface AsraOpDao { @@ -13,4 +15,12 @@ public interface AsraOpDao {
13 * 2018年7月30日 wangfs.<br/> 15 * 2018年7月30日 wangfs.<br/>
14 */ 16 */
15 PageInfo<AsraOp> queryAsraOpForPage(AsraOpQueryReq asraOpQueryReq); 17 PageInfo<AsraOp> queryAsraOpForPage(AsraOpQueryReq asraOpQueryReq);
  18 +
  19 + /**
  20 + * 获取员工信息.<br/>
  21 + * @param asraOpQueryRe
  22 + * @return
  23 + * 2018年7月31日 wangfs.<br/>
  24 + */
  25 + AsraOp queryAsraOp(AsraOpQueryReq asraOpQueryRe);
16 } 26 }
src/main/java/com/zteits/oa/report/dao/impl/AsraOpDaoImpl.java
@@ -4,18 +4,26 @@ import java.util.List; @@ -4,18 +4,26 @@ import java.util.List;
4 4
5 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Component; 6 import org.springframework.stereotype.Component;
  7 +import org.springframework.util.CollectionUtils;
  8 +import org.springframework.util.StringUtils;
7 9
8 import com.github.pagehelper.PageHelper; 10 import com.github.pagehelper.PageHelper;
9 import com.github.pagehelper.PageInfo; 11 import com.github.pagehelper.PageInfo;
10 import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq; 12 import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;
11 import com.zteits.oa.report.dao.AsraOpDao; 13 import com.zteits.oa.report.dao.AsraOpDao;
12 import com.zteits.oa.report.domain.AsraOp; 14 import com.zteits.oa.report.domain.AsraOp;
  15 +import com.zteits.oa.report.domain.AsraOpExample;
  16 +import com.zteits.oa.report.domain.AsraOpExample.Criteria;
  17 +import com.zteits.oa.report.mapper.AsraOpMapper;
13 import com.zteits.oa.report.mapper.smapper.AsraOpSmapper; 18 import com.zteits.oa.report.mapper.smapper.AsraOpSmapper;
14 @Component 19 @Component
15 public class AsraOpDaoImpl implements AsraOpDao { 20 public class AsraOpDaoImpl implements AsraOpDao {
16 21
17 @Autowired 22 @Autowired
18 private AsraOpSmapper asraOpSmapper; 23 private AsraOpSmapper asraOpSmapper;
  24 +
  25 + @Autowired
  26 + private AsraOpMapper asraOpMapper;
19 /** 27 /**
20 * 分页查询工时系统员工信息.<br/> 28 * 分页查询工时系统员工信息.<br/>
21 * @param asraOpQueryReq 29 * @param asraOpQueryReq
@@ -30,5 +38,28 @@ public class AsraOpDaoImpl implements AsraOpDao { @@ -30,5 +38,28 @@ public class AsraOpDaoImpl implements AsraOpDao {
30 List<AsraOp> list = asraOpSmapper.queryAsraOpForList(asraOpQueryReq); 38 List<AsraOp> list = asraOpSmapper.queryAsraOpForList(asraOpQueryReq);
31 return new PageInfo<AsraOp>(list); 39 return new PageInfo<AsraOp>(list);
32 } 40 }
  41 +
  42 + /**
  43 + * 获取员工信息.<br/>
  44 + * @param asraOpQueryRe
  45 + * @return
  46 + * 2018年7月31日 wangfs.<br/>
  47 + */
  48 + @Override
  49 + public AsraOp queryAsraOp(AsraOpQueryReq asraOpQueryRe) {
  50 + AsraOpExample example = new AsraOpExample();
  51 + Criteria criteria = example.createCriteria();
  52 + if(!StringUtils.isEmpty(asraOpQueryRe.getLoginCode())){
  53 + criteria.andLoginCodeEqualTo(asraOpQueryRe.getLoginCode());
  54 + }
  55 + if(!StringUtils.isEmpty(asraOpQueryRe.getLoginPassword())){
  56 + criteria.andLoginPasswordEqualTo(asraOpQueryRe.getLoginPassword());
  57 + }
  58 + if(asraOpQueryRe.getId() != null){
  59 + criteria.andIdEqualTo(asraOpQueryRe.getId());
  60 + }
  61 + List<AsraOp> list = asraOpMapper.selectByExample(example);
  62 + return CollectionUtils.isEmpty(list) ? new AsraOp() : list.get(0);
  63 + }
33 64
34 } 65 }
src/main/java/com/zteits/oa/report/domain/AsraOp.java
@@ -27,9 +27,6 @@ public class AsraOp { @@ -27,9 +27,6 @@ public class AsraOp {
27 /**地市名称*/ 27 /**地市名称*/
28 private String cityName; 28 private String cityName;
29 29
30 - /**上级领导id 领导:-1*/  
31 - private Long parentId;  
32 -  
33 /**是否邮件提醒 1:是,0:否*/ 30 /**是否邮件提醒 1:是,0:否*/
34 private Integer isRemindEmail; 31 private Integer isRemindEmail;
35 32
@@ -137,16 +134,6 @@ public class AsraOp { @@ -137,16 +134,6 @@ public class AsraOp {
137 this.cityName = cityName == null ? null : cityName.trim(); 134 this.cityName = cityName == null ? null : cityName.trim();
138 } 135 }
139 136
140 - /**获取上级领导id 领导:-1*/  
141 - public Long getParentId() {  
142 - return parentId;  
143 - }  
144 -  
145 - /**设置上级领导id 领导:-1*/  
146 - public void setParentId(Long parentId) {  
147 - this.parentId = parentId;  
148 - }  
149 -  
150 /**获取是否邮件提醒 1:是,0:否*/ 137 /**获取是否邮件提醒 1:是,0:否*/
151 public Integer getIsRemindEmail() { 138 public Integer getIsRemindEmail() {
152 return isRemindEmail; 139 return isRemindEmail;
src/main/java/com/zteits/oa/report/domain/AsraOpExample.java
@@ -635,66 +635,6 @@ public class AsraOpExample { @@ -635,66 +635,6 @@ public class AsraOpExample {
635 return (Criteria) this; 635 return (Criteria) this;
636 } 636 }
637 637
638 - public Criteria andParentIdIsNull() {  
639 - addCriterion("parent_id is null");  
640 - return (Criteria) this;  
641 - }  
642 -  
643 - public Criteria andParentIdIsNotNull() {  
644 - addCriterion("parent_id is not null");  
645 - return (Criteria) this;  
646 - }  
647 -  
648 - public Criteria andParentIdEqualTo(Long value) {  
649 - addCriterion("parent_id =", value, "parentId");  
650 - return (Criteria) this;  
651 - }  
652 -  
653 - public Criteria andParentIdNotEqualTo(Long value) {  
654 - addCriterion("parent_id <>", value, "parentId");  
655 - return (Criteria) this;  
656 - }  
657 -  
658 - public Criteria andParentIdGreaterThan(Long value) {  
659 - addCriterion("parent_id >", value, "parentId");  
660 - return (Criteria) this;  
661 - }  
662 -  
663 - public Criteria andParentIdGreaterThanOrEqualTo(Long value) {  
664 - addCriterion("parent_id >=", value, "parentId");  
665 - return (Criteria) this;  
666 - }  
667 -  
668 - public Criteria andParentIdLessThan(Long value) {  
669 - addCriterion("parent_id <", value, "parentId");  
670 - return (Criteria) this;  
671 - }  
672 -  
673 - public Criteria andParentIdLessThanOrEqualTo(Long value) {  
674 - addCriterion("parent_id <=", value, "parentId");  
675 - return (Criteria) this;  
676 - }  
677 -  
678 - public Criteria andParentIdIn(List<Long> values) {  
679 - addCriterion("parent_id in", values, "parentId");  
680 - return (Criteria) this;  
681 - }  
682 -  
683 - public Criteria andParentIdNotIn(List<Long> values) {  
684 - addCriterion("parent_id not in", values, "parentId");  
685 - return (Criteria) this;  
686 - }  
687 -  
688 - public Criteria andParentIdBetween(Long value1, Long value2) {  
689 - addCriterion("parent_id between", value1, value2, "parentId");  
690 - return (Criteria) this;  
691 - }  
692 -  
693 - public Criteria andParentIdNotBetween(Long value1, Long value2) {  
694 - addCriterion("parent_id not between", value1, value2, "parentId");  
695 - return (Criteria) this;  
696 - }  
697 -  
698 public Criteria andIsRemindEmailIsNull() { 638 public Criteria andIsRemindEmailIsNull() {
699 addCriterion("is_remind_email is null"); 639 addCriterion("is_remind_email is null");
700 return (Criteria) this; 640 return (Criteria) this;
src/main/java/com/zteits/oa/report/web/OAuthController.java 0 → 100644
  1 +package com.zteits.oa.report.web;
  2 +
  3 +import javax.servlet.http.HttpServletRequest;
  4 +import javax.servlet.http.HttpSession;
  5 +
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.util.StringUtils;
  10 +import org.springframework.web.bind.annotation.PostMapping;
  11 +import org.springframework.web.bind.annotation.RequestBody;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RestController;
  14 +
  15 +import com.zteits.oa.api.base.bean.BizResult;
  16 +import com.zteits.oa.api.base.constants.ErrorType;
  17 +import com.zteits.oa.api.base.constants.SessionEnum;
  18 +import com.zteits.oa.api.dto.asraop.AsraOpDTO;
  19 +import com.zteits.oa.api.dto.asraop.LoginOathRes;
  20 +import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;
  21 +import com.zteits.oa.api.dto.asraop.param.LoginOauthReq;
  22 +import com.zteits.oa.api.service.report.query.AsraOpRueryService;
  23 +import com.zteits.oa.util.MD5Utils;
  24 +
  25 +import io.swagger.annotations.Api;
  26 +import io.swagger.annotations.ApiOperation;
  27 +
  28 +@Api("用户登录授权")
  29 +@RestController
  30 +@RequestMapping("/oauth")
  31 +public class OAuthController {
  32 + private static final Logger logger = LoggerFactory.getLogger(OAuthController.class);
  33 +
  34 + @Autowired
  35 + private AsraOpRueryService asraOpRueryService;
  36 +
  37 + @Autowired
  38 + private HttpServletRequest request;
  39 +
  40 + @ApiOperation("用户登录")
  41 + @PostMapping("/login")
  42 + public BizResult<LoginOathRes> login(@RequestBody LoginOauthReq req ) throws Exception {
  43 + BizResult<LoginOathRes> result = this._login(req);
  44 + return result;
  45 + }
  46 + /**
  47 + * 登陆验证.<br/>
  48 + * @param req
  49 + * @return
  50 + * 2018年7月31日 wangfs.<br/>
  51 + */
  52 + private BizResult<LoginOathRes> _login(LoginOauthReq req ){
  53 + BizResult<LoginOathRes> result = new BizResult<LoginOathRes>();
  54 + LoginOathRes loginOathRes = new LoginOathRes();
  55 + String loginCode = req.getLoginCode();
  56 + String passWord = req.getPassWord();
  57 + if(StringUtils.isEmpty(loginCode) || StringUtils.isEmpty(passWord)) {
  58 + logger.info("校验登录信息,用户名 或者 登录密码为空!");
  59 + result.setErrorInfo(ErrorType.PARAMM_NULL, "用户名 或者 登录密码为空");
  60 + }
  61 + AsraOpQueryReq asraOpQueryRe = new AsraOpQueryReq();
  62 + AsraOpDTO asraOpDTO = new AsraOpDTO();
  63 + boolean isCheckSuccess = false;
  64 + //1.判断登录账号/密码
  65 + asraOpQueryRe.setLoginCode(loginCode);
  66 + BizResult<AsraOpDTO> asraOpReult = asraOpRueryService.queryAsraOp(asraOpQueryRe);
  67 + if(asraOpReult != null && asraOpReult.getData() != null){
  68 + asraOpDTO = asraOpReult.getData();
  69 + if(StringUtils.isEmpty(asraOpDTO.getLoginCode())){
  70 + logger.info("{}登录账号不存在",loginCode);
  71 + result.setErrorInfo(ErrorType.AUTH_LOGIN_ERROR, "登录账号不存在!");
  72 + }else{
  73 + if(!asraOpDTO.getLoginPassword().equalsIgnoreCase(MD5Utils.enMD5(passWord))){
  74 + logger.info("{}登录账号输入的密码不正确",loginCode);
  75 + result.setErrorInfo(ErrorType.AUTH_PASS_ERROR, "登录密码不匹配!");
  76 + }else{
  77 + isCheckSuccess = true;
  78 + }
  79 + }
  80 +
  81 + }else{
  82 + result.setErrorInfo(ErrorType.BIZ_ERROR, "用户登录失败");
  83 + }
  84 +
  85 +
  86 + if(isCheckSuccess){
  87 + HttpSession session = request.getSession();
  88 + session.setAttribute(SessionEnum.USER_INFO.key(), asraOpDTO);
  89 + logger.info("---获取到的session_id={}",session.getId());
  90 + loginOathRes.setOpId(asraOpDTO.getId());
  91 + loginOathRes.setLoginCode(loginCode);
  92 + loginOathRes.setUserName(asraOpDTO.getOpName());
  93 + loginOathRes.setCityId(asraOpDTO.getCityId());
  94 + loginOathRes.setCityName(asraOpDTO.getCityName());
  95 + loginOathRes.setAccessToken(session.getId());
  96 + result.setData(loginOathRes);
  97 + result.setErrorInfo(ErrorType.BIZ_SUCCESS, "登录成功");
  98 + }
  99 +
  100 +
  101 + return result;
  102 + }
  103 +
  104 +
  105 +
  106 +}
src/main/java/com/zteits/oa/report/web/demo/DemoController.java deleted
1 -package com.zteits.oa.report.web.demo;  
2 -  
3 -import javax.servlet.http.HttpServletRequest;  
4 -  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.web.bind.annotation.RequestBody;  
7 -import org.springframework.web.bind.annotation.RequestMapping;  
8 -import org.springframework.web.bind.annotation.RequestMethod;  
9 -import org.springframework.web.bind.annotation.RestController;  
10 -  
11 -import com.zteits.oa.api.base.bean.BizResult;  
12 -import com.zteits.oa.api.base.bean.PageBean;  
13 -import com.zteits.oa.api.dto.asraop.AsraOpDTO;  
14 -import com.zteits.oa.api.dto.asraop.param.AsraOpQueryReq;  
15 -import com.zteits.oa.api.service.report.query.AsraOpRueryService;  
16 -  
17 -import io.swagger.annotations.Api;  
18 -  
19 -@Api(value = "swagger测试", description = "swagger测")  
20 -@RestController  
21 -@RequestMapping("/demo")  
22 -public class DemoController {  
23 - @Autowired  
24 - private AsraOpRueryService asraOpRueryService;  
25 -  
26 - @RequestMapping(value="/demo",method = RequestMethod.POST)  
27 - public BizResult<PageBean<AsraOpDTO>> test(@RequestBody AsraOpQueryReq asraOpQueryReq, HttpServletRequest request){  
28 - BizResult<PageBean<AsraOpDTO>> result = asraOpRueryService.queryAsraOpForPage(asraOpQueryReq);  
29 - return result;  
30 - }  
31 -  
32 -}  
src/main/java/com/zteits/oa/util/MD5Utils.java 0 → 100644
  1 +package com.zteits.oa.util;
  2 +
  3 +import java.io.UnsupportedEncodingException;
  4 +import java.security.MessageDigest;
  5 +/**
  6 + *
  7 + * Copyright: Copyright (c) 2017 ZTE-ITS
  8 + *
  9 + * @ClassName: MD5Utils.java
  10 + * @Description:
  11 + * @version: v1.0.0
  12 + * @author: wangbiao
  13 + * @date: 2017年4月21日 下午4:12:16
  14 + * Modification History:
  15 + * Date Author Version Description
  16 + *---------------------------------------------------------*
  17 + * 2017年4月21日 wangbiao v1.0.0 创建
  18 + */
  19 +public class MD5Utils {
  20 + public final static String enMD5(String s) {
  21 + char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
  22 + try {
  23 + byte[] btInput = s.getBytes();
  24 + // 获得MD5摘要算法的 MessageDigest 对象
  25 + MessageDigest mdInst = MessageDigest.getInstance("MD5");
  26 + // 使用指定的字节更新摘要
  27 + mdInst.update(btInput);
  28 + // 获得密文
  29 + byte[] md = mdInst.digest();
  30 + // 把密文转换成十六进制的字符串形式
  31 + int j = md.length;
  32 + char str[] = new char[j * 2];
  33 + int k = 0;
  34 + for (int i = 0; i < j; i++) {
  35 + byte byte0 = md[i];
  36 + str[k++] = hexDigits[byte0 >>> 4 & 0xf];
  37 + str[k++] = hexDigits[byte0 & 0xf];
  38 + }
  39 + return new String(str);
  40 + } catch (Exception e) {
  41 + e.printStackTrace();
  42 + return null;
  43 + }
  44 + }
  45 +
  46 + public static void main(String[] args) {
  47 + System.out.println(MD5Utils.enMD5("123qwe"));
  48 + }
  49 +
  50 +}
src/main/resources/generator/generatorConfig.xml
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <!-- 指定自动生成主键的属性 --> 54 <!-- 指定自动生成主键的属性 -->
55 <generatedKey column="id" sqlStatement="MySql" identity="true"></generatedKey> 55 <generatedKey column="id" sqlStatement="MySql" identity="true"></generatedKey>
56 </table> 56 </table>
57 - <table tableName="tb_area"> 57 + <table tableName="asra_op">
58 <!-- 指定自动生成主键的属性 --> 58 <!-- 指定自动生成主键的属性 -->
59 <generatedKey column="id" sqlStatement="MySql" identity="true"></generatedKey> 59 <generatedKey column="id" sqlStatement="MySql" identity="true"></generatedKey>
60 </table> 60 </table>
src/main/resources/mybatis/mapper/AsraOpMapper.xml
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 <result column="role_id" jdbcType="BIGINT" property="roleId" /> 10 <result column="role_id" jdbcType="BIGINT" property="roleId" />
11 <result column="city_id" jdbcType="BIGINT" property="cityId" /> 11 <result column="city_id" jdbcType="BIGINT" property="cityId" />
12 <result column="city_name" jdbcType="VARCHAR" property="cityName" /> 12 <result column="city_name" jdbcType="VARCHAR" property="cityName" />
13 - <result column="parent_id" jdbcType="BIGINT" property="parentId" />  
14 <result column="is_remind_email" jdbcType="INTEGER" property="isRemindEmail" /> 13 <result column="is_remind_email" jdbcType="INTEGER" property="isRemindEmail" />
15 <result column="data_state" jdbcType="INTEGER" property="dataState" /> 14 <result column="data_state" jdbcType="INTEGER" property="dataState" />
16 <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" /> 15 <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
@@ -80,9 +79,9 @@ @@ -80,9 +79,9 @@
80 </where> 79 </where>
81 </sql> 80 </sql>
82 <sql id="Base_Column_List"> 81 <sql id="Base_Column_List">
83 - id, login_code, login_password, op_name, email, role_id, city_id, city_name, parent_id,  
84 - is_remind_email, data_state, create_empid, create_emp_name, create_date, modfiy_empid,  
85 - modfiy_emp_name, modfiy_date, remark 82 + id, login_code, login_password, op_name, email, role_id, city_id, city_name, is_remind_email,
  83 + data_state, create_empid, create_emp_name, create_date, modfiy_empid, modfiy_emp_name,
  84 + modfiy_date, remark
86 </sql> 85 </sql>
87 <select id="selectByExample" parameterType="com.zteits.oa.report.domain.AsraOpExample" resultMap="BaseResultMap"> 86 <select id="selectByExample" parameterType="com.zteits.oa.report.domain.AsraOpExample" resultMap="BaseResultMap">
88 select 87 select
@@ -120,16 +119,16 @@ @@ -120,16 +119,16 @@
120 </selectKey> 119 </selectKey>
121 insert into asra_op (login_code, login_password, op_name, 120 insert into asra_op (login_code, login_password, op_name,
122 email, role_id, city_id, 121 email, role_id, city_id,
123 - city_name, parent_id, is_remind_email,  
124 - data_state, create_empid, create_emp_name,  
125 - create_date, modfiy_empid, modfiy_emp_name,  
126 - modfiy_date, remark) 122 + city_name, is_remind_email, data_state,
  123 + create_empid, create_emp_name, create_date,
  124 + modfiy_empid, modfiy_emp_name, modfiy_date,
  125 + remark)
127 values (#{loginCode,jdbcType=VARCHAR}, #{loginPassword,jdbcType=VARCHAR}, #{opName,jdbcType=VARCHAR}, 126 values (#{loginCode,jdbcType=VARCHAR}, #{loginPassword,jdbcType=VARCHAR}, #{opName,jdbcType=VARCHAR},
128 #{email,jdbcType=VARCHAR}, #{roleId,jdbcType=BIGINT}, #{cityId,jdbcType=BIGINT}, 127 #{email,jdbcType=VARCHAR}, #{roleId,jdbcType=BIGINT}, #{cityId,jdbcType=BIGINT},
129 - #{cityName,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT}, #{isRemindEmail,jdbcType=INTEGER},  
130 - #{dataState,jdbcType=INTEGER}, #{createEmpid,jdbcType=VARCHAR}, #{createEmpName,jdbcType=VARCHAR},  
131 - #{createDate,jdbcType=TIMESTAMP}, #{modfiyEmpid,jdbcType=VARCHAR}, #{modfiyEmpName,jdbcType=VARCHAR},  
132 - #{modfiyDate,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}) 128 + #{cityName,jdbcType=VARCHAR}, #{isRemindEmail,jdbcType=INTEGER}, #{dataState,jdbcType=INTEGER},
  129 + #{createEmpid,jdbcType=VARCHAR}, #{createEmpName,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
  130 + #{modfiyEmpid,jdbcType=VARCHAR}, #{modfiyEmpName,jdbcType=VARCHAR}, #{modfiyDate,jdbcType=TIMESTAMP},
  131 + #{remark,jdbcType=VARCHAR})
133 </insert> 132 </insert>
134 <insert id="insertSelective" parameterType="com.zteits.oa.report.domain.AsraOp"> 133 <insert id="insertSelective" parameterType="com.zteits.oa.report.domain.AsraOp">
135 <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> 134 <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -158,9 +157,6 @@ @@ -158,9 +157,6 @@
158 <if test="cityName != null"> 157 <if test="cityName != null">
159 city_name, 158 city_name,
160 </if> 159 </if>
161 - <if test="parentId != null">  
162 - parent_id,  
163 - </if>  
164 <if test="isRemindEmail != null"> 160 <if test="isRemindEmail != null">
165 is_remind_email, 161 is_remind_email,
166 </if> 162 </if>
@@ -211,9 +207,6 @@ @@ -211,9 +207,6 @@
211 <if test="cityName != null"> 207 <if test="cityName != null">
212 #{cityName,jdbcType=VARCHAR}, 208 #{cityName,jdbcType=VARCHAR},
213 </if> 209 </if>
214 - <if test="parentId != null">  
215 - #{parentId,jdbcType=BIGINT},  
216 - </if>  
217 <if test="isRemindEmail != null"> 210 <if test="isRemindEmail != null">
218 #{isRemindEmail,jdbcType=INTEGER}, 211 #{isRemindEmail,jdbcType=INTEGER},
219 </if> 212 </if>
@@ -276,9 +269,6 @@ @@ -276,9 +269,6 @@
276 <if test="record.cityName != null"> 269 <if test="record.cityName != null">
277 city_name = #{record.cityName,jdbcType=VARCHAR}, 270 city_name = #{record.cityName,jdbcType=VARCHAR},
278 </if> 271 </if>
279 - <if test="record.parentId != null">  
280 - parent_id = #{record.parentId,jdbcType=BIGINT},  
281 - </if>  
282 <if test="record.isRemindEmail != null"> 272 <if test="record.isRemindEmail != null">
283 is_remind_email = #{record.isRemindEmail,jdbcType=INTEGER}, 273 is_remind_email = #{record.isRemindEmail,jdbcType=INTEGER},
284 </if> 274 </if>
@@ -321,7 +311,6 @@ @@ -321,7 +311,6 @@
321 role_id = #{record.roleId,jdbcType=BIGINT}, 311 role_id = #{record.roleId,jdbcType=BIGINT},
322 city_id = #{record.cityId,jdbcType=BIGINT}, 312 city_id = #{record.cityId,jdbcType=BIGINT},
323 city_name = #{record.cityName,jdbcType=VARCHAR}, 313 city_name = #{record.cityName,jdbcType=VARCHAR},
324 - parent_id = #{record.parentId,jdbcType=BIGINT},  
325 is_remind_email = #{record.isRemindEmail,jdbcType=INTEGER}, 314 is_remind_email = #{record.isRemindEmail,jdbcType=INTEGER},
326 data_state = #{record.dataState,jdbcType=INTEGER}, 315 data_state = #{record.dataState,jdbcType=INTEGER},
327 create_empid = #{record.createEmpid,jdbcType=VARCHAR}, 316 create_empid = #{record.createEmpid,jdbcType=VARCHAR},
@@ -359,9 +348,6 @@ @@ -359,9 +348,6 @@
359 <if test="cityName != null"> 348 <if test="cityName != null">
360 city_name = #{cityName,jdbcType=VARCHAR}, 349 city_name = #{cityName,jdbcType=VARCHAR},
361 </if> 350 </if>
362 - <if test="parentId != null">  
363 - parent_id = #{parentId,jdbcType=BIGINT},  
364 - </if>  
365 <if test="isRemindEmail != null"> 351 <if test="isRemindEmail != null">
366 is_remind_email = #{isRemindEmail,jdbcType=INTEGER}, 352 is_remind_email = #{isRemindEmail,jdbcType=INTEGER},
367 </if> 353 </if>
@@ -401,7 +387,6 @@ @@ -401,7 +387,6 @@
401 role_id = #{roleId,jdbcType=BIGINT}, 387 role_id = #{roleId,jdbcType=BIGINT},
402 city_id = #{cityId,jdbcType=BIGINT}, 388 city_id = #{cityId,jdbcType=BIGINT},
403 city_name = #{cityName,jdbcType=VARCHAR}, 389 city_name = #{cityName,jdbcType=VARCHAR},
404 - parent_id = #{parentId,jdbcType=BIGINT},  
405 is_remind_email = #{isRemindEmail,jdbcType=INTEGER}, 390 is_remind_email = #{isRemindEmail,jdbcType=INTEGER},
406 data_state = #{dataState,jdbcType=INTEGER}, 391 data_state = #{dataState,jdbcType=INTEGER},
407 create_empid = #{createEmpid,jdbcType=VARCHAR}, 392 create_empid = #{createEmpid,jdbcType=VARCHAR},
src/main/resources/mybatis/smapper/AsraOpSmapper.xml
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 <result column="role_id" jdbcType="BIGINT" property="roleId" /> 10 <result column="role_id" jdbcType="BIGINT" property="roleId" />
11 <result column="city_id" jdbcType="BIGINT" property="cityId" /> 11 <result column="city_id" jdbcType="BIGINT" property="cityId" />
12 <result column="city_name" jdbcType="VARCHAR" property="cityName" /> 12 <result column="city_name" jdbcType="VARCHAR" property="cityName" />
13 - <result column="parent_id" jdbcType="BIGINT" property="parentId" />  
14 <result column="is_remind_email" jdbcType="INTEGER" property="isRemindEmail" /> 13 <result column="is_remind_email" jdbcType="INTEGER" property="isRemindEmail" />
15 <result column="data_state" jdbcType="INTEGER" property="dataState" /> 14 <result column="data_state" jdbcType="INTEGER" property="dataState" />
16 <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" /> 15 <result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
@@ -22,7 +21,7 @@ @@ -22,7 +21,7 @@
22 <result column="remark" jdbcType="VARCHAR" property="remark" /> 21 <result column="remark" jdbcType="VARCHAR" property="remark" />
23 </resultMap> 22 </resultMap>
24 <sql id="Base_Column_List"> 23 <sql id="Base_Column_List">
25 - id, login_code, login_password, op_name, email, role_id, city_id, city_name, parent_id, 24 + id, login_code, login_password, op_name, email, role_id, city_id, city_name,
26 is_remind_email, data_state, create_empid, create_emp_name, create_date, modfiy_empid, 25 is_remind_email, data_state, create_empid, create_emp_name, create_date, modfiy_empid,
27 modfiy_emp_name, modfiy_date, remark 26 modfiy_emp_name, modfiy_date, remark
28 </sql> 27 </sql>