代码提交

This commit is contained in:
glj 2023-04-15 17:33:41 +08:00
parent 4d0aeb8bc6
commit bbfb15fc3c
9 changed files with 211 additions and 32 deletions

View File

@ -0,0 +1,41 @@
package com.kening.vordm.vo;
import lombok.Data;
@Data
public class UserVo {
private Long id;
/**
* 验证码
*/
private String code;
/**
* 邮箱
*/
private String email;
/**
* 密码1
*/
private String password;
/**
* 密码2
*/
private String password2;
/**
* 验证码key
*/
private String key;
/**
* 机构Id
*/
private String tenantId;
}

View File

@ -11,7 +11,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
@SpringCloudApplication
public class VoRdmApplication {
public static void main(String[] args) {
BladeApplication.run("yyhouc-"+CommonConstant.KN_VORDM_MODULE_NAME, VoRdmApplication.class, args);
BladeApplication.run("glj-"+CommonConstant.KN_VORDM_MODULE_NAME, VoRdmApplication.class, args);
// BladeApplication.run("zqq-" + CommonConstant.KN_VORDM_MODULE_NAME, VoRdmApplication.class, args);
}
}

View File

@ -0,0 +1,50 @@
package com.kening.vordm.controller;
import com.kening.vordm.service.DisasterInfoService;
import com.kening.vordm.service.EmailService;
import com.kening.vordm.vo.UserVo;
import lombok.RequiredArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.mail.MessagingException;
@RestController
@RequiredArgsConstructor
@RequestMapping("/ui/login")
public class LoginController {
//实体数据服务层
private final DisasterInfoService disasterInfoService;
//邮箱发送服务
private final EmailService emailService;
/**
* 新增用户信息
*
* @param userVo
* @return
*/
@PostMapping("/saveUserData")
public R saveUserData(@RequestBody UserVo userVo) {
return disasterInfoService.saveUserData(userVo);
}
/**
* 邮箱发送
* @param userVo
* @return
* @throws MessagingException
*/
@PostMapping("/sendUserPasswordEmail")
public R sendUserPasswordEmail(@RequestBody UserVo userVo) throws MessagingException {
return emailService.sendUserPasswordEmail(userVo);
}
}

View File

@ -4,12 +4,10 @@ package com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kening.vordm.entity.DisasterInfo;
import com.kening.vordm.vo.CallForHelpVo;
import com.kening.vordm.vo.DisasterMangerInfo;
import com.kening.vordm.vo.GroupByUse;
import com.kening.vordm.vo.UserTenantVo;
import com.kening.vordm.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
import org.springblade.core.secure.BladeUser;
import java.util.List;
@ -49,4 +47,10 @@ public interface DisasterInfoMapper extends BaseMapper<DisasterInfo> {
List<GroupByUse> getLeft2Data();
List<CallForHelpVo> page(IPage page,@Param("callForHelpVo" )CallForHelpVo callForHelpVo);
Integer getUserEmail(@Param("email") String email);
Integer saveUserData(@Param("userVo") UserVo userVo);
UserVo getUserByEmail(String email);
}

View File

