7 changed files with 680 additions and 0 deletions
@ -0,0 +1,137 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.dto.VerificationFreeUserDTO; |
||||
|
import com.elink.esua.epdc.service.VerificationFreeUserService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 免校验PC用户(针对隐私数据,免验证码校验) |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-12-22 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("verificationfreeuser") |
||||
|
public class VerificationFreeUserController { |
||||
|
|
||||
|
@Autowired |
||||
|
private VerificationFreeUserService verificationFreeUserService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<VerificationFreeUserDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<VerificationFreeUserDTO> page = verificationFreeUserService.page(params); |
||||
|
return new Result<PageData<VerificationFreeUserDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<VerificationFreeUserDTO> get(@PathVariable("id") String id){ |
||||
|
VerificationFreeUserDTO data = verificationFreeUserService.get(id); |
||||
|
return new Result<VerificationFreeUserDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody VerificationFreeUserDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
verificationFreeUserService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody VerificationFreeUserDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
verificationFreeUserService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
verificationFreeUserService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 隐私数据导出前,校验当前登录人 |
||||
|
* 返回 code:0 表示免校验 |
||||
|
* 返回 code:1 表示需要校验 msg 中返回的手机号 |
||||
|
* |
||||
|
* @param |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 10:47 2021-12-22 |
||||
|
**/ |
||||
|
@GetMapping("preCheckLoginUser") |
||||
|
public Result preCheckLoginUser() { |
||||
|
return verificationFreeUserService.preCheckLoginUser(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 给当前登录用户,发送短信 |
||||
|
* |
||||
|
* @param |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 14:57 2021-12-22 |
||||
|
**/ |
||||
|
@GetMapping("sendSMS") |
||||
|
public Result sendSMS() { |
||||
|
return verificationFreeUserService.sendSMS(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 验证码校验 |
||||
|
* |
||||
|
* @param smsCode |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 16:22 2021-12-22 |
||||
|
**/ |
||||
|
@GetMapping("postCheckSMSCode/{smsCode}") |
||||
|
public Result postCheckSMSCode(@PathVariable("smsCode") String smsCode) { |
||||
|
return verificationFreeUserService.postCheckSMSCode(smsCode); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 设置系统用户,对于隐私数据的访问权限 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 11:06 2021-12-23 |
||||
|
**/ |
||||
|
@PostMapping("setAccessPermissions") |
||||
|
public Result setAccessPermissions(@RequestBody VerificationFreeUserDTO dto) { |
||||
|
return verificationFreeUserService.setAccessPermissions(dto); |
||||
|
} |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.dto.VerificationFreeUserDTO; |
||||
|
import com.elink.esua.epdc.entity.VerificationFreeUserEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 免校验PC用户(针对隐私数据,免验证码校验) |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-12-22 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface VerificationFreeUserDao extends BaseDao<VerificationFreeUserEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 是否需要校验当前登录人的手机号 |
||||
|
* true 为不需要 |
||||
|
* false 为需要 |
||||
|
* |
||||
|
* @param sysUserId |
||||
|
* @return java.lang.Boolean |
||||
|
* @Author zhangyong |
||||
|
* @Date 09:52 2021-12-23 |
||||
|
**/ |
||||
|
Boolean isVerificationBySysUserId(@Param("sysUserId") Long sysUserId); |
||||
|
|
||||
|
/** |
||||
|
* 指定系统用户,是否已设置过 隐私数据权限 |
||||
|
* true 设置过 |
||||
|
* false 未设置 |
||||
|
* |
||||
|
* @param sysUserId |
||||
|
* @return java.lang.Boolean |
||||
|
* @Author zhangyong |
||||
|
* @Date 09:52 2021-12-23 |
||||
|
**/ |
||||
|
Boolean isExistBySysUserId(@Param("sysUserId") Long sysUserId); |
||||
|
|
||||
|
/** |
||||
|
* 查询系统用户信息 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<com.elink.esua.epdc.dto.VerificationFreeUserDTO> |
||||
|
* @Author zhangyong |
||||
|
* @Date 09:54 2021-12-23 |
||||
|
**/ |
||||
|
List<VerificationFreeUserDTO> selectListSysUserInfo(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 修改系统用户,访问隐私数据的数据权限 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @Author zhangyong |
||||
|
* @Date 11:10 2021-12-23 |
||||
|
**/ |
||||
|
void updateVerificationFlagBySysUserId(VerificationFreeUserDTO dto); |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 免校验PC用户(针对隐私数据,免验证码校验) |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-12-22 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_verification_free_user") |
||||
|
public class VerificationFreeUserEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 用户管理表主键 |
||||
|
*/ |
||||
|
private Long sysUserId; |
||||
|
|
||||
|
/** |
||||
|
* 校验标识 0:否,1:是 |
||||
|
*/ |
||||
|
private String verificationFlag; |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.elink.esua.epdc.feign; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.feign.fallback.MessageFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
|
||||
|
/** |
||||
|
* 文件对象模块 |
||||
|
* |
||||
|
* @Author zy |
||||
|
* @Date 2019/9/8 18:24 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_MESSAGE_SERVER, fallback = MessageFeignClientFallback.class) |
||||
|
public interface MessageFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* 发送短信验证码 |
||||
|
* |
||||
|
* @param mobile |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author yujintao |
||||
|
* @date 2019/9/11 20:59 |
||||
|
*/ |
||||
|
@GetMapping("message/epdc-app/sms/sendCode") |
||||
|
Result sendCode(String mobile); |
||||
|
|
||||
|
} |
@ -0,0 +1,138 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.VerificationFreeUserDTO; |
||||
|
import com.elink.esua.epdc.entity.VerificationFreeUserEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 免校验PC用户(针对隐私数据,免验证码校验) |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-12-22 |
||||
|
*/ |
||||
|
public interface VerificationFreeUserService extends BaseService<VerificationFreeUserEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<VerificationFreeUserDTO> |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
PageData<VerificationFreeUserDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<VerificationFreeUserDTO> |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
List<VerificationFreeUserDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return VerificationFreeUserDTO |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
VerificationFreeUserDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
void save(VerificationFreeUserDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
void update(VerificationFreeUserDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-12-22 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 隐私数据导出前,校验当前登录人 |
||||
|
* 返回 code:0 表示免校验 |
||||
|
* 返回 code:1 表示需要校验 msg 中返回的手机号 |
||||
|
* |
||||
|
* @param |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 10:47 2021-12-22 |
||||
|
**/ |
||||
|
Result preCheckLoginUser(); |
||||
|
|
||||
|
/** |
||||
|
* 给当前登录用户,发送短信 |
||||
|
* |
||||
|
* @param |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 14:57 2021-12-22 |
||||
|
**/ |
||||
|
Result sendSMS(); |
||||
|
|
||||
|
/** |
||||
|
* 验证码校验 |
||||
|
* |
||||
|
* @param smsCode |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 16:22 2021-12-22 |
||||
|
**/ |
||||
|
Result postCheckSMSCode(String smsCode); |
||||
|
|
||||
|
/** |
||||
|
* 设置系统用户,对于隐私数据的访问权限 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author zhangyong |
||||
|
* @Date 11:06 2021-12-23 |
||||
|
**/ |
||||
|
Result setAccessPermissions(VerificationFreeUserDTO dto); |
||||
|
} |
@ -0,0 +1,173 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dao.VerificationFreeUserDao; |
||||
|
import com.elink.esua.epdc.dto.VerificationFreeUserDTO; |
||||
|
import com.elink.esua.epdc.entity.VerificationFreeUserEntity; |
||||
|
import com.elink.esua.epdc.feign.MessageFeignClient; |
||||
|
import com.elink.esua.epdc.service.VerificationFreeUserService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 免校验PC用户(针对隐私数据,免验证码校验) |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-12-22 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class VerificationFreeUserServiceImpl extends BaseServiceImpl<VerificationFreeUserDao, VerificationFreeUserEntity> implements VerificationFreeUserService { |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
@Autowired |
||||
|
private MessageFeignClient messageFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<VerificationFreeUserDTO> page(Map<String, Object> params) { |
||||
|
IPage<VerificationFreeUserDTO> page = getPage(params); |
||||
|
List<VerificationFreeUserDTO> list = baseDao.selectListSysUserInfo(params); |
||||
|
return new PageData<>(list, page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<VerificationFreeUserDTO> list(Map<String, Object> params) { |
||||
|
List<VerificationFreeUserEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, VerificationFreeUserDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<VerificationFreeUserEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<VerificationFreeUserEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public VerificationFreeUserDTO get(String id) { |
||||
|
VerificationFreeUserEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, VerificationFreeUserDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(VerificationFreeUserDTO dto) { |
||||
|
VerificationFreeUserEntity entity = ConvertUtils.sourceToTarget(dto, VerificationFreeUserEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(VerificationFreeUserDTO dto) { |
||||
|
VerificationFreeUserEntity entity = ConvertUtils.sourceToTarget(dto, VerificationFreeUserEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result preCheckLoginUser() { |
||||
|
// 如果当前登录账号,设置了免校验,则直接下载隐私数据
|
||||
|
UserDetail user = SecurityUser.getUser(); |
||||
|
if (user == null) { |
||||
|
throw new RenException("用户未登录"); |
||||
|
} |
||||
|
// 免校验么?
|
||||
|
Boolean noVerification = baseDao.isVerificationBySysUserId(user.getId()); |
||||
|
if (!noVerification) { |
||||
|
// 如果当前登录账号的手机号在 30分钟内校验成功过,则本次下载免校验
|
||||
|
String phoneKey = RedisKeys.getPrivaceDataEpidemicUserInfoKey(user.getMobile()); |
||||
|
Object value = redisUtils.get(phoneKey); |
||||
|
if (null == value) { |
||||
|
// 手机号需校验
|
||||
|
Result result = new Result(); |
||||
|
result.setCode(NumConstant.ONE); |
||||
|
result.setMsg(user.getMobile()); |
||||
|
return result; |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result sendSMS() { |
||||
|
UserDetail user = SecurityUser.getUser(); |
||||
|
if (user == null) { |
||||
|
throw new RenException("用户未登录"); |
||||
|
} |
||||
|
return messageFeignClient.sendCode(user.getMobile()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result postCheckSMSCode(String smsCode) { |
||||
|
UserDetail user = SecurityUser.getUser(); |
||||
|
if (user == null) { |
||||
|
throw new RenException("用户未登录"); |
||||
|
} |
||||
|
String phoneKey = RedisKeys.getPhoneSmsCodeKey(user.getMobile()); |
||||
|
Object redisSmsCode = redisUtils.get(phoneKey); |
||||
|
if (null == redisSmsCode || !redisSmsCode.toString().equals(smsCode)) { |
||||
|
throw new RenException("验证码错误"); |
||||
|
} |
||||
|
redisUtils.set(RedisKeys.getPrivaceDataEpidemicUserInfoKey(user.getMobile()), "verified", RedisUtils.MINUTE_THIRTY_EXPIRE); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result setAccessPermissions(VerificationFreeUserDTO dto) { |
||||
|
Boolean existBySysUserId = baseDao.isExistBySysUserId(dto.getSysUserId()); |
||||
|
if (existBySysUserId) { |
||||
|
// 设置过了,修改
|
||||
|
baseDao.updateVerificationFlagBySysUserId(dto); |
||||
|
} else { |
||||
|
// 未设置,新增
|
||||
|
VerificationFreeUserEntity entity = ConvertUtils.sourceToTarget(dto, VerificationFreeUserEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
return new Result(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.elink.esua.epdc.dao.VerificationFreeUserDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.entity.VerificationFreeUserEntity" id="verificationFreeUserMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="sysUserId" column="SYS_USER_ID"/> |
||||
|
<result property="verificationFlag" column="VERIFICATION_FLAG"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<select id="isVerificationBySysUserId" resultType="java.lang.Boolean"> |
||||
|
SELECT |
||||
|
SYS_USER_ID = #{sysUserId,jdbcType=BIGINT} |
||||
|
FROM epdc_verification_free_user |
||||
|
WHERE del_flag = '0' |
||||
|
AND VERIFICATION_FLAG = '1' |
||||
|
LIMIT 1; |
||||
|
</select> |
||||
|
|
||||
|
<select id="isExistBySysUserId" resultType="java.lang.Boolean"> |
||||
|
SELECT |
||||
|
SYS_USER_ID = #{sysUserId,jdbcType=BIGINT} |
||||
|
FROM epdc_verification_free_user |
||||
|
WHERE del_flag = '0' |
||||
|
LIMIT 1; |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectListSysUserInfo" resultType="com.elink.esua.epdc.dto.VerificationFreeUserDTO"> |
||||
|
SELECT |
||||
|
s.id, |
||||
|
s.username, |
||||
|
s.real_name, |
||||
|
s.email, |
||||
|
s.mobile, |
||||
|
d.`NAME` deptName, |
||||
|
IFNULL(v.VERIFICATION_FLAG, 0) VERIFICATION_FLAG, |
||||
|
v.UPDATED_TIME |
||||
|
FROM sys_user s |
||||
|
LEFT JOIN sys_dept d ON s.dept_id = d.id AND d.del_flag = 0 |
||||
|
LEFT JOIN epdc_verification_free_user v ON s.id = v.SYS_USER_ID AND v.DEL_FLAG = '0' |
||||
|
WHERE s.del_flag = 0 |
||||
|
AND s.super_admin = 0 |
||||
|
AND s.`status` = 1 |
||||
|
<if test="username != null and username.trim() != ''"> |
||||
|
AND s.username LIKE CONCAT( '%', #{username}, '%' ) |
||||
|
</if> |
||||
|
<if test="realName != null and realName.trim() != ''"> |
||||
|
AND s.real_name LIKE CONCAT( '%', #{realName}, '%' ) |
||||
|
</if> |
||||
|
<if test="mobile != null and mobile.trim() != ''"> |
||||
|
AND s.mobile LIKE CONCAT( '%', #{mobile}, '%' ) |
||||
|
</if> |
||||
|
ORDER BY IFNULL(v.VERIFICATION_FLAG, 0) DESC, IFNULL(v.UPDATED_TIME, d.update_date) DESC |
||||
|
</select> |
||||
|
|
||||
|
<update id="updateVerificationFlagBySysUserId"> |
||||
|
UPDATE epdc_verification_free_user |
||||
|
SET |
||||
|
VERIFICATION_FLAG = #{verificationFlag,jdbcType=VARCHAR}, |
||||
|
UPDATED_TIME = now() |
||||
|
WHERE SYS_USER_ID = #{sysUserId,jdbcType=BIGINT} |
||||
|
AND del_flag = '0' |
||||
|
</update> |
||||
|
</mapper> |
Loading…
Reference in new issue