兴安访客小程序对接部分迁移
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.dcsoft.system.api;
|
package com.dcsoft.system.api;
|
||||||
|
|
||||||
|
import com.dcsoft.common.core.web.domain.AjaxResult;
|
||||||
|
import com.dcsoft.system.api.domain.SmsDTO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -59,4 +61,50 @@ public interface RemoteUserService
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/user/updateOpenId")
|
@PostMapping("/user/updateOpenId")
|
||||||
public R<Boolean> updateOpenId(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public R<Boolean> updateOpenId(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信
|
||||||
|
*
|
||||||
|
* @param smsDTO
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/sendMessage")
|
||||||
|
public AjaxResult sendMessage(@RequestBody SmsDTO smsDTO, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户信息(不返回异常信息)
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/infos/{username}")
|
||||||
|
public R<LoginUser> getUserInfos(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统配置
|
||||||
|
* @param configKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/config/configKey/{configKey}")
|
||||||
|
AjaxResult selectConfigByKey(@PathVariable("configKey") String configKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户基本信息
|
||||||
|
*
|
||||||
|
* @param sysUser 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/role/insertVisitor")
|
||||||
|
public AjaxResult insertVisitor(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户基本信息
|
||||||
|
*
|
||||||
|
* @param sysUser 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/updateByUserId")
|
||||||
|
public R<?> updateByUserId(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.dcsoft.system.api.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SmsDTO {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* code值
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信模板入参
|
||||||
|
*/
|
||||||
|
private String captcha;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private String templateId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.dcsoft.system.api.factory;
|
package com.dcsoft.system.api.factory;
|
||||||
|
|
||||||
|
import com.dcsoft.common.core.web.domain.AjaxResult;
|
||||||
|
import com.dcsoft.system.api.domain.SmsDTO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
@@ -31,6 +33,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||||||
return R.fail("获取用户失败:" + throwable.getMessage());
|
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<LoginUser> getUserInfos(String username, String source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<Boolean> registerUserInfo(SysUser sysUser, String source)
|
public R<Boolean> registerUserInfo(SysUser sysUser, String source)
|
||||||
{
|
{
|
||||||
@@ -48,6 +55,26 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||||||
return R.fail("绑定用户openid失败:" + throwable.getMessage());
|
return R.fail("绑定用户openid失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<?> updateByUserId(SysUser sysUser, String source) {
|
||||||
|
return R.fail("更新用户信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult insertVisitor(SysUser sysUser, String source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult sendMessage(SmsDTO smsDTO, String source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult selectConfigByKey(String configKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,10 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/src/main/resources/lib/jose4j-0.4.3.jar</systemPath>
|
<systemPath>${project.basedir}/src/main/resources/lib/jose4j-0.4.3.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dcsoft</groupId>
|
||||||
|
<artifactId>dcsoft-common-sms</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.dcsoft.auth.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dcsoft.auth.form.RegisterBody;
|
||||||
|
import com.dcsoft.auth.service.SysLoginService;
|
||||||
|
import com.dcsoft.common.core.domain.R;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码控制
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class SmsLoginController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysLoginService sysLoginService;
|
||||||
|
|
||||||
|
@PostMapping("app/sendSms")
|
||||||
|
public R<?> sendSms(@RequestBody RegisterBody register) {
|
||||||
|
R<String> result = sysLoginService.sendSms(register);
|
||||||
|
if (null != result && 200 == result.getCode()) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.fail("获取短信验证码失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
package com.dcsoft.auth.controller;
|
package com.dcsoft.auth.controller;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dcsoft.auth.bean.ValidateResult;
|
|
||||||
import com.dcsoft.auth.form.IDaasBody;
|
|
||||||
import com.dcsoft.auth.utils.LicenseManager;
|
|
||||||
import com.dcsoft.auth.utils.LicenseThread;
|
|
||||||
import com.idsmanager.dingdang.jwt.DingdangUserRetriever;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import com.dcsoft.auth.form.LoginBody;
|
import com.dcsoft.auth.form.LoginBody;
|
||||||
import com.dcsoft.auth.form.RegisterBody;
|
import com.dcsoft.auth.form.RegisterBody;
|
||||||
import com.dcsoft.auth.service.SysLoginService;
|
import com.dcsoft.auth.service.SysLoginService;
|
||||||
|
import com.dcsoft.auth.utils.LicenseManager;
|
||||||
|
import com.dcsoft.auth.utils.LicenseThread;
|
||||||
|
import com.dcsoft.auth.utils.RsaUiUtils;
|
||||||
import com.dcsoft.common.core.domain.R;
|
import com.dcsoft.common.core.domain.R;
|
||||||
import com.dcsoft.common.core.utils.JwtUtils;
|
import com.dcsoft.common.core.utils.JwtUtils;
|
||||||
import com.dcsoft.common.core.utils.StringUtils;
|
import com.dcsoft.common.core.utils.StringUtils;
|
||||||
|
import com.dcsoft.common.core.utils.bean.BeanUtils;
|
||||||
import com.dcsoft.common.security.auth.AuthUtil;
|
import com.dcsoft.common.security.auth.AuthUtil;
|
||||||
import com.dcsoft.common.security.service.TokenService;
|
import com.dcsoft.common.security.service.TokenService;
|
||||||
import com.dcsoft.common.security.utils.SecurityUtils;
|
import com.dcsoft.common.security.utils.SecurityUtils;
|
||||||
import com.dcsoft.system.api.model.LoginUser;
|
import com.dcsoft.system.api.model.LoginUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
public class TokenController
|
public class TokenController
|
||||||
{
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TokenController.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@@ -43,31 +45,46 @@ public class TokenController
|
|||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public R<?> login(@RequestBody LoginBody form)
|
public R<?> login(@RequestBody LoginBody form) throws Exception {
|
||||||
{
|
|
||||||
/* if(enabled){
|
/* if(enabled){
|
||||||
ValidateResult validateResult = LicenseThread.validateResult.get("Authorize");
|
ValidateResult validateResult = LicenseThread.validateResult.get("Authorize");
|
||||||
if (!validateResult.getIsValidate()){
|
if (!validateResult.getIsValidate()){
|
||||||
return R.fail(validateResult.getMessage());
|
return R.fail(validateResult.getMessage());
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
log.info("login form:{}", form);
|
||||||
LoginUser userInfo=new LoginUser();
|
LoginUser userInfo = new LoginUser();
|
||||||
// 用户登录
|
// 用户登录
|
||||||
if("weixin".equals(form.getFlag())){
|
if ("weixin".equals(form.getFlag())) {
|
||||||
R<LoginUser> userInfos=sysLoginService.getWxUserInfo(form);
|
//微信登录openid必传,phone必传
|
||||||
|
String s = RsaUiUtils.decryptByPrivateKey(form.getOpenid());
|
||||||
|
form.setOpenid(s);
|
||||||
|
R<LoginUser> userInfos = sysLoginService.getWxUserInfo(form);
|
||||||
userInfo = userInfos.getData();
|
userInfo = userInfos.getData();
|
||||||
if(userInfo==null){
|
if (ObjectUtil.isEmpty(userInfo) || ObjectUtil.isEmpty(userInfo.getSysUser())) {
|
||||||
return R.fail(userInfos.getCode(), userInfos.getMsg());
|
RegisterBody registerBody = new RegisterBody();
|
||||||
|
BeanUtils.copyProperties(form, registerBody);
|
||||||
|
userInfo = sysLoginService.appRegister(registerBody);
|
||||||
}
|
}
|
||||||
}else if("app".equals(form.getFlag())){
|
} else if ("app".equals(form.getFlag())) {
|
||||||
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
String str = RsaUiUtils.decryptByPrivateKey(form.getEncrypt());
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(str);
|
||||||
|
userInfo = sysLoginService.login(jsonObject.getString("username"), jsonObject.getString("password"));
|
||||||
//保存用户openid
|
//保存用户openid
|
||||||
if(StringUtils.isNotEmpty(form.getOpenid())){
|
if (StringUtils.isNotEmpty(form.getOpenid())) {
|
||||||
sysLoginService.updateOpenId(userInfo,form);
|
String s = RsaUiUtils.decryptByPrivateKey(form.getOpenid());
|
||||||
|
form.setOpenid(s);
|
||||||
|
sysLoginService.updateOpenId(userInfo, form);
|
||||||
}
|
}
|
||||||
}else{
|
} else if ("sms".equals(form.getFlag())) {
|
||||||
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
//短信登录openid,phone,smsCode必传(openid不能使用,存在他人手机号登录别人账号场景)
|
||||||
|
String s = RsaUiUtils.decryptByPrivateKey(form.getSmsCode());
|
||||||
|
form.setSmsCode(s);
|
||||||
|
userInfo = sysLoginService.Smslogin(form);
|
||||||
|
} else {
|
||||||
|
String s = RsaUiUtils.decryptByPrivateKey(form.getEncrypt());
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
|
userInfo = sysLoginService.login(jsonObject.getString("username"), jsonObject.getString("password"));
|
||||||
}
|
}
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
return R.ok(tokenService.createToken(userInfo));
|
return R.ok(tokenService.createToken(userInfo));
|
||||||
@@ -83,7 +100,7 @@ public class TokenController
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
LoginUser userInfo=new LoginUser();
|
LoginUser userInfo = new LoginUser();
|
||||||
// 用户登录
|
// 用户登录
|
||||||
if("weixin".equals(form.getFlag())){
|
if("weixin".equals(form.getFlag())){
|
||||||
R<LoginUser> userInfos=sysLoginService.getWxUserInfo(form);
|
R<LoginUser> userInfos=sysLoginService.getWxUserInfo(form);
|
||||||
@@ -91,13 +108,13 @@ public class TokenController
|
|||||||
if(userInfo==null){
|
if(userInfo==null){
|
||||||
R.fail();
|
R.fail();
|
||||||
}
|
}
|
||||||
}else if("app".equals(form.getFlag())){
|
} else if ("app".equals(form.getFlag())) {
|
||||||
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||||
//保存用户openid
|
//保存用户openid
|
||||||
if(!"".equals(form.getOpenid())){
|
if (!"".equals(form.getOpenid())) {
|
||||||
sysLoginService.updateOpenId(userInfo,form);
|
sysLoginService.updateOpenId(userInfo, form);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||||
}
|
}
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
@@ -202,4 +219,21 @@ public class TokenController
|
|||||||
return retMap;
|
return retMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/redisSet")
|
||||||
|
public R<?> redisSet(@RequestBody JSONObject js) {
|
||||||
|
tokenService.redisSet(js.getString("key"), js.getString("value"));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/redisGet")
|
||||||
|
public R<?> redisGet(@RequestBody JSONObject js) {
|
||||||
|
return R.ok(tokenService.redisGet(js.getString("key")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/redisDel")
|
||||||
|
public R<?> redisDel(@RequestBody JSONObject js) {
|
||||||
|
tokenService.redisDel(js.getString("key"));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,47 @@ public class LoginBody
|
|||||||
* 用户密码
|
* 用户密码
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录方式
|
* 登录方式
|
||||||
* **/
|
*/
|
||||||
private String flag;
|
private String flag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信openid
|
* 微信openid
|
||||||
* **/
|
*/
|
||||||
private String openid;
|
private String openid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码
|
||||||
|
*/
|
||||||
|
private String smsCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密后的数据
|
||||||
|
*/
|
||||||
|
private String encrypt;
|
||||||
|
|
||||||
|
public String getEncrypt() {
|
||||||
|
return encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncrypt(String encrypt) {
|
||||||
|
this.encrypt = encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSmsCode() {
|
||||||
|
return smsCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSmsCode(String smsCode) {
|
||||||
|
this.smsCode = smsCode;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
@@ -62,6 +94,14 @@ public class LoginBody
|
|||||||
this.openid = openid;
|
this.openid = openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "LoginBody{" +
|
return "LoginBody{" +
|
||||||
@@ -69,6 +109,8 @@ public class LoginBody
|
|||||||
", password='" + password + '\'' +
|
", password='" + password + '\'' +
|
||||||
", flag='" + flag + '\'' +
|
", flag='" + flag + '\'' +
|
||||||
", openid='" + openid + '\'' +
|
", openid='" + openid + '\'' +
|
||||||
|
", smsCode='" + smsCode + '\'' +
|
||||||
|
", phone='" + phone + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.dcsoft.auth.service;
|
package com.dcsoft.auth.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.dcsoft.auth.form.LoginBody;
|
import com.dcsoft.auth.form.LoginBody;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.dcsoft.auth.form.RegisterBody;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.dcsoft.common.core.constant.CacheConstants;
|
import com.dcsoft.common.core.constant.CacheConstants;
|
||||||
import com.dcsoft.common.core.constant.Constants;
|
import com.dcsoft.common.core.constant.Constants;
|
||||||
import com.dcsoft.common.core.constant.SecurityConstants;
|
import com.dcsoft.common.core.constant.SecurityConstants;
|
||||||
@@ -11,13 +12,27 @@ import com.dcsoft.common.core.domain.R;
|
|||||||
import com.dcsoft.common.core.enums.UserStatus;
|
import com.dcsoft.common.core.enums.UserStatus;
|
||||||
import com.dcsoft.common.core.exception.ServiceException;
|
import com.dcsoft.common.core.exception.ServiceException;
|
||||||
import com.dcsoft.common.core.text.Convert;
|
import com.dcsoft.common.core.text.Convert;
|
||||||
|
import com.dcsoft.common.core.utils.SmsUtils;
|
||||||
import com.dcsoft.common.core.utils.StringUtils;
|
import com.dcsoft.common.core.utils.StringUtils;
|
||||||
|
import com.dcsoft.common.core.utils.bean.BeanUtils;
|
||||||
import com.dcsoft.common.core.utils.ip.IpUtils;
|
import com.dcsoft.common.core.utils.ip.IpUtils;
|
||||||
|
import com.dcsoft.common.core.utils.uuid.IdUtils;
|
||||||
|
import com.dcsoft.common.core.web.domain.AjaxResult;
|
||||||
import com.dcsoft.common.redis.service.RedisService;
|
import com.dcsoft.common.redis.service.RedisService;
|
||||||
import com.dcsoft.common.security.utils.SecurityUtils;
|
import com.dcsoft.common.security.utils.SecurityUtils;
|
||||||
|
import com.dcsoft.common.sms.config.properties.SmsProperties;
|
||||||
import com.dcsoft.system.api.RemoteUserService;
|
import com.dcsoft.system.api.RemoteUserService;
|
||||||
|
import com.dcsoft.system.api.domain.SmsDTO;
|
||||||
import com.dcsoft.system.api.domain.SysUser;
|
import com.dcsoft.system.api.domain.SysUser;
|
||||||
import com.dcsoft.system.api.model.LoginUser;
|
import com.dcsoft.system.api.model.LoginUser;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
@@ -27,6 +42,7 @@ import com.dcsoft.system.api.model.LoginUser;
|
|||||||
@Component
|
@Component
|
||||||
public class SysLoginService
|
public class SysLoginService
|
||||||
{
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SysLoginService.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUserService remoteUserService;
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@@ -39,6 +55,20 @@ public class SysLoginService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SmsProperties smsProperties;
|
||||||
|
|
||||||
|
@Value("${visitor.deptId}")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Value("${visitor.roleId}")
|
||||||
|
private Long roleId;
|
||||||
|
|
||||||
|
private static final String USER_REGISTER = "USER_REGISTER:";
|
||||||
|
private static final String USER_REGISTER_TIME = "USER_REGISTER_TIME:";
|
||||||
|
|
||||||
|
private static final long CASH_TIMEOUT = 60 * 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +107,7 @@ public class SysLoginService
|
|||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
||||||
{
|
{
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("用户不存在/密码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R.FAIL == userResult.getCode())
|
if (R.FAIL == userResult.getCode())
|
||||||
@@ -142,60 +172,164 @@ public class SysLoginService
|
|||||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册(小程序注册都是一键注册)
|
||||||
|
*/
|
||||||
|
public LoginUser appRegister(RegisterBody registerBody) {
|
||||||
|
if (ObjectUtil.isNull(registerBody)) {
|
||||||
|
throw new ServiceException("请校验注册信息!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册用户信息
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
//如果有openId,从微信一键登录过来的
|
||||||
|
if (StringUtils.isNotBlank(registerBody.getOpenid())) {
|
||||||
|
sysUser.setOpenid(registerBody.getOpenid());
|
||||||
|
//查询该手机的用户信息是否绑定了openId,没有则绑定openId
|
||||||
|
R<LoginUser> userInfo = remoteUserService.getUserInfos(registerBody.getPhone(), SecurityConstants.INNER);
|
||||||
|
if (null != userInfo && 200 == userInfo.getCode()) {
|
||||||
|
//如果没有openId,更新该手机号的openId
|
||||||
|
if (ObjectUtil.isNotEmpty(userInfo.getData())
|
||||||
|
&& ObjectUtil.isNotEmpty(userInfo.getData().getSysUser())
|
||||||
|
&& StringUtils.isBlank(userInfo.getData().getSysUser().getOpenid())) {
|
||||||
|
SysUser sysUser1 = new SysUser();
|
||||||
|
sysUser1.setUserId(userInfo.getData().getSysUser().getUserId());
|
||||||
|
sysUser1.setOpenid(registerBody.getOpenid());
|
||||||
|
remoteUserService.updateOpenId(sysUser1, SecurityConstants.INNER);
|
||||||
|
return remoteUserService.getWxUserInfo(sysUser.getOpenid(), SecurityConstants.INNER).getData();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("微信登录注册异常!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//如果是手机号验证码登录一键注册
|
||||||
|
if(StringUtils.isNotBlank(registerBody.getSmsCode())) {
|
||||||
|
//获取短信验证码
|
||||||
|
Object smsCode = redisService.getCacheObject(USER_REGISTER + registerBody.getPhone());
|
||||||
|
if (ObjectUtil.isNull(smsCode) && StringUtils.isBlank(String.valueOf(smsCode))) {
|
||||||
|
throw new ServiceException("验证码已过期,请重新获取");
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(registerBody.getSmsCode(), String.valueOf(smsCode))) {
|
||||||
|
throw new ServiceException("验证码不正确,请重新填写");
|
||||||
|
}
|
||||||
|
sysUser.setUserName(registerBody.getPhone());
|
||||||
|
sysUser.setPhonenumber(registerBody.getPhone());
|
||||||
|
}
|
||||||
|
|
||||||
|
sysUser.setUserName(registerBody.getPhone());
|
||||||
|
sysUser.setPhonenumber(registerBody.getPhone());
|
||||||
|
sysUser.setNickName(registerBody.getPhone());
|
||||||
|
//密码初始化
|
||||||
|
if (StringUtils.isBlank(registerBody.getPassword())) {
|
||||||
|
AjaxResult result = remoteUserService.selectConfigByKey("sys.user.initPassword");
|
||||||
|
String password = "123456";
|
||||||
|
if (result.isSuccess()) {
|
||||||
|
password = result.get("msg").toString();
|
||||||
|
}
|
||||||
|
registerBody.setPassword(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||||
|
sysUser.setDeptId(deptId);
|
||||||
|
R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
if (R.FAIL == registerResult.getCode()) {
|
||||||
|
throw new ServiceException(registerResult.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询新增的访客信息
|
||||||
|
R<LoginUser> userResult = null;
|
||||||
|
if (StringUtils.isNotBlank(registerBody.getOpenid())) {
|
||||||
|
userResult = remoteUserService.getWxUserInfo(sysUser.getOpenid(), SecurityConstants.INNER);
|
||||||
|
} else {
|
||||||
|
userResult = remoteUserService.getUserInfo(sysUser.getUserName(), SecurityConstants.INNER);
|
||||||
|
}
|
||||||
|
//给访客设置对应角色
|
||||||
|
SysUser sysUser1 = new SysUser();
|
||||||
|
sysUser1.setUserId(userResult.getData().getSysUser().getUserId());
|
||||||
|
sysUser1.setRoleId(roleId);
|
||||||
|
remoteUserService.insertVisitor(sysUser1, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
recordLogService.recordLogininfor(sysUser.getOpenid(), Constants.REGISTER, "注册成功");
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(sysUser.getOpenid())) {
|
||||||
|
return remoteUserService.getWxUserInfo(sysUser.getOpenid(), SecurityConstants.INNER).getData();
|
||||||
|
} else {
|
||||||
|
return remoteUserService.getUserInfo(sysUser.getUserName(), SecurityConstants.INNER).getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
public LoginUser login(String username)
|
public LoginUser Smslogin(LoginBody login) {
|
||||||
{
|
|
||||||
|
|
||||||
// 用户名不在指定范围内 错误
|
// 用户名不在指定范围内 错误
|
||||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
if (login.getUsername().length() < UserConstants.USERNAME_MIN_LENGTH
|
||||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
|| login.getUsername().length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||||
{
|
recordLogService.recordLogininfor(login.getUsername(), Constants.LOGIN_FAIL, "用户名不在指定范围");
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围");
|
|
||||||
throw new ServiceException("用户名不在指定范围");
|
throw new ServiceException("用户名不在指定范围");
|
||||||
}
|
}
|
||||||
// IP黑名单校验
|
// IP黑名单校验
|
||||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
|
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) {
|
||||||
{
|
recordLogService.recordLogininfor(login.getUsername(), Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单");
|
|
||||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||||
}
|
}
|
||||||
// 查询用户信息
|
|
||||||
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))
|
//获取短信验证码
|
||||||
{
|
Object cashSmsCode = redisService.getCacheObject(USER_REGISTER + login.getUsername());
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
if (ObjectUtil.isNull(login.getSmsCode()) && StringUtils.isBlank(String.valueOf(login.getSmsCode()))) {
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("验证码已过期,请重新获取");
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(login.getSmsCode(), String.valueOf(cashSmsCode))) {
|
||||||
|
throw new ServiceException("验证码不正确,请重新填写");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R.FAIL == userResult.getCode())
|
// 查询用户信息
|
||||||
{
|
R<LoginUser> userResult = remoteUserService.getUserInfos(login.getUsername(), SecurityConstants.INNER);
|
||||||
|
|
||||||
|
//没查到用户则注册
|
||||||
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||||
|
RegisterBody registerBody = new RegisterBody();
|
||||||
|
BeanUtils.copyProperties(login, registerBody);
|
||||||
|
registerBody.setPhone(login.getUsername());
|
||||||
|
registerBody.setOpenid(null);
|
||||||
|
return this.appRegister(registerBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R.FAIL == userResult.getCode()) {
|
||||||
throw new ServiceException(userResult.getMsg());
|
throw new ServiceException(userResult.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginUser userInfo = userResult.getData();
|
|
||||||
SysUser user = userResult.getData().getSysUser();
|
SysUser user = userResult.getData().getSysUser();
|
||||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||||
{
|
recordLogService.recordLogininfor(login.getUsername(), Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
throw new ServiceException("对不起,您的账号:" + login.getUsername() + " 已被删除");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
|
||||||
}
|
}
|
||||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
{
|
recordLogService.recordLogininfor(login.getUsername(), Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
throw new ServiceException("对不起,您的账号:" + login.getUsername() + " 已停用");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
|
||||||
}
|
}
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
if (user.getUserName().contains("WX_")) {
|
||||||
return userInfo;
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setUserId(user.getUserId());
|
||||||
|
sysUser.setUserName(login.getUsername());
|
||||||
|
sysUser.setNickName(login.getUsername());
|
||||||
|
sysUser.setPhonenumber(login.getUsername());
|
||||||
|
remoteUserService.updateByUserId(sysUser, SecurityConstants.INNER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户信息
|
||||||
|
R<LoginUser> userResultNew = remoteUserService.getUserInfo(login.getUsername(), SecurityConstants.INNER);
|
||||||
|
recordLogService.recordLogininfor(login.getUsername(), Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
|
return userResultNew.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOpenId(LoginUser userInfo, LoginBody form) {
|
public void updateOpenId(LoginUser userInfo, LoginBody form) {
|
||||||
// 注册用户信息
|
// 注册用户信息
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser=userInfo.getSysUser();
|
sysUser = userInfo.getSysUser();
|
||||||
sysUser.setUserName(form.getUsername());
|
sysUser.setUserName(form.getUsername());
|
||||||
sysUser.setOpenid(form.getOpenid());
|
sysUser.setOpenid(form.getOpenid());
|
||||||
R<?> registerResult = remoteUserService.updateOpenId(sysUser, SecurityConstants.INNER);
|
R<?> registerResult = remoteUserService.updateOpenId(sysUser, SecurityConstants.INNER);
|
||||||
@@ -209,4 +343,47 @@ public class SysLoginService
|
|||||||
R<LoginUser> registerResult = remoteUserService.getWxUserInfo(form.getOpenid(), SecurityConstants.INNER);
|
R<LoginUser> registerResult = remoteUserService.getWxUserInfo(form.getOpenid(), SecurityConstants.INNER);
|
||||||
return registerResult;
|
return registerResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信
|
||||||
|
*
|
||||||
|
* @param register
|
||||||
|
*/
|
||||||
|
public R<String> sendSms(RegisterBody register) {
|
||||||
|
if (StringUtils.isBlank(register.getPhone())) {
|
||||||
|
return R.fail("手机号不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成六位验证码
|
||||||
|
String smsCode = SmsUtils.generateSmsCode();
|
||||||
|
|
||||||
|
SmsDTO smsDTO = new SmsDTO();
|
||||||
|
smsDTO.setTemplateId(smsProperties.getTemplate11());
|
||||||
|
smsDTO.setCaptcha(smsCode);
|
||||||
|
smsDTO.setPhone(register.getPhone());
|
||||||
|
AjaxResult ajaxResult = remoteUserService.sendMessage(smsDTO, SecurityConstants.INNER);
|
||||||
|
if (!ajaxResult.isSuccess()) {
|
||||||
|
throw new ServiceException(ajaxResult.get("msg").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//缓存次数
|
||||||
|
int i = 1;
|
||||||
|
Integer time = redisService.getCacheObject(USER_REGISTER_TIME + register.getPhone());
|
||||||
|
//如果已经达到10次则达到单日上限
|
||||||
|
if (null != time) {
|
||||||
|
i = time + 1;
|
||||||
|
if(time == 10) {
|
||||||
|
throw new ServiceException("发送短信验证码次数已达到单日上限");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 获取当天的结束时间点
|
||||||
|
Date endOfDay = DateUtil.endOfDay(new Date());
|
||||||
|
// 获取当前时间至当天结束的毫秒数
|
||||||
|
long cashTime = (endOfDay.getTime() - System.currentTimeMillis()) / 1000;
|
||||||
|
redisService.setCacheObject(USER_REGISTER_TIME + register.getPhone(), i, cashTime, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
//缓存短信
|
||||||
|
redisService.setCacheObject(USER_REGISTER + register.getPhone(), smsCode, CASH_TIMEOUT, TimeUnit.SECONDS);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
147
dcsoft-auth/src/main/java/com/dcsoft/auth/utils/RsaUiUtils.java
Normal file
147
dcsoft-auth/src/main/java/com/dcsoft/auth/utils/RsaUiUtils.java
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
package com.dcsoft.auth.utils;
|
||||||
|
|
||||||
|
import org.apache.tomcat.util.codec.binary.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import java.security.*;
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA加密解密
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public class RsaUiUtils {
|
||||||
|
|
||||||
|
|
||||||
|
// Rsa 私钥
|
||||||
|
public static String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKNPuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gAkM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWowcSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99EcvDQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthhYhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3UP8iWi1Qw0Y=";
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// String s = decryptByPrivateKey("pWwsO5+mUIzh1svfQhswNKqI36UPrC4/tn6mzsSE9T9KwjpeZiw+sAZnyP51CxXl8saj4wUmI4aJcmgGdbM3eA==");
|
||||||
|
String s = decryptByPrivateKey("NeInqZTsJAXHnRMl4zbO89mJZ4/LBnoTPhdgiFXwtpsunoqQM7duJ2ZdoXKyUGEuKFestyQ4sO5Qx4mpD5m7Sg==");
|
||||||
|
System.out.println(s);
|
||||||
|
// JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
|
// System.out.println(jsonObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥解密
|
||||||
|
*
|
||||||
|
* @param text 私钥
|
||||||
|
* @param text 待解密的文本
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPrivateKey(String text) throws Exception {
|
||||||
|
return decryptByPrivateKey(privateKey, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥解密
|
||||||
|
*
|
||||||
|
* @param publicKeyString 公钥
|
||||||
|
* @param text 待解密的信息
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPublicKey(String publicKeyString, String text) throws Exception {
|
||||||
|
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, publicKey);
|
||||||
|
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
||||||
|
return new String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥加密
|
||||||
|
*
|
||||||
|
* @param privateKeyString 私钥
|
||||||
|
* @param text 待加密的信息
|
||||||
|
* @return 加密后的文本
|
||||||
|
*/
|
||||||
|
public static String encryptByPrivateKey(String privateKeyString, String text) throws Exception {
|
||||||
|
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
|
||||||
|
byte[] result = cipher.doFinal(text.getBytes());
|
||||||
|
return Base64.encodeBase64String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私钥解密
|
||||||
|
*
|
||||||
|
* @param privateKeyString 私钥
|
||||||
|
* @param text 待解密的文本
|
||||||
|
* @return 解密后的文本
|
||||||
|
*/
|
||||||
|
public static String decryptByPrivateKey(String privateKeyString, String text) throws Exception {
|
||||||
|
PKCS8EncodedKeySpec pkcs8EncodedKeySpec5 = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec5);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
|
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
||||||
|
return new String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公钥加密
|
||||||
|
*
|
||||||
|
* @param publicKeyString 公钥
|
||||||
|
* @param text 待加密的文本
|
||||||
|
* @return 加密后的文本
|
||||||
|
*/
|
||||||
|
public static String encryptByPublicKey(String publicKeyString, String text) throws Exception {
|
||||||
|
X509EncodedKeySpec x509EncodedKeySpec2 = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyString));
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
|
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec2);
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
|
byte[] result = cipher.doFinal(text.getBytes());
|
||||||
|
return Base64.encodeBase64String(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建RSA密钥对
|
||||||
|
*
|
||||||
|
* @return 生成后的公私钥信息
|
||||||
|
*/
|
||||||
|
public static RsaKeyPair generateKeyPair() throws NoSuchAlgorithmException {
|
||||||
|
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
keyPairGenerator.initialize(1024);
|
||||||
|
KeyPair keyPair = keyPairGenerator.generateKeyPair();
|
||||||
|
RSAPublicKey rsaPublicKey = (RSAPublicKey) keyPair.getPublic();
|
||||||
|
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||||
|
String publicKeyString = Base64.encodeBase64String(rsaPublicKey.getEncoded());
|
||||||
|
String privateKeyString = Base64.encodeBase64String(rsaPrivateKey.getEncoded());
|
||||||
|
return new RsaKeyPair(publicKeyString, privateKeyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA密钥对对象
|
||||||
|
*/
|
||||||
|
public static class RsaKeyPair {
|
||||||
|
private final String publicKey;
|
||||||
|
private final String privateKey;
|
||||||
|
|
||||||
|
public RsaKeyPair(String publicKey, String privateKey) {
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
this.privateKey = privateKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicKey() {
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrivateKey() {
|
||||||
|
return privateKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.dcsoft.common.core.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批状态集合
|
||||||
|
*/
|
||||||
|
public enum ExamineEnum {
|
||||||
|
|
||||||
|
ALL("3", "全部","#607D8B"),
|
||||||
|
IN_REVIEW("2", "审核中","#2d82fb"),
|
||||||
|
PASSED("0", "已通过","#17b26a"),
|
||||||
|
REJECTED("1", "已驳回","#ff1100"),
|
||||||
|
;
|
||||||
|
|
||||||
|
ExamineEnum(String code, String name, String color) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getByCode(String code) {
|
||||||
|
for (ExamineEnum examine : ExamineEnum.values()) {
|
||||||
|
if (examine.code.equals(code)) {
|
||||||
|
return examine.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getColorByCode(String code) {
|
||||||
|
for (ExamineEnum examine : ExamineEnum.values()) {
|
||||||
|
if (examine.code.equals(code)) {
|
||||||
|
return examine.color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String name;
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.dcsoft.common.core.enums;
|
||||||
|
|
||||||
|
public enum MatterEnum {
|
||||||
|
|
||||||
|
VISIT_WORK("1", "走访办事"),
|
||||||
|
BID("2", "参加投标"),
|
||||||
|
MEETING("3", "会议交流"),
|
||||||
|
OTHER("4", "其他"),
|
||||||
|
INTERVIEW("9", "面试预约"),
|
||||||
|
;
|
||||||
|
|
||||||
|
MatterEnum(String code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getByCode(String code) {
|
||||||
|
for (MatterEnum matter : MatterEnum.values()) {
|
||||||
|
if (matter.code.equals(code)) {
|
||||||
|
return matter.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.dcsoft.common.core.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信工具类
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SmsUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成六位随机纯数字短信验证码
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String generateSmsCode() {
|
||||||
|
// 生成一个6位数的随机整数作为短信验证码
|
||||||
|
int smsCode = RandomUtil.randomInt(100000, 999999);
|
||||||
|
// 将验证码转换为字符串
|
||||||
|
return String.valueOf(smsCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -166,4 +166,16 @@ public class TokenService
|
|||||||
{
|
{
|
||||||
return ACCESS_TOKEN + token;
|
return ACCESS_TOKEN + token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void redisSet(String key, String value) {
|
||||||
|
redisService.setCacheObject(key, value, 60 * 5L, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String redisGet(String key) {
|
||||||
|
return redisService.getCacheObject(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void redisDel(String key) {
|
||||||
|
redisService.deleteObject(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,4 +86,9 @@ public class SmsProperties {
|
|||||||
* 兴安访客审核不通过
|
* 兴安访客审核不通过
|
||||||
*/
|
*/
|
||||||
private String template10;
|
private String template10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录注册6位验证码
|
||||||
|
*/
|
||||||
|
private String template11;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.dcsoft.system.controller;
|
package com.dcsoft.system.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
@@ -89,4 +91,17 @@ public class SysNoticeController extends BaseController
|
|||||||
{
|
{
|
||||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取园区须知
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/app/getNoticeInfo")
|
||||||
|
public AjaxResult getNoticeInfo(SysNotice notice)
|
||||||
|
{
|
||||||
|
SysNotice noticeInfo = noticeService.getNoticeInfo(notice);
|
||||||
|
if (ObjectUtil.isEmpty(noticeInfo)) {
|
||||||
|
return error("请联系管理员配置访客须知内容");
|
||||||
|
}
|
||||||
|
return success(noticeInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1256,5 +1256,34 @@ public class SysPeopleController extends BaseController
|
|||||||
return success(sysPeople);
|
return success(sysPeople);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序通过手机号查找姓名
|
||||||
|
*
|
||||||
|
* @param js
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/app/queryPeopleName")
|
||||||
|
public AjaxResult queryAppPeopleName(@RequestBody JSONObject js) {
|
||||||
|
if (null == js) {
|
||||||
|
throw new ServiceException("请输入查询参数");
|
||||||
|
}
|
||||||
|
String phone = js.getString("phone");
|
||||||
|
String deptType = js.getString("deptType");
|
||||||
|
if (StringUtils.isBlank(phone)) {
|
||||||
|
throw new ServiceException("手机号不能为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(deptType)) {
|
||||||
|
throw new ServiceException("公司/部门不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SysBranch> branch = sysBranchService.queryJuniorBranch(deptType);
|
||||||
|
List<String> collect = branch.stream().map(SysBranch::getId).collect(Collectors.toList());
|
||||||
|
collect.add(deptType);
|
||||||
|
SysPeople people = sysPeopleService.queryPeopleName(phone, collect);
|
||||||
|
if (people == null) {
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
return success(people);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.dcsoft.system.controller;
|
package com.dcsoft.system.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dcsoft.common.core.constant.CacheConstants;
|
||||||
import com.dcsoft.common.core.domain.R;
|
import com.dcsoft.common.core.domain.R;
|
||||||
|
import com.dcsoft.common.core.exception.ServiceException;
|
||||||
|
import com.dcsoft.common.core.utils.SpringUtils;
|
||||||
import com.dcsoft.common.core.utils.StringUtils;
|
import com.dcsoft.common.core.utils.StringUtils;
|
||||||
import com.dcsoft.common.core.utils.poi.ExcelUtil;
|
import com.dcsoft.common.core.utils.poi.ExcelUtil;
|
||||||
import com.dcsoft.common.core.web.controller.BaseController;
|
import com.dcsoft.common.core.web.controller.BaseController;
|
||||||
@@ -11,9 +15,14 @@ import com.dcsoft.common.core.web.domain.AjaxResult;
|
|||||||
import com.dcsoft.common.core.web.page.TableDataInfo;
|
import com.dcsoft.common.core.web.page.TableDataInfo;
|
||||||
import com.dcsoft.common.log.annotation.Log;
|
import com.dcsoft.common.log.annotation.Log;
|
||||||
import com.dcsoft.common.log.enums.BusinessType;
|
import com.dcsoft.common.log.enums.BusinessType;
|
||||||
|
import com.dcsoft.common.redis.service.RedisService;
|
||||||
import com.dcsoft.common.security.annotation.InnerAuth;
|
import com.dcsoft.common.security.annotation.InnerAuth;
|
||||||
import com.dcsoft.common.security.annotation.RequiresPermissions;
|
import com.dcsoft.common.security.annotation.RequiresPermissions;
|
||||||
import com.dcsoft.common.security.utils.SecurityUtils;
|
import com.dcsoft.common.security.utils.SecurityUtils;
|
||||||
|
import com.dcsoft.common.sms.config.properties.SmsProperties;
|
||||||
|
import com.dcsoft.common.sms.entity.SmsResult;
|
||||||
|
import com.dcsoft.common.sms.service.SmsTemplate;
|
||||||
|
import com.dcsoft.system.api.domain.SmsDTO;
|
||||||
import com.dcsoft.system.api.domain.SysDept;
|
import com.dcsoft.system.api.domain.SysDept;
|
||||||
import com.dcsoft.system.api.domain.SysRole;
|
import com.dcsoft.system.api.domain.SysRole;
|
||||||
import com.dcsoft.system.api.domain.SysUser;
|
import com.dcsoft.system.api.domain.SysUser;
|
||||||
@@ -21,6 +30,8 @@ import com.dcsoft.system.api.model.LoginUser;
|
|||||||
import com.dcsoft.system.domain.vo.AppletInfoVo;
|
import com.dcsoft.system.domain.vo.AppletInfoVo;
|
||||||
import com.dcsoft.system.service.*;
|
import com.dcsoft.system.service.*;
|
||||||
import com.dcsoft.system.uniubi.service.ISysApiService;
|
import com.dcsoft.system.uniubi.service.ISysApiService;
|
||||||
|
import com.dcsoft.system.utils.WeChatUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -30,8 +41,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +53,7 @@ import java.util.stream.Collectors;
|
|||||||
*
|
*
|
||||||
* @author dcsoft
|
* @author dcsoft
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public class SysUserController extends BaseController
|
public class SysUserController extends BaseController
|
||||||
@@ -62,13 +77,10 @@ public class SysUserController extends BaseController
|
|||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysBranchService sysBranchService;
|
private SmsProperties smsProperties;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPeopleService peopleService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ISysApiService sysApiService;
|
|
||||||
|
|
||||||
@Value("${applet.appid}")
|
@Value("${applet.appid}")
|
||||||
public String appid;
|
public String appid;
|
||||||
@@ -76,6 +88,9 @@ public class SysUserController extends BaseController
|
|||||||
@Value("${applet.secret}")
|
@Value("${applet.secret}")
|
||||||
public String secret;
|
public String secret;
|
||||||
|
|
||||||
|
@Value("${weixin.token}")
|
||||||
|
public String weixinToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
*/
|
*/
|
||||||
@@ -141,6 +156,30 @@ public class SysUserController extends BaseController
|
|||||||
return R.ok(sysUserVo);
|
return R.ok(sysUserVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户信息(不返回异常信息)
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping("/infos/{username}")
|
||||||
|
public R<LoginUser> infos(@PathVariable("username") String username)
|
||||||
|
{
|
||||||
|
SysUser sysUser = userService.selectUserByUserName(username);
|
||||||
|
if (StringUtils.isNull(sysUser))
|
||||||
|
{
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
// 角色集合
|
||||||
|
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||||
|
// 权限集合
|
||||||
|
Set<String> permissions = permissionService.getMenuPermission(sysUser);
|
||||||
|
LoginUser sysUserVo = new LoginUser();
|
||||||
|
sysUserVo.setUserid(sysUser.getUserId());
|
||||||
|
sysUserVo.setSysUser(sysUser);
|
||||||
|
sysUserVo.setRoles(roles);
|
||||||
|
sysUserVo.setPermissions(permissions);
|
||||||
|
return R.ok(sysUserVo);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户信息
|
* 获取当前用户信息
|
||||||
*/
|
*/
|
||||||
@@ -164,6 +203,21 @@ public class SysUserController extends BaseController
|
|||||||
return R.ok(sysUserVo);
|
return R.ok(sysUserVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户信息
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@PostMapping("/updateByUserId")
|
||||||
|
public R<?> updateByUserId(@RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||||
|
{
|
||||||
|
throw new ServiceException(user.getUserName() + "手机号码已存在");
|
||||||
|
}
|
||||||
|
userService.updateUserProfile(user);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
*/
|
*/
|
||||||
@@ -411,6 +465,50 @@ public class SysUserController extends BaseController
|
|||||||
return AjaxResult.success(jsonObject);
|
return AjaxResult.success(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code获取手机号
|
||||||
|
*
|
||||||
|
* @param json
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getuserphonenumber")
|
||||||
|
public AjaxResult getuserphonenumber(@RequestBody JSONObject json) {
|
||||||
|
if (ObjectUtil.isNull(json) || StringUtils.isBlank(json.getString("code"))) {
|
||||||
|
throw new ServiceException("参数code不能为空");
|
||||||
|
}
|
||||||
|
String code = json.getString("code");
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("code", code);
|
||||||
|
log.info("getuserphonenumber入参:{}", code);
|
||||||
|
String wxToken = getWxToken();
|
||||||
|
log.info("getuserphonenumber_getWxToken:{}", wxToken);
|
||||||
|
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token= " + wxToken;
|
||||||
|
String body = HttpUtil.createPost(url).body(JSON.toJSONString(map)).execute().body();
|
||||||
|
log.info("getuserphonenumber_result:{}", body);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(body);
|
||||||
|
if (jsonObject.getInteger("errcode") != 0) {
|
||||||
|
return AjaxResult.error(body);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取小程序token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getWxToken() {
|
||||||
|
String cacheObject = redisService.getCacheObject(CacheConstants.WEIXIN_TOKEN);
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotEmpty(cacheObject)) {
|
||||||
|
return cacheObject;
|
||||||
|
}
|
||||||
|
String body = HttpUtil.createGet(weixinToken).execute().body();
|
||||||
|
JSONObject object = JSONObject.parseObject(body);
|
||||||
|
String string = object.get("access_token").toString();
|
||||||
|
redisService.setCacheObject(CacheConstants.LOGIN_TOKEN, string, Long.valueOf(object.get("expires_in").toString()), TimeUnit.SECONDS);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序获取token
|
* 小程序获取token
|
||||||
* @param appletInfoVo
|
* @param appletInfoVo
|
||||||
@@ -430,5 +528,32 @@ public class SysUserController extends BaseController
|
|||||||
return success(userService.updateAppletAvatar(file, userName));
|
return success(userService.updateAppletAvatar(file, userName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/sendMessage")
|
||||||
|
public AjaxResult sendMessage(@RequestBody SmsDTO sms) {
|
||||||
|
if (StringUtils.isEmpty(sms.getPhone())) {
|
||||||
|
return error("手机号不能为空!");
|
||||||
|
}
|
||||||
|
if (!smsProperties.getEnabled()) {
|
||||||
|
error("当前系统没有开启短信功能!");
|
||||||
|
}
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
if(StringUtils.isNotBlank(sms.getCode())) {
|
||||||
|
map.put("code", sms.getCode());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(sms.getCaptcha())) {
|
||||||
|
map.put("captcha", sms.getCaptcha());
|
||||||
|
}
|
||||||
|
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
|
||||||
|
SmsResult result = smsTemplate.send(sms.getPhone(), sms.getTemplateId(), map);
|
||||||
|
if (!result.getIsSuccess()) {
|
||||||
|
return error(result.getMessage());
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class SysNotice extends BaseEntity
|
|||||||
/** 公告标题 */
|
/** 公告标题 */
|
||||||
private String noticeTitle;
|
private String noticeTitle;
|
||||||
|
|
||||||
/** 公告类型(1通知 2公告) */
|
/** 公告类型(1通知 2公告 3须知) */
|
||||||
private String noticeType;
|
private String noticeType;
|
||||||
|
|
||||||
/** 公告内容 */
|
/** 公告内容 */
|
||||||
@@ -31,6 +31,39 @@ public class SysNotice extends BaseEntity
|
|||||||
/** 公告状态(0正常 1关闭) */
|
/** 公告状态(0正常 1关闭) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/** 字典类型 */
|
||||||
|
private String dictType;
|
||||||
|
|
||||||
|
/** 字典值 */
|
||||||
|
private String dictValue;
|
||||||
|
|
||||||
|
/** 字典名称 */
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
public String getDictName() {
|
||||||
|
return dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictName(String dictName) {
|
||||||
|
this.dictName = dictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictType() {
|
||||||
|
return dictType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictType(String dictType) {
|
||||||
|
this.dictType = dictType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDictValue() {
|
||||||
|
return dictValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDictValue(String dictValue) {
|
||||||
|
this.dictValue = dictValue;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getNoticeId()
|
public Long getNoticeId()
|
||||||
{
|
{
|
||||||
return noticeId;
|
return noticeId;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.dcsoft.system.domain.vo;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Treeselect树结构实体类
|
||||||
|
*
|
||||||
|
* @author dcsoft
|
||||||
|
*/
|
||||||
|
public class KeyLabelVo implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
|
||||||
|
public KeyLabelVo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey()
|
||||||
|
{
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key)
|
||||||
|
{
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel()
|
||||||
|
{
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label)
|
||||||
|
{
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -97,4 +97,6 @@ public interface SysBranchMapper
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SysBranch> queryPropertyDept(String parentId);
|
List<SysBranch> queryPropertyDept(String parentId);
|
||||||
|
|
||||||
|
List<SysBranch> queryJuniorBranch(String branchId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,11 @@ public interface SysNoticeMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds(Long[] noticeIds);
|
public int deleteNoticeByIds(Long[] noticeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取访客须知
|
||||||
|
* @param notice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysNotice selectNotice(SysNotice notice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,4 +125,11 @@ public interface ISysBranchService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SysBranch> queryPropertyDept(String parentId);
|
List<SysBranch> queryPropertyDept(String parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param branchId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysBranch> queryJuniorBranch(String branchId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,11 @@ public interface ISysNoticeService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds(Long[] noticeIds);
|
public int deleteNoticeByIds(Long[] noticeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取访客须知
|
||||||
|
* @param notice
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysNotice getNoticeInfo(SysNotice notice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,11 @@ public class SysBranchServiceImpl implements ISysBranchService
|
|||||||
return sysBranchMapper.queryPropertyDept(parentId);
|
return sysBranchMapper.queryPropertyDept(parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysBranch> queryJuniorBranch(String branchId) {
|
||||||
|
return sysBranchMapper.queryJuniorBranch(branchId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要树结构
|
* 构建前端所需要树结构
|
||||||
|
|||||||
@@ -89,4 +89,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
|||||||
{
|
{
|
||||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysNotice getNoticeInfo(SysNotice notice) {
|
||||||
|
return noticeMapper.selectNotice(notice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.dcsoft.system.visitor.controller;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.dcsoft.common.core.utils.StringUtils;
|
||||||
import com.dcsoft.system.visitor.domain.VisVisitorRegister;
|
import com.dcsoft.system.visitor.domain.VisVisitorRegister;
|
||||||
import com.dcsoft.system.visitor.service.IVisVisitorRegisterService;
|
import com.dcsoft.system.visitor.service.IVisVisitorRegisterService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -37,7 +38,7 @@ public class VisVisitorRegisterController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询访客注册列表
|
* 查询访客注册列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:register:list")
|
// @RequiresPermissions("system:register:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(VisVisitorRegister visVisitorRegister) {
|
public TableDataInfo list(VisVisitorRegister visVisitorRegister) {
|
||||||
startPage();
|
startPage();
|
||||||
@@ -60,27 +61,40 @@ public class VisVisitorRegisterController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 获取访客注册详细信息
|
* 获取访客注册详细信息
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:register:query")
|
// @RequiresPermissions("system:register:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") String id) {
|
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||||
return success(visVisitorRegisterService.selectVisVisitorRegisterById(id));
|
return success(visVisitorRegisterService.selectVisVisitorRegisterById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序获取访客注册详细信息
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("system:register:query")
|
||||||
|
@PostMapping(value = "/getVisitorInfo")
|
||||||
|
public AjaxResult getVisitorInfo() {
|
||||||
|
return success(visVisitorRegisterService.getVisitorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增访客注册
|
* 新增访客注册
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:register:add")
|
// @RequiresPermissions("system:register:add")
|
||||||
@Log(title = "访客注册", businessType = BusinessType.INSERT)
|
@Log(title = "访客注册", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody VisVisitorRegister visVisitorRegister) {
|
public AjaxResult addOrUpdate(@RequestBody VisVisitorRegister visVisitorRegister) {
|
||||||
|
if (StringUtils.isBlank(visVisitorRegister.getId())) {
|
||||||
return toAjax(visVisitorRegisterService.insertVisVisitorRegister(visVisitorRegister));
|
return toAjax(visVisitorRegisterService.insertVisVisitorRegister(visVisitorRegister));
|
||||||
|
} else {
|
||||||
|
return toAjax(visVisitorRegisterService.updateVisVisitorRegister(visVisitorRegister));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改访客注册
|
* 修改访客注册
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:register:edit")
|
// @RequiresPermissions("system:register:edit")
|
||||||
@Log(title = "访客注册", businessType = BusinessType.UPDATE)
|
@Log(title = "修改访客注册", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody VisVisitorRegister visVisitorRegister) {
|
public AjaxResult edit(@RequestBody VisVisitorRegister visVisitorRegister) {
|
||||||
return toAjax(visVisitorRegisterService.updateVisVisitorRegister(visVisitorRegister));
|
return toAjax(visVisitorRegisterService.updateVisVisitorRegister(visVisitorRegister));
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dcsoft.common.core.constant.CacheConstants;
|
import com.dcsoft.common.core.constant.CacheConstants;
|
||||||
import com.dcsoft.common.core.constant.Constants;
|
import com.dcsoft.common.core.constant.Constants;
|
||||||
|
import com.dcsoft.common.core.enums.ExamineEnum;
|
||||||
|
import com.dcsoft.common.core.enums.MatterEnum;
|
||||||
import com.dcsoft.common.core.enums.exception.CommonExceptionEnum;
|
import com.dcsoft.common.core.enums.exception.CommonExceptionEnum;
|
||||||
import com.dcsoft.common.core.exception.ServiceException;
|
import com.dcsoft.common.core.exception.ServiceException;
|
||||||
import com.dcsoft.common.core.utils.SpringUtils;
|
import com.dcsoft.common.core.utils.SpringUtils;
|
||||||
@@ -24,6 +26,7 @@ import com.dcsoft.common.sms.entity.SmsResult;
|
|||||||
import com.dcsoft.common.sms.service.SmsTemplate;
|
import com.dcsoft.common.sms.service.SmsTemplate;
|
||||||
import com.dcsoft.system.api.model.LoginUser;
|
import com.dcsoft.system.api.model.LoginUser;
|
||||||
import com.dcsoft.system.domain.*;
|
import com.dcsoft.system.domain.*;
|
||||||
|
import com.dcsoft.system.domain.vo.KeyLabelVo;
|
||||||
import com.dcsoft.system.domain.vo.OfficialAccountVo;
|
import com.dcsoft.system.domain.vo.OfficialAccountVo;
|
||||||
import com.dcsoft.system.domain.vo.SysFileVo;
|
import com.dcsoft.system.domain.vo.SysFileVo;
|
||||||
import com.dcsoft.system.service.*;
|
import com.dcsoft.system.service.*;
|
||||||
@@ -215,6 +218,52 @@ public class VisitorController extends BaseController {
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序查询我的访客信息列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/app/list")
|
||||||
|
public TableDataInfo appList(Visitor visitor) {
|
||||||
|
LoginUser user = SecurityUtils.getLoginUser();
|
||||||
|
visitor.setCreateBy(user.getUsername());
|
||||||
|
log.info("访客信息列表入参:{}", JSON.toJSONString(visitor));
|
||||||
|
|
||||||
|
startPage();
|
||||||
|
List<Visitor> list = visitorService.selectAppVisitorList(visitor);
|
||||||
|
Map<String, String> map = dictDataService.queryDictData("sys_company_type");
|
||||||
|
// Map<String, String> parkMap = dictDataService.queryDictData("sys_park_group");
|
||||||
|
List<SysBranch> sysBranches = sysBranchService.queryPropertyDept(null);
|
||||||
|
Map<String, String> collect = sysBranches.stream().collect(Collectors.toMap(SysBranch::getId, SysBranch::getName));
|
||||||
|
for (Visitor visitor1 : list) {
|
||||||
|
String s = map.get(visitor1.getDeptId());
|
||||||
|
if (StringUtils.isNotEmpty(s)) {
|
||||||
|
visitor1.setDeptName(s);
|
||||||
|
} else {
|
||||||
|
visitor1.setDeptName(collect.get(visitor1.getDeptId()));
|
||||||
|
}
|
||||||
|
visitor1.setMatterName(MatterEnum.getByCode(visitor1.getMatter()));
|
||||||
|
// visitor1.setParkName(parkMap.get(visitor1.getPark()));
|
||||||
|
}
|
||||||
|
log.info("访客信息列表:{}", JSON.toJSONString(list));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询审批状态枚举类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/app/getExamineEnum")
|
||||||
|
public AjaxResult getExamineEnum() {
|
||||||
|
List<KeyLabelVo> list = new ArrayList();
|
||||||
|
for (ExamineEnum examine : ExamineEnum.values()) {
|
||||||
|
KeyLabelVo keyLabelVo = new KeyLabelVo();
|
||||||
|
keyLabelVo.setKey(examine.getCode());
|
||||||
|
keyLabelVo.setLabel(examine.getValue());
|
||||||
|
keyLabelVo.setColor(examine.getColor());
|
||||||
|
list.add(keyLabelVo);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出访客信息列表
|
* 导出访客信息列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,6 +40,26 @@ public class VisVisitorRegister extends BaseEntity {
|
|||||||
@Excel(name = "用户手机号")
|
@Excel(name = "用户手机号")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户主键id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证
|
||||||
|
*/
|
||||||
|
private String idcard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访客用人单位
|
||||||
|
*/
|
||||||
|
private String visitingUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸图片地址
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信公众号用户id
|
* 微信公众号用户id
|
||||||
*/
|
*/
|
||||||
@@ -158,6 +178,38 @@ public class VisVisitorRegister extends BaseEntity {
|
|||||||
return updatedTime;
|
return updatedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdcard() {
|
||||||
|
return idcard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdcard(String idcard) {
|
||||||
|
this.idcard = idcard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVisitingUnit() {
|
||||||
|
return visitingUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisitingUnit(String visitingUnit) {
|
||||||
|
this.visitingUnit = visitingUnit;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@@ -166,6 +218,10 @@ public class VisVisitorRegister extends BaseEntity {
|
|||||||
.append("nickName", getNickName())
|
.append("nickName", getNickName())
|
||||||
.append("phone", getPhone())
|
.append("phone", getPhone())
|
||||||
.append("openid", getOpenid())
|
.append("openid", getOpenid())
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("idcard", getIdcard())
|
||||||
|
.append("visitingUnit", getVisitingUnit())
|
||||||
|
.append("avatar", getAvatar())
|
||||||
.append("deleteState", getDeleteState())
|
.append("deleteState", getDeleteState())
|
||||||
.append("createdBy", getCreatedBy())
|
.append("createdBy", getCreatedBy())
|
||||||
.append("createdTime", getCreatedTime())
|
.append("createdTime", getCreatedTime())
|
||||||
|
|||||||
@@ -242,4 +242,17 @@ public class Visitor extends BaseEntity {
|
|||||||
private List<SysFileVo> fileList;
|
private List<SysFileVo> fileList;
|
||||||
|
|
||||||
private List<VisitorReviewProcessVo> reviewProcessList;
|
private List<VisitorReviewProcessVo> reviewProcessList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ids
|
||||||
|
*/
|
||||||
|
List<Long> ids;
|
||||||
|
|
||||||
|
/** 小程序二维码 */
|
||||||
|
private String qrCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来访事由名称
|
||||||
|
*/
|
||||||
|
private String MatterName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,4 +65,12 @@ public interface VisVisitorRegisterMapper {
|
|||||||
void saveVisitorRegister(SysPeople people1);
|
void saveVisitorRegister(SysPeople people1);
|
||||||
|
|
||||||
void updateVisitorRegisterByOpenid(SysPeople sysPeople);
|
void updateVisitorRegisterByOpenid(SysPeople sysPeople);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询访客注册
|
||||||
|
*
|
||||||
|
* @param userId 访客注册主键
|
||||||
|
* @return 访客注册
|
||||||
|
*/
|
||||||
|
public VisVisitorRegister selectVisVisitorRegisterByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,4 +232,10 @@ public interface VisitorMapper
|
|||||||
int queryVisitorReviewProcessCount(Long id);
|
int queryVisitorReviewProcessCount(Long id);
|
||||||
|
|
||||||
List<VisitorReviewProcessVo> queryVisitorReviewProcessList(Long id);
|
List<VisitorReviewProcessVo> queryVisitorReviewProcessList(Long id);
|
||||||
|
|
||||||
|
List<Long> selectAppVisitorFollow(Visitor visitor);
|
||||||
|
|
||||||
|
List<Visitor> selectAppVisitorList(Visitor visitor);
|
||||||
|
|
||||||
|
List<CheckCodeVo> queryCode(List<Long> collect);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,11 @@ public interface IVisVisitorRegisterService
|
|||||||
void saveVisitorRegister(SysPeople people1);
|
void saveVisitorRegister(SysPeople people1);
|
||||||
|
|
||||||
void updateVisitorRegisterByOpenid(SysPeople sysPeople);
|
void updateVisitorRegisterByOpenid(SysPeople sysPeople);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询访客注册
|
||||||
|
*
|
||||||
|
* @return 访客注册
|
||||||
|
*/
|
||||||
|
public VisVisitorRegister getVisitorInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,4 +247,6 @@ public interface IVisitorService
|
|||||||
String queryReviewProcess(Visitor visitor);
|
String queryReviewProcess(Visitor visitor);
|
||||||
|
|
||||||
int queryVisitorReviewProcessCount(Long id);
|
int queryVisitorReviewProcessCount(Long id);
|
||||||
|
|
||||||
|
List<Visitor> selectAppVisitorList(Visitor visitor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ package com.dcsoft.system.visitor.service.impl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.dcsoft.common.core.exception.ServiceException;
|
||||||
|
import com.dcsoft.common.core.utils.StringUtils;
|
||||||
|
import com.dcsoft.common.security.utils.SecurityUtils;
|
||||||
|
import com.dcsoft.system.api.model.LoginUser;
|
||||||
import com.dcsoft.system.domain.SysPeople;
|
import com.dcsoft.system.domain.SysPeople;
|
||||||
import com.dcsoft.system.visitor.domain.VisVisitorRegister;
|
import com.dcsoft.system.visitor.domain.VisVisitorRegister;
|
||||||
import com.dcsoft.system.visitor.mapper.VisVisitorRegisterMapper;
|
import com.dcsoft.system.visitor.mapper.VisVisitorRegisterMapper;
|
||||||
@@ -50,6 +55,15 @@ public class VisVisitorRegisterServiceImpl implements IVisVisitorRegisterService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertVisVisitorRegister(VisVisitorRegister visVisitorRegister) {
|
public int insertVisVisitorRegister(VisVisitorRegister visVisitorRegister) {
|
||||||
|
if (null == visVisitorRegister.getUserId()) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
visVisitorRegister.setUserId(loginUser.getUserid());
|
||||||
|
}
|
||||||
|
|
||||||
|
VisVisitorRegister visVisitor = visVisitorRegisterMapper.selectVisVisitorRegisterByUserId(visVisitorRegister.getUserId());
|
||||||
|
if (ObjectUtil.isNotNull(visVisitor) && StringUtils.isNotBlank(visVisitor.getId())) {
|
||||||
|
throw new ServiceException("不可重复注册访客信息!");
|
||||||
|
}
|
||||||
return visVisitorRegisterMapper.insertVisVisitorRegister(visVisitorRegister);
|
return visVisitorRegisterMapper.insertVisVisitorRegister(visVisitorRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,4 +114,17 @@ public class VisVisitorRegisterServiceImpl implements IVisVisitorRegisterService
|
|||||||
public void updateVisitorRegisterByOpenid(SysPeople sysPeople) {
|
public void updateVisitorRegisterByOpenid(SysPeople sysPeople) {
|
||||||
visVisitorRegisterMapper.updateVisitorRegisterByOpenid(sysPeople);
|
visVisitorRegisterMapper.updateVisitorRegisterByOpenid(sysPeople);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询访客注册
|
||||||
|
*
|
||||||
|
* @return 访客注册
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public VisVisitorRegister getVisitorInfo() {
|
||||||
|
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
Long userId = loginUser.getUserid();
|
||||||
|
return visVisitorRegisterMapper.selectVisVisitorRegisterByUserId(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.dcsoft.system.visitor.service.impl;
|
|||||||
import com.dcsoft.common.core.constant.Constants;
|
import com.dcsoft.common.core.constant.Constants;
|
||||||
import com.dcsoft.common.core.domain.R;
|
import com.dcsoft.common.core.domain.R;
|
||||||
import com.dcsoft.common.core.exception.ServiceException;
|
import com.dcsoft.common.core.exception.ServiceException;
|
||||||
|
import com.dcsoft.common.core.utils.CollUtil;
|
||||||
import com.dcsoft.common.core.web.page.TableDataInfoPage;
|
import com.dcsoft.common.core.web.page.TableDataInfoPage;
|
||||||
import com.dcsoft.common.datascope.annotation.DataScope;
|
import com.dcsoft.common.datascope.annotation.DataScope;
|
||||||
import com.dcsoft.system.api.RemoteFileService;
|
import com.dcsoft.system.api.RemoteFileService;
|
||||||
@@ -668,4 +669,36 @@ public class VisitorServiceImpl implements IVisitorService {
|
|||||||
return visitorMapper.queryVisitorReviewProcessCount(id);
|
return visitorMapper.queryVisitorReviewProcessCount(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询访客信息列表
|
||||||
|
*
|
||||||
|
* @param visitor 访客信息
|
||||||
|
* @return 访客信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
|
public List<Visitor> selectAppVisitorList(Visitor visitor) {
|
||||||
|
//查询我作为随访人员的申请信息主键ids
|
||||||
|
List<Long> ids = visitorMapper.selectAppVisitorFollow(visitor);
|
||||||
|
|
||||||
|
//查询我申请的访客信息
|
||||||
|
visitor.setIds(ids);
|
||||||
|
List<Visitor> visitors = visitorMapper.selectAppVisitorList(visitor);
|
||||||
|
|
||||||
|
List<Long> collect = visitors.stream().map(Visitor::getId).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(collect)) {
|
||||||
|
List<CheckCodeVo> checkCodeVos = visitorMapper.queryCode(collect);
|
||||||
|
visitors.forEach(visit -> {
|
||||||
|
checkCodeVos.forEach(code -> {
|
||||||
|
if (StringUtils.equals(String.valueOf(visit.getId()), code.getVisitorId())) {
|
||||||
|
visit.setQrCode(code.getCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return visitors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,5 +236,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryJuniorBranch" resultType="com.dcsoft.system.domain.SysBranch">
|
||||||
|
WITH RECURSIVE subdepartments AS (
|
||||||
|
SELECT id, name, parent_id
|
||||||
|
FROM sys_branch
|
||||||
|
WHERE parent_id = #{branchId}
|
||||||
|
UNION ALL
|
||||||
|
SELECT d.id, d.name, d.parent_id
|
||||||
|
FROM sys_branch d
|
||||||
|
JOIN subdepartments sd ON d.parent_id = sd.id
|
||||||
|
)
|
||||||
|
SELECT * FROM subdepartments
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -15,10 +15,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
|
<result property="dictType" column="dict_type" />
|
||||||
|
<result property="dictValue" column="dict_value" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNoticeVo">
|
<sql id="selectNoticeVo">
|
||||||
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
|
select notice_id,
|
||||||
|
notice_title,
|
||||||
|
notice_type,
|
||||||
|
cast(notice_content as char) as notice_content,
|
||||||
|
status,
|
||||||
|
dict_type,
|
||||||
|
dict_value,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
remark
|
||||||
from sys_notice
|
from sys_notice
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -41,6 +54,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectNotice" resultMap="SysNoticeResult">
|
||||||
|
<include refid="selectNoticeVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="dictType != null and dictType != ''">
|
||||||
|
AND dict_type = #{dictType}
|
||||||
|
</if>
|
||||||
|
<if test="dictValue != null and dictValue != ''">
|
||||||
|
AND dict_value = #{dictValue}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertNotice" parameterType="SysNotice">
|
<insert id="insertNotice" parameterType="SysNotice">
|
||||||
insert into sys_notice (
|
insert into sys_notice (
|
||||||
@@ -48,6 +72,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
|
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
|
||||||
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
|
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
|
||||||
<if test="status != null and status != '' ">status, </if>
|
<if test="status != null and status != '' ">status, </if>
|
||||||
|
<if test="dictType != null and dictType != '' ">dict_type, </if>
|
||||||
|
<if test="dictValue != null and dictValue != '' ">dict_value, </if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
create_time
|
create_time
|
||||||
@@ -56,6 +82,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
|
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
|
||||||
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
|
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
|
||||||
<if test="status != null and status != ''">#{status}, </if>
|
<if test="status != null and status != ''">#{status}, </if>
|
||||||
|
<if test="dictType != null and dictType != ''">#{dictType}, </if>
|
||||||
|
<if test="dictValue != null and dictValue != ''">#{dictValue}, </if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="nickName" column="nick_name" />
|
<result property="nickName" column="nick_name" />
|
||||||
<result property="phone" column="phone" />
|
<result property="phone" column="phone" />
|
||||||
<result property="openid" column="openid" />
|
<result property="openid" column="openid" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="idcard" column="idcard" />
|
||||||
|
<result property="visitingUnit" column="visiting_unit" />
|
||||||
|
<result property="avatar" column="avatar" />
|
||||||
<result property="deleteState" column="delete_state" />
|
<result property="deleteState" column="delete_state" />
|
||||||
<result property="createdBy" column="created_by" />
|
<result property="createdBy" column="created_by" />
|
||||||
<result property="createdTime" column="created_time" />
|
<result property="createdTime" column="created_time" />
|
||||||
@@ -18,7 +22,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectVisVisitorRegisterVo">
|
<sql id="selectVisVisitorRegisterVo">
|
||||||
select id, user_name, nick_name, phone, openid, delete_state, created_by, created_time, updated_by, updated_time from vis_visitor_register
|
select id,
|
||||||
|
user_name,
|
||||||
|
nick_name,
|
||||||
|
phone,
|
||||||
|
openid,
|
||||||
|
user_id,
|
||||||
|
idcard,
|
||||||
|
visiting_unit,
|
||||||
|
avatar,
|
||||||
|
delete_state,
|
||||||
|
created_by,
|
||||||
|
created_time,
|
||||||
|
updated_by,
|
||||||
|
updated_time
|
||||||
|
from vis_visitor_register
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectVisVisitorRegisterList" parameterType="VisVisitorRegister" resultMap="VisVisitorRegisterResult">
|
<select id="selectVisVisitorRegisterList" parameterType="VisVisitorRegister" resultMap="VisVisitorRegisterResult">
|
||||||
@@ -44,11 +62,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<insert id="insertVisVisitorRegister" parameterType="VisVisitorRegister">
|
<insert id="insertVisVisitorRegister" parameterType="VisVisitorRegister">
|
||||||
insert into vis_visitor_register
|
insert into vis_visitor_register
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">id,</if>
|
id,
|
||||||
<if test="userName != null">user_name,</if>
|
<if test="userName != null">user_name,</if>
|
||||||
<if test="nickName != null">nick_name,</if>
|
<if test="nickName != null">nick_name,</if>
|
||||||
<if test="phone != null">phone,</if>
|
<if test="phone != null">phone,</if>
|
||||||
<if test="openid != null">openid,</if>
|
<if test="openid != null">openid,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="idcard != null">idcard,</if>
|
||||||
|
<if test="visitingUnit != null">visiting_unit,</if>
|
||||||
|
<if test="avatar != null">avatar,</if>
|
||||||
<if test="deleteState != null">delete_state,</if>
|
<if test="deleteState != null">delete_state,</if>
|
||||||
<if test="createdBy != null">created_by,</if>
|
<if test="createdBy != null">created_by,</if>
|
||||||
<if test="createdTime != null">created_time,</if>
|
<if test="createdTime != null">created_time,</if>
|
||||||
@@ -56,11 +78,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updatedTime != null">updated_time,</if>
|
<if test="updatedTime != null">updated_time,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">#{id},</if>
|
REPLACE(uuid(), '-', ''),
|
||||||
<if test="userName != null">#{userName},</if>
|
<if test="userName != null">#{userName},</if>
|
||||||
<if test="nickName != null">#{nickName},</if>
|
<if test="nickName != null">#{nickName},</if>
|
||||||
<if test="phone != null">#{phone},</if>
|
<if test="phone != null">#{phone},</if>
|
||||||
<if test="openid != null">#{openid},</if>
|
<if test="openid != null">#{openid},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="idcard != null">#{idcard},</if>
|
||||||
|
<if test="visitingUnit != null">#{visitingUnit},</if>
|
||||||
|
<if test="avatar != null">#{avatar},</if>
|
||||||
<if test="deleteState != null">#{deleteState},</if>
|
<if test="deleteState != null">#{deleteState},</if>
|
||||||
<if test="createdBy != null">#{createdBy},</if>
|
<if test="createdBy != null">#{createdBy},</if>
|
||||||
<if test="createdTime != null">#{createdTime},</if>
|
<if test="createdTime != null">#{createdTime},</if>
|
||||||
@@ -76,6 +102,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="nickName != null">nick_name = #{nickName},</if>
|
<if test="nickName != null">nick_name = #{nickName},</if>
|
||||||
<if test="phone != null">phone = #{phone},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
||||||
<if test="openid != null">openid = #{openid},</if>
|
<if test="openid != null">openid = #{openid},</if>
|
||||||
|
<if test="idcard != null">idcard = #{idcard},</if>
|
||||||
|
<if test="visitingUnit != null">visiting_unit = #{visitingUnit},</if>
|
||||||
|
<if test="avatar != null">avatar = #{avatar},</if>
|
||||||
<if test="deleteState != null">delete_state = #{deleteState},</if>
|
<if test="deleteState != null">delete_state = #{deleteState},</if>
|
||||||
<if test="createdBy != null">created_by = #{createdBy},</if>
|
<if test="createdBy != null">created_by = #{createdBy},</if>
|
||||||
<if test="createdTime != null">created_time = #{createdTime},</if>
|
<if test="createdTime != null">created_time = #{createdTime},</if>
|
||||||
@@ -108,4 +137,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="queryVisitorRegister" resultType="java.lang.String">
|
<select id="queryVisitorRegister" resultType="java.lang.String">
|
||||||
select id from vis_visitor_register where user_name = #{name} and phone = #{phone}
|
select id from vis_visitor_register where user_name = #{name} and phone = #{phone}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectVisVisitorRegisterByUserId" parameterType="Long" resultMap="VisVisitorRegisterResult">
|
||||||
|
select
|
||||||
|
vvr.id,
|
||||||
|
vvr.user_name as user_name,
|
||||||
|
IFNULL(vvr.phone,su.phonenumber) as phone,
|
||||||
|
su.openid,
|
||||||
|
su.user_id,
|
||||||
|
vvr.user_id,
|
||||||
|
vvr.idcard,
|
||||||
|
vvr.visiting_unit,
|
||||||
|
vvr.avatar,
|
||||||
|
vvr.delete_state,
|
||||||
|
vvr.created_by,
|
||||||
|
vvr.created_time,
|
||||||
|
vvr.updated_by,
|
||||||
|
vvr.updated_time
|
||||||
|
from sys_user su left join vis_visitor_register vvr on vvr.user_id = su.user_id
|
||||||
|
where su.user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -808,4 +808,106 @@
|
|||||||
where visitor_id = #{id} and vvar.reviewer = vv.user_id
|
where visitor_id = #{id} and vvar.reviewer = vv.user_id
|
||||||
order by ifnull(createdTime, 'zzz')
|
order by ifnull(createdTime, 'zzz')
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAppVisitorFollow" resultType="java.lang.Long">
|
||||||
|
select distinct
|
||||||
|
vv.parent_id
|
||||||
|
from vis_visitor vv left join vis_visitor vv1 on vv.parent_id = vv1.id
|
||||||
|
where vv.parent_id is not null
|
||||||
|
<choose>
|
||||||
|
<when test="examineState != null and examineState == 3">
|
||||||
|
and vv1.examine_state = '0'
|
||||||
|
</when>
|
||||||
|
<when test="examineState != null and examineState != 3">
|
||||||
|
and vv1.examine_state = #{examineState}
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
and vv.phone = #{createBy}
|
||||||
|
and vv1.park = #{park}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectAppVisitorList" parameterType="Visitor" resultMap="VisitorResult">
|
||||||
|
select distinct
|
||||||
|
vv.id,
|
||||||
|
vv.name,
|
||||||
|
vv.phone,
|
||||||
|
vv.sex,
|
||||||
|
vv.avatar,
|
||||||
|
vv.idcard,
|
||||||
|
vv.car_no,
|
||||||
|
vv.user_id,
|
||||||
|
vv.dept_id,
|
||||||
|
vv.flag,
|
||||||
|
vv.start_time,
|
||||||
|
vv.end_time,
|
||||||
|
vv.matter,
|
||||||
|
vv.res,
|
||||||
|
vv.guid,
|
||||||
|
vv.face_guid,
|
||||||
|
vv.remark,
|
||||||
|
vv.create_by,
|
||||||
|
vv.create_time,
|
||||||
|
vv.update_by,
|
||||||
|
vv.parent_id,
|
||||||
|
vv.update_time,
|
||||||
|
vve.admittance_start,
|
||||||
|
vve.admittance_end,
|
||||||
|
vve.point_id,
|
||||||
|
sb.name branch_name,
|
||||||
|
if(sp.name is not null, sp.name, vv.user_name) people_name,
|
||||||
|
vve.examine,
|
||||||
|
vv.in_time,
|
||||||
|
vv.out_time,
|
||||||
|
vve.create_by examine_name,
|
||||||
|
sp.phone people_phone,
|
||||||
|
vv.source,
|
||||||
|
sp.position,
|
||||||
|
vv.position visitorPosition,
|
||||||
|
vv.visiting_unit,
|
||||||
|
vv.reviewer2,
|
||||||
|
vv.reviewer3,
|
||||||
|
vv.instance_id,
|
||||||
|
vv.examine_state,
|
||||||
|
vv.visitor_type,
|
||||||
|
vv.park,
|
||||||
|
vv.current_node,
|
||||||
|
vv.user_task_count,
|
||||||
|
vv.procdef_id,
|
||||||
|
vv.proc_id
|
||||||
|
from vis_visitor vv
|
||||||
|
left join vis_visitor_examine vve on vv.id = vve.visitor_id
|
||||||
|
left join sys_branch sb on vv.dept_id = sb.id
|
||||||
|
left join sys_people sp on vv.user_id = sp.id
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''">and vv.name like concat('%', #{name}, '%')</if>
|
||||||
|
<if test="createBy != null ">and vv.create_by = #{createBy}</if>
|
||||||
|
<if test="examineState != null and examineState != 3">and vv.examine_state = #{examineState}</if>
|
||||||
|
<if test="park != null and park != ''">and vv.park = #{park}</if>
|
||||||
|
<if test="visitorType != null">and vv.visitor_type = #{visitorType}</if>
|
||||||
|
and vv.parent_id is null
|
||||||
|
<if test="ids != null and ids.size() > 0">
|
||||||
|
or vv.id in
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryCode" resultType="com.dcsoft.system.visitor.domain.CheckCodeVo">
|
||||||
|
SELECT
|
||||||
|
vcc.visitor_id as visitorId,
|
||||||
|
vcc.`code`
|
||||||
|
FROM
|
||||||
|
vis_check_code vcc
|
||||||
|
JOIN (SELECT max(created_time) as created_time, visitor_id FROM vis_check_code GROUP BY visitor_id) t ON vcc.created_time = t.created_time
|
||||||
|
left join vis_visitor vv on vv.examine_state = 0 and vcc.visitor_id = vv.id
|
||||||
|
WHERE t.visitor_id IN
|
||||||
|
<foreach collection="list" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
and vv.examine_state = 0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user