@ -37,6 +37,10 @@
d.disaster_type,d.disaster_time,d.disaster_country,
m.organization
</sql>
<insert id="saveUserData">
insert into blade_user (tenant_id,password,email,status,is_deleted)
values (#{userVo.tenantId},#{userVo.password},#{userVo.email},1,0);
</insert>
<select id="getDisasterInfoDetail" resultType="com.kening.vordm.entity.DisasterInfo">
select
@ -158,4 +162,23 @@
</where>
order by d.upload_time desc
</select>
<select id="getUserEmail" resultType="java.lang.Integer">
select count(id) from blade_user
<where>
<if test="email != null and email != ''" >
email = #{email}
</if>
</where>
</select>
<select id="getUserByEmail" resultType="com.kening.vordm.vo.UserVo">
select password from blade_user
<where>
<if test="email != null and email != ''" >
email = #{email}
</if>
</where>
</select>
</mapper>

View File

@ -4,10 +4,8 @@ package com.kening.vordm.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.DisasterInfo;
import com.kening.vordm.vo.CallForHelpVo;
import com.kening.vordm.vo.DisasterMangerInfo;
import com.kening.vordm.vo.GroupByUse;
import com.kening.vordm.vo.UserTenantVo;
import com.kening.vordm.vo.*;
import org.springblade.core.tool.api.R;
import java.util.List;
@ -55,4 +53,6 @@ public interface DisasterInfoService extends IService<DisasterInfo> {
Boolean addVisitCount(Long id);
IPage<CallForHelpVo> page(IPage<CallForHelpVo> page, CallForHelpVo callForHelpVo);
R saveUserData(UserVo userVo);
}

View File

@ -2,6 +2,8 @@ package com.kening.vordm.service;
import com.kening.vordm.entity.Email;
import com.kening.vordm.vo.UserVo;
import org.springblade.core.tool.api.R;
import javax.mail.MessagingException;
@ -14,4 +16,6 @@ public interface EmailService {
void sendMimeMessage(Email email) throws MessagingException;
void sendTemplate(Email email) throws MessagingException;
R sendUserPasswordEmail(UserVo userVo) throws MessagingException;
}

View File

@ -6,11 +6,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.DisasterInfo;
import com.kening.vordm.mapper.DisasterInfoMapper;
import com.kening.vordm.service.DisasterInfoService;
import com.kening.vordm.vo.CallForHelpVo;
import com.kening.vordm.vo.DisasterMangerInfo;
import com.kening.vordm.vo.GroupByUse;
import com.kening.vordm.vo.UserTenantVo;
import com.kening.vordm.service.EmailService;
import com.kening.vordm.vo.*;
import lombok.RequiredArgsConstructor;
import org.springblade.common.cache.CacheNames;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -18,49 +22,53 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author G1393
* @description 针对表disaster_info(灾害信息表存储灾害信息)的数据库操作Service实现
* @createDate 2023-04-04 15:54:30
*/
* @author G1393
* @description 针对表disaster_info(灾害信息表存储灾害信息)的数据库操作Service实现
* @createDate 2023-04-04 15:54:30
*/
@Service
@RequiredArgsConstructor
public class DisasterInfoServiceImpl extends ServiceImpl<DisasterInfoMapper, DisasterInfo>
implements DisasterInfoService {
implements DisasterInfoService {
private final BladeRedis bladeRedis;
/**
* 返回指定的灾害条目
*
* @param type
* @param country
* @param time
* @param name
* @return
*/
public List<GroupByUse> getConditionData(String type, String country, String time, String name){
List<GroupByUse> disasterInfos=this.baseMapper.getSelectCondition(type,country,time,name);
public List<GroupByUse> getConditionData(String type, String country, String time, String name) {
List<GroupByUse> disasterInfos = this.baseMapper.getSelectCondition(type, country, time, name);
return disasterInfos;
}
/**
* 用于获取灾害id类型
*
* @param disasterInfo
* @return
*/
public List<Long> getDisasterId(DisasterInfo disasterInfo){
public List<Long> getDisasterId(DisasterInfo disasterInfo) {
QueryWrapper<DisasterInfo> qw = new QueryWrapper<>();
if (disasterInfo.getDisasterType()!=null){
qw.eq("disaster_type",disasterInfo.getDisasterType());
if (disasterInfo.getDisasterType() != null) {
qw.eq("disaster_type", disasterInfo.getDisasterType());
}
if (disasterInfo.getDisasterCountry()!=null){
qw.eq("disaster_country",disasterInfo.getDisasterCountry());
if (disasterInfo.getDisasterCountry() != null) {
qw.eq("disaster_country", disasterInfo.getDisasterCountry());
}
if (disasterInfo.getDisasterTime()!=null){
qw.eq("disaster_time",disasterInfo.getDisasterTime());
if (disasterInfo.getDisasterTime() != null) {
qw.eq("disaster_time", disasterInfo.getDisasterTime());
}
List<DisasterInfo> disasterInfos = this.baseMapper.selectList(qw);
List<Long> ids = new ArrayList<>();
if (!disasterInfos.isEmpty()){
if (!disasterInfos.isEmpty()) {
disasterInfos.stream().forEach(disasterInfo1 -> {
ids .add(disasterInfo1.getId());
ids.add(disasterInfo1.getId());
});
return ids;
}
@ -69,6 +77,7 @@ implements DisasterInfoService {
/**
* 获取债害详情信息
*
* @param id
* @return
*/
@ -79,14 +88,15 @@ implements DisasterInfoService {
/**
* 进行灾害信息的统计国家类型
*
* @param name
* @return
*/
public List<GroupByUse> getDisasterStatistics(String name){
public List<GroupByUse> getDisasterStatistics(String name) {
return this.baseMapper.getDisasterStatistics(name);
}
public IPage<DisasterMangerInfo> getHomeDisaster(IPage<DisasterMangerInfo> page, Integer respondStatus){
public IPage<DisasterMangerInfo> getHomeDisaster(IPage<DisasterMangerInfo> page, Integer respondStatus) {
List<DisasterMangerInfo> disasterMangerInfos = this.baseMapper.getHomeDisaster(page, respondStatus);
return page.setRecords(disasterMangerInfos);
}
@ -128,8 +138,30 @@ implements DisasterInfoService {
@Override
public IPage<CallForHelpVo> page(IPage<CallForHelpVo> page, CallForHelpVo callForHelpVo) {
return page.setRecords(this.baseMapper.page(page,callForHelpVo));
return page.setRecords(this.baseMapper.page(page, callForHelpVo));
}
@Override
public R saveUserData(UserVo userVo) {
//通过邮箱判断当前用户是否存在
Integer userEmail = this.baseMapper.getUserEmail(userVo.getEmail());
if (userEmail > 0) {
return R.data(1405, "The current email is already bound to a user");
}
// 获取验证码
String redisCode = bladeRedis.get(CacheNames.CAPTCHA_KEY + userVo.getKey());
// 判断验证码
if (userVo.getCode() == null || !StringUtil.equalsIgnoreCase(redisCode, userVo.getCode())) {
return R.data(1404, "Verification code error");
}
//密码
userVo.setPassword(DigestUtil.encrypt(userVo.getPassword()));
Integer integer = this.baseMapper.saveUserData(userVo);
return R.status(integer > 0);
}
}

View File

@ -1,8 +1,14 @@
package com.kening.vordm.service.impl;
import com.kening.vordm.entity.Email;
import com.kening.vordm.mapper.DisasterInfoMapper;
import com.kening.vordm.service.DisasterInfoService;
import com.kening.vordm.service.EmailService;
import com.kening.vordm.vo.UserVo;
import lombok.RequiredArgsConstructor;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
@ -30,6 +36,8 @@ public class EmailServiceImpl implements EmailService {
private final TemplateEngine templateEngine;
private final DisasterInfoMapper disasterInfoMapper;
@Value("${spring.mail.username}")
private String from;
@ -44,6 +52,23 @@ public class EmailServiceImpl implements EmailService {
javaMailSender.send(buildTemplateMail(email));
}
@Override
public R sendUserPasswordEmail(UserVo userVo) throws MessagingException {
//通过邮箱判断当前用户是否存在
UserVo bladeUser = disasterInfoMapper.getUserByEmail(userVo.getEmail());
if (bladeUser == null || bladeUser.getPassword()==null){
return R.data(1405, "There are currently no bound users for this email");
}
Email email = new Email();
email.setSubject("您的登录密码");
String encrypt = DigestUtil.encrypt(bladeUser.getPassword());
email.setText("邮箱为"+ userVo.getEmail()+ "的用户登录密码为:"+encrypt);
email.setHtmlText(false);
email.setTos(userVo.getEmail().split(","));
javaMailSender.send(buildMimeMessage(email));
return R.status(true);
}
/**
* 构建模板邮件
* @param email