验证码
parent
99063fcd8f
commit
e29df7e02c
|
|
@ -89,6 +89,10 @@
|
||||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.ruoyi.app.controller;
|
||||||
|
|
||||||
|
public class AppLoginController {
|
||||||
|
}
|
||||||
|
|
@ -3,15 +3,11 @@ package com.ruoyi.app.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -30,6 +26,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/school")
|
@RequestMapping("/school")
|
||||||
|
@Api(tags = "学校配置接口" , description = "学校配置接口")
|
||||||
public class AppSchoolController extends BaseController
|
public class AppSchoolController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -38,33 +35,42 @@ public class AppSchoolController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 查询学校配置列表
|
* 查询学校配置列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("app:school:list")
|
// @RequiresPermissions("app:school:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
|
@ApiOperation(value = "获取学校列表集合", notes = "获取学校列表集合", httpMethod = "GET")
|
||||||
public TableDataInfo list(AppSchool appSchool)
|
public TableDataInfo list(AppSchool appSchool)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
|
List<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
@GetMapping("/listAll")
|
||||||
|
@ApiOperation(value = "获取学校列表集合", notes = "获取学校列表集合", httpMethod = "GET")
|
||||||
|
public AjaxResult list(@RequestParam(value = "name",required = false) String name)
|
||||||
|
{
|
||||||
|
List<AppSchool> list = appSchoolService.selectAppSchoolAllList(name);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出学校配置列表
|
* 导出学校配置列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("app:school:export")
|
// @RequiresPermissions("app:school:export")
|
||||||
@Log(title = "学校配置", businessType = BusinessType.EXPORT)
|
// @Log(title = "学校配置", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
// @PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, AppSchool appSchool)
|
// public void export(HttpServletResponse response, AppSchool appSchool)
|
||||||
{
|
// {
|
||||||
List<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
|
// List<AppSchool> list = appSchoolService.selectAppSchoolList(appSchool);
|
||||||
ExcelUtil<AppSchool> util = new ExcelUtil<AppSchool>(AppSchool.class);
|
// ExcelUtil<AppSchool> util = new ExcelUtil<AppSchool>(AppSchool.class);
|
||||||
util.exportExcel(response, list, "学校配置数据");
|
// util.exportExcel(response, list, "学校配置数据");
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取学校配置详细信息
|
* 获取学校配置详细信息
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("app:school:query")
|
// @RequiresPermissions("app:school:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiOperation(value = "获取学校配置详细信息", notes = "获取学校配置详细信息", httpMethod = "GET")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
{
|
{
|
||||||
return success(appSchoolService.selectAppSchoolById(id));
|
return success(appSchoolService.selectAppSchoolById(id));
|
||||||
|
|
@ -76,6 +82,7 @@ public class AppSchoolController extends BaseController
|
||||||
@RequiresPermissions("app:school:add")
|
@RequiresPermissions("app:school:add")
|
||||||
@Log(title = "学校配置", businessType = BusinessType.INSERT)
|
@Log(title = "学校配置", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@ApiOperation(value = "新增学校配置", notes = "新增学校配置", httpMethod = "POST")
|
||||||
public AjaxResult add(@RequestBody AppSchool appSchool)
|
public AjaxResult add(@RequestBody AppSchool appSchool)
|
||||||
{
|
{
|
||||||
return toAjax(appSchoolService.insertAppSchool(appSchool));
|
return toAjax(appSchoolService.insertAppSchool(appSchool));
|
||||||
|
|
@ -87,6 +94,7 @@ public class AppSchoolController extends BaseController
|
||||||
@RequiresPermissions("app:school:edit")
|
@RequiresPermissions("app:school:edit")
|
||||||
@Log(title = "学校配置", businessType = BusinessType.UPDATE)
|
@Log(title = "学校配置", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@ApiOperation(value = "修改学校配置", notes = "修改学校配置", httpMethod = "PUT")
|
||||||
public AjaxResult edit(@RequestBody AppSchool appSchool)
|
public AjaxResult edit(@RequestBody AppSchool appSchool)
|
||||||
{
|
{
|
||||||
return toAjax(appSchoolService.updateAppSchool(appSchool));
|
return toAjax(appSchoolService.updateAppSchool(appSchool));
|
||||||
|
|
@ -98,6 +106,7 @@ public class AppSchoolController extends BaseController
|
||||||
@RequiresPermissions("app:school:remove")
|
@RequiresPermissions("app:school:remove")
|
||||||
@Log(title = "学校配置", businessType = BusinessType.DELETE)
|
@Log(title = "学校配置", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation(value = "删除学校配置", notes = "删除学校配置", httpMethod = "DELETE")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids)
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
{
|
{
|
||||||
return toAjax(appSchoolService.deleteAppSchoolByIds(ids));
|
return toAjax(appSchoolService.deleteAppSchoolByIds(ids));
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ package com.ruoyi.app.controller;
|
||||||
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.Authorization;
|
import io.swagger.annotations.Authorization;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
@ -12,12 +15,14 @@ import org.springframework.web.bind.annotation.*;
|
||||||
@RequestMapping("/api/msm")
|
@RequestMapping("/api/msm")
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
|
@Api(tags = "短信验证码接口" , description = "短信验证码接口")
|
||||||
public class PhoneCodeController {
|
public class PhoneCodeController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendNoteUtil sendNoteUtil;
|
private SendNoteUtil sendNoteUtil;
|
||||||
|
|
||||||
@GetMapping(value = "/send")
|
@GetMapping(value = "/send")
|
||||||
|
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码", httpMethod = "GET")
|
||||||
public AjaxResult sendCode(@RequestParam("phoneNum") String phoneNum){
|
public AjaxResult sendCode(@RequestParam("phoneNum") String phoneNum){
|
||||||
|
|
||||||
String send = sendNoteUtil.sendNoteMessgae(phoneNum);
|
String send = sendNoteUtil.sendNoteMessgae(phoneNum);
|
||||||
|
|
@ -36,6 +41,8 @@ public class PhoneCodeController {
|
||||||
* @return 返回验证状态
|
* @return 返回验证状态
|
||||||
*/
|
*/
|
||||||
@GetMapping(value ="/check")
|
@GetMapping(value ="/check")
|
||||||
|
|
||||||
|
@ApiOperation(value = "验证验证码", notes = "验证验证码", httpMethod = "GET")
|
||||||
public AjaxResult check(@RequestParam("phoneNum") String phoneNumber, @RequestParam("code") String code) {
|
public AjaxResult check(@RequestParam("phoneNum") String phoneNumber, @RequestParam("code") String code) {
|
||||||
String verificationResults = sendNoteUtil.check(phoneNumber, code);
|
String verificationResults = sendNoteUtil.check(phoneNumber, code);
|
||||||
if (StringUtils.isNotBlank(verificationResults)) {
|
if (StringUtils.isNotBlank(verificationResults)) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.app.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.app.domain.AppSchool;
|
import com.ruoyi.app.domain.AppSchool;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学校配置Mapper接口
|
* 学校配置Mapper接口
|
||||||
|
|
@ -58,4 +59,6 @@ public interface AppSchoolMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteAppSchoolByIds(Long[] ids);
|
public int deleteAppSchoolByIds(Long[] ids);
|
||||||
|
|
||||||
|
List<AppSchool> selectAppSchoolAllList(@Param("name") String name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.ruoyi.app.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "alisms")
|
||||||
|
@Data
|
||||||
|
public class AliSmsProperties {
|
||||||
|
@Value(value = "${alisms.accessKeyId}")
|
||||||
|
private String accessKeyId;
|
||||||
|
@Value(value = "${alisms.accessKeySecret}")
|
||||||
|
private String accessKeySecret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -58,4 +58,6 @@ public interface IAppSchoolService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteAppSchoolById(Long id);
|
public int deleteAppSchoolById(Long id);
|
||||||
|
|
||||||
|
List<AppSchool> selectAppSchoolAllList(String name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.app.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.app.mapper.AppSchoolMapper;
|
import com.ruoyi.app.mapper.AppSchoolMapper;
|
||||||
|
|
@ -55,6 +56,8 @@ public class AppSchoolServiceImpl implements IAppSchoolService
|
||||||
{
|
{
|
||||||
appSchool.setCreateTime(DateUtils.getNowDate());
|
appSchool.setCreateTime(DateUtils.getNowDate());
|
||||||
appSchool.setUpdateTime(DateUtils.getNowDate());
|
appSchool.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
appSchool.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return appSchoolMapper.insertAppSchool(appSchool);
|
return appSchoolMapper.insertAppSchool(appSchool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,6 +71,7 @@ public class AppSchoolServiceImpl implements IAppSchoolService
|
||||||
public int updateAppSchool(AppSchool appSchool)
|
public int updateAppSchool(AppSchool appSchool)
|
||||||
{
|
{
|
||||||
appSchool.setUpdateTime(DateUtils.getNowDate());
|
appSchool.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
appSchool.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return appSchoolMapper.updateAppSchool(appSchool);
|
return appSchoolMapper.updateAppSchool(appSchool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,4 +98,10 @@ public class AppSchoolServiceImpl implements IAppSchoolService
|
||||||
{
|
{
|
||||||
return appSchoolMapper.deleteAppSchoolById(id);
|
return appSchoolMapper.deleteAppSchoolById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AppSchool> selectAppSchoolAllList(String name) {
|
||||||
|
return appSchoolMapper.selectAppSchoolAllList(name);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.aliyuncs.exceptions.ClientException;
|
||||||
import com.aliyuncs.exceptions.ServerException;
|
import com.aliyuncs.exceptions.ServerException;
|
||||||
import com.aliyuncs.http.MethodType;
|
import com.aliyuncs.http.MethodType;
|
||||||
import com.aliyuncs.profile.DefaultProfile;
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
|
import com.ruoyi.app.properties.AliSmsProperties;
|
||||||
import com.ruoyi.common.redis.service.RedisService;
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
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;
|
||||||
|
|
@ -21,27 +22,29 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class SendNoteUtil {
|
public class SendNoteUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云 accessKeyId
|
* 阿里云 accessKeyId : "fEZZyFvWkETS8Clm73f7qmY9ohcTpc"
|
||||||
*/
|
*/
|
||||||
@Value("${aliSms.accessKeyId}")
|
@Value("${alisms.accessKeyId}")
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云 secret
|
* 阿里云 secret : "LTAI5tM1LeE2pkiS3qEFQkfb"
|
||||||
*/
|
*/
|
||||||
@Value("${aliSms.accessKeySecret}")
|
@Value("${alisms.accessKeySecret}")
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
|
@Autowired
|
||||||
|
private AliSmsProperties aliSmsProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云签名
|
* 阿里云签名
|
||||||
*/
|
*/
|
||||||
@Value("${aliSms.signName}")
|
@Value("${alisms.signName}")
|
||||||
private String signName;
|
private String signName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阿里云短信模板Code
|
* 阿里云短信模板Code
|
||||||
*/
|
*/
|
||||||
@Value("${aliSms.templateCode}")
|
@Value("${alisms.templateCode}")
|
||||||
private String templateCode;
|
private String templateCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -55,7 +58,7 @@ public class SendNoteUtil {
|
||||||
//验证平台信息 开发者无需任何更改
|
//验证平台信息 开发者无需任何更改
|
||||||
private static final String dysmsapi = "dysmsapi.aliyuncs.com";
|
private static final String dysmsapi = "dysmsapi.aliyuncs.com";
|
||||||
|
|
||||||
DefaultProfile profile = DefaultProfile.getProfile("default", "LTAI5tM1LeE2pkiS3qEFQkfb", "fEZZyFvWkETS8Clm73f7qmY9ohcTpc");
|
DefaultProfile profile = DefaultProfile.getProfile("default","LTAI5tM1LeE2pkiS3qEFQkfb", "fEZZyFvWkETS8Clm73f7qmY9ohcTpc");
|
||||||
IAcsClient client = new DefaultAcsClient(profile);
|
IAcsClient client = new DefaultAcsClient(profile);
|
||||||
//这一步的两个参数,一个是要发送验证码的手机号 一个是模板Code用来区分登录注册
|
//这一步的两个参数,一个是要发送验证码的手机号 一个是模板Code用来区分登录注册
|
||||||
|
|
||||||
|
|
@ -66,7 +69,6 @@ public class SendNoteUtil {
|
||||||
* @return 返回发送状态
|
* @return 返回发送状态
|
||||||
*/
|
*/
|
||||||
public String sendNoteMessgae(String PhoneNumber) {
|
public String sendNoteMessgae(String PhoneNumber) {
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
String randomNumber = String.valueOf(random.nextInt(9000) + 1000);
|
String randomNumber = String.valueOf(random.nextInt(9000) + 1000);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectAppSchoolAllList" resultMap="AppSchoolResult">
|
||||||
|
<include refid="selectAppSchoolVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
6
pom.xml
6
pom.xml
|
|
@ -35,6 +35,7 @@
|
||||||
<minio.version>8.2.2</minio.version>
|
<minio.version>8.2.2</minio.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<aliyun.sms.version>2.0.24</aliyun.sms.version>
|
<aliyun.sms.version>2.0.24</aliyun.sms.version>
|
||||||
|
<knife4j.version>3.0.3</knife4j.version>
|
||||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
@ -222,6 +223,11 @@
|
||||||
<artifactId>ruoyi-api-system</artifactId>
|
<artifactId>ruoyi-api-system</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
<!--阿里云短信包-->
|
<!--阿里云短信包-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue