main
parent
af1ebcbc4f
commit
581a962cf9
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.ruoyi.app.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
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.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.ruoyi.app.domain.AppCode;
|
||||||
|
import com.ruoyi.app.service.IAppCodeService;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册码Controller
|
||||||
|
*
|
||||||
|
* @author wyh
|
||||||
|
* @date 2024-06-28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/code")
|
||||||
|
@Api(tags = "用户注册码" , description = "用户注册码")
|
||||||
|
public class AppCodeController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IAppCodeService appCodeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户注册码列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation(value = "查询用户注册码", notes = "查询用户注册码", httpMethod = "GET")
|
||||||
|
public TableDataInfo list(AppCode appCode)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<AppCode> list = appCodeService.selectAppCodeList(appCode);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出用户注册码列表
|
||||||
|
*/
|
||||||
|
@Log(title = "用户注册码", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, AppCode appCode)
|
||||||
|
{
|
||||||
|
List<AppCode> list = appCodeService.selectAppCodeList(appCode);
|
||||||
|
ExcelUtil<AppCode> util = new ExcelUtil<AppCode>(AppCode.class);
|
||||||
|
util.exportExcel(response, list, "用户注册码数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户注册码详细信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiOperation(value = "获取用户注册码详细信息", notes = "获取用户注册码详细信息", httpMethod = "GET")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(appCodeService.selectAppCodeById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户注册码
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增用户注册码", notes = "新增用户注册码", httpMethod = "POST")
|
||||||
|
@Log(title = "用户注册码", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult add(@RequestBody AppCode appCode)
|
||||||
|
{
|
||||||
|
return toAjax(appCodeService.insertAppCode(appCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户注册码
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改用户注册码", notes = "修改用户注册码", httpMethod = "PUT")
|
||||||
|
@Log(title = "用户注册码", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/edit")
|
||||||
|
public AjaxResult edit(@RequestBody AppCode appCode)
|
||||||
|
{
|
||||||
|
return toAjax(appCodeService.updateAppCode(appCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户注册码
|
||||||
|
*/
|
||||||
|
@Log(title = "用户注册码", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(appCodeService.deleteAppCodeByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,15 +3,14 @@ package com.ruoyi.app.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.app.domain.AppRegister;
|
import com.ruoyi.app.domain.*;
|
||||||
import com.ruoyi.app.domain.AppSchool;
|
|
||||||
import com.ruoyi.app.domain.AppUser;
|
|
||||||
import com.ruoyi.app.domain.dto.HelperUtil;
|
import com.ruoyi.app.domain.dto.HelperUtil;
|
||||||
import com.ruoyi.app.domain.dto.PayConfig;
|
import com.ruoyi.app.domain.dto.PayConfig;
|
||||||
import com.ruoyi.app.domain.vo.AppUserVo;
|
import com.ruoyi.app.domain.vo.AppUserVo;
|
||||||
import com.ruoyi.app.form.AppLoginUser;
|
import com.ruoyi.app.form.AppLoginUser;
|
||||||
import com.ruoyi.app.form.LoginForm;
|
import com.ruoyi.app.form.LoginForm;
|
||||||
import com.ruoyi.app.form.RegisterForm;
|
import com.ruoyi.app.form.RegisterForm;
|
||||||
|
import com.ruoyi.app.mapper.AppCodeMapper;
|
||||||
import com.ruoyi.app.mapper.AppRegisterMapper;
|
import com.ruoyi.app.mapper.AppRegisterMapper;
|
||||||
import com.ruoyi.app.service.IAppRegisterService;
|
import com.ruoyi.app.service.IAppRegisterService;
|
||||||
import com.ruoyi.app.service.IAppSchoolService;
|
import com.ruoyi.app.service.IAppSchoolService;
|
||||||
|
|
@ -40,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -73,11 +73,8 @@ public class AppLoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppRegisterMapper appRegisterMapper;
|
private AppRegisterMapper appRegisterMapper;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
@Autowired
|
||||||
String email = "ddd@qq.com";
|
private AppCodeMapper appCodeMapper;
|
||||||
String emailStr = email.substring(email.indexOf("@") + 1,email.length());
|
|
||||||
System.out.println(emailStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@ApiOperation(value = "注册", notes = "注册")
|
@ApiOperation(value = "注册", notes = "注册")
|
||||||
|
|
@ -99,7 +96,7 @@ public class AppLoginController {
|
||||||
String email = registerForm.getEmail();
|
String email = registerForm.getEmail();
|
||||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(email)) {
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(email)) {
|
||||||
if (org.apache.commons.lang3.StringUtils.isBlank(registerForm.getProve()) && org.apache.commons.lang3.StringUtils.isBlank(appSchool.getEmail())) {
|
if (org.apache.commons.lang3.StringUtils.isBlank(registerForm.getProve()) && org.apache.commons.lang3.StringUtils.isBlank(appSchool.getEmail())) {
|
||||||
return R.fail(2001,"该学校没有提供邮箱审核,请人工审核!");
|
return R.fail(2001,"您提供的邮箱后缀与您的学校不符!请提供学习邮箱或人工审核。");
|
||||||
}
|
}
|
||||||
String emailStr = email.substring(email.indexOf("@") + 1,email.length());
|
String emailStr = email.substring(email.indexOf("@") + 1,email.length());
|
||||||
if (org.apache.commons.lang3.StringUtils.isBlank(registerForm.getProve()) && !emailStr.equals(appSchool.getEmail())) {
|
if (org.apache.commons.lang3.StringUtils.isBlank(registerForm.getProve()) && !emailStr.equals(appSchool.getEmail())) {
|
||||||
|
|
@ -127,25 +124,6 @@ public class AppLoginController {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if (StringUtils.isNotEmpty(email) && appSchool.getEmail() != null && appSchool.getEmail().equals(email.substring(email.indexOf("@") + 1,email.length()))) {
|
|
||||||
AppRegister appRegister = setAppRegister(registerForm);
|
|
||||||
//校验邮箱是否已注册
|
|
||||||
AppUser emailUser = appUserService.selectAppUserByEmail(registerForm.getEmail());
|
|
||||||
Assert.isNull(emailUser, "邮箱已注册");
|
|
||||||
String uuid = IdUtils.fastUUID();
|
|
||||||
redisService.setCacheObject(uuid, registerForm);
|
|
||||||
try {
|
|
||||||
String EM = "<html><body><h2>欢迎来到我们的服务!!</h2>"
|
|
||||||
+ "<p>请点击下面的网址确认您的注册:</p>"
|
|
||||||
+ "<a href=https://gobig.flameby.com/api/app/activation/" + uuid + "/" + registerForm.getEmail() + ">注册账号</a>"
|
|
||||||
+ "</body></html>";
|
|
||||||
|
|
||||||
AliMailUtil.sendMail(EM,registerForm.getEmail());
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (register != null && register.getStatus() != null) {
|
if (register != null && register.getStatus() != null) {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,6 +138,17 @@ public class AppLoginController {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if ("其他".equals(appSchool.getName()) && org.apache.commons.lang3.StringUtils.isNotBlank(registerForm.getInvitationCode())) {
|
||||||
|
AppCode appCode = appCodeMapper.selectAppCodeByCode(registerForm.getInvitationCode());
|
||||||
|
if (appCode == null || appCode.getUserId() != null) {
|
||||||
|
return R.fail(2001,"该注册码不存在或已被使用,请检查该注册码是否正确!");
|
||||||
|
}
|
||||||
|
AppRegister appRegister = setAppRegister(registerForm);
|
||||||
|
appRegister.setInvitationCode(registerForm.getInvitationCode());
|
||||||
|
int i = appRegisterService.insertAppRegister(appRegister);
|
||||||
|
appRegisterService.passAppRegister(appRegister.getId());
|
||||||
|
return R.ok(null, "注册申请成功,可以去登录啦!");
|
||||||
|
}
|
||||||
AppRegister appRegister = setAppRegister(registerForm);
|
AppRegister appRegister = setAppRegister(registerForm);
|
||||||
appRegister.setInvitationCode(registerForm.getInvitationCode());
|
appRegister.setInvitationCode(registerForm.getInvitationCode());
|
||||||
int i = appRegisterService.insertAppRegister(appRegister);
|
int i = appRegisterService.insertAppRegister(appRegister);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.ruoyi.app.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册码对象 app_code
|
||||||
|
*
|
||||||
|
* @author wyh
|
||||||
|
* @date 2024-06-28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AppCode extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 兑换码 */
|
||||||
|
@Excel(name = "兑换码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 使用者 */
|
||||||
|
@Excel(name = "使用者")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
/** 使用时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date userTime;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setCode(String code)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode()
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setUserId(Long userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setUserTime(Date userTime)
|
||||||
|
{
|
||||||
|
this.userTime = userTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUserTime()
|
||||||
|
{
|
||||||
|
return userTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("code", getCode())
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.append("userTime", getUserTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.ruoyi.app.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCode;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册码Mapper接口
|
||||||
|
*
|
||||||
|
* @author wyh
|
||||||
|
* @date 2024-06-28
|
||||||
|
*/
|
||||||
|
public interface AppCodeMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询用户注册码
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 用户注册码
|
||||||
|
*/
|
||||||
|
public AppCode selectAppCodeById(Long id);
|
||||||
|
public AppCode selectAppCodeByCode(@Param("code") String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户注册码列表
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 用户注册码集合
|
||||||
|
*/
|
||||||
|
public List<AppCode> selectAppCodeList(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAppCode(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAppCode(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户注册码
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAppCodeById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户注册码
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAppCodeByIds(Long[] ids);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.ruoyi.app.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册码Service接口
|
||||||
|
*
|
||||||
|
* @author wyh
|
||||||
|
* @date 2024-06-28
|
||||||
|
*/
|
||||||
|
public interface IAppCodeService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询用户注册码
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 用户注册码
|
||||||
|
*/
|
||||||
|
public AppCode selectAppCodeById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户注册码列表
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 用户注册码集合
|
||||||
|
*/
|
||||||
|
public List<AppCode> selectAppCodeList(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertAppCode(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateAppCode(AppCode appCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户注册码
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的用户注册码主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAppCodeByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户注册码信息
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteAppCodeById(Long id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.ruoyi.app.service.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.ruoyi.app.domain.AppExchangeCode;
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.app.mapper.AppCodeMapper;
|
||||||
|
import com.ruoyi.app.domain.AppCode;
|
||||||
|
import com.ruoyi.app.service.IAppCodeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册码Service业务层处理
|
||||||
|
*
|
||||||
|
* @author wyh
|
||||||
|
* @date 2024-06-28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppCodeServiceImpl implements IAppCodeService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private AppCodeMapper appCodeMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户注册码
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 用户注册码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AppCode selectAppCodeById(Long id)
|
||||||
|
{
|
||||||
|
return appCodeMapper.selectAppCodeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户注册码列表
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 用户注册码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AppCode> selectAppCodeList(AppCode appCode)
|
||||||
|
{
|
||||||
|
return appCodeMapper.selectAppCodeList(appCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertAppCode(AppCode appCode) {
|
||||||
|
int num = appCode.getNum() == null ? 1 : appCode.getNum();
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
String code = getItemName(6);
|
||||||
|
AppCode entity = new AppCode();
|
||||||
|
entity.setCreateTime(new Date());
|
||||||
|
entity.setCode(code);
|
||||||
|
appCodeMapper.insertAppCode(entity);
|
||||||
|
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getItemName( int length ){
|
||||||
|
String base = "123456789ABCDEFHJKMNPQRSTUVWXYZ";
|
||||||
|
Random random = new Random();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for ( int i = 0; i < length; i++ )
|
||||||
|
{
|
||||||
|
int number = random.nextInt( base.length() );
|
||||||
|
sb.append( base.charAt( number ) );
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户注册码
|
||||||
|
*
|
||||||
|
* @param appCode 用户注册码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateAppCode(AppCode appCode)
|
||||||
|
{
|
||||||
|
appCode.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return appCodeMapper.updateAppCode(appCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户注册码
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的用户注册码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAppCodeByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return appCodeMapper.deleteAppCodeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户注册码信息
|
||||||
|
*
|
||||||
|
* @param id 用户注册码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteAppCodeById(Long id)
|
||||||
|
{
|
||||||
|
return appCodeMapper.deleteAppCodeById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import com.ruoyi.app.domain.*;
|
||||||
import com.ruoyi.app.domain.vo.AppRegisterVo;
|
import com.ruoyi.app.domain.vo.AppRegisterVo;
|
||||||
import com.ruoyi.app.mapper.*;
|
import com.ruoyi.app.mapper.*;
|
||||||
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
import com.ruoyi.app.utils.aliyun.sms.SendNoteUtil;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||||
|
|
@ -55,6 +56,8 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppExchangeCodeMapper appExchangeCodeMapper;
|
private AppExchangeCodeMapper appExchangeCodeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppCodeMapper appCodeMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询注册审核
|
* 查询注册审核
|
||||||
|
|
@ -146,13 +149,6 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
AppRegister appRegister = appRegisterMapper.selectAppRegisterById(id);
|
AppRegister appRegister = appRegisterMapper.selectAppRegisterById(id);
|
||||||
Assert.isTrue(appRegister != null, "该申请不存在");
|
Assert.isTrue(appRegister != null, "该申请不存在");
|
||||||
Assert.isTrue(appRegister.getStatus() != null && appRegister.getStatus() == 0, "该申请已审核");
|
Assert.isTrue(appRegister.getStatus() != null && appRegister.getStatus() == 0, "该申请已审核");
|
||||||
AppExchangeCode appExchangeCode = null;
|
|
||||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(appRegister.getInvitationCode())) {
|
|
||||||
appExchangeCode = appExchangeCodeMapper.selectAppExchangeCodeByCode(appRegister.getInvitationCode());
|
|
||||||
if (appExchangeCode == null || appExchangeCode.getUserId() != null) {
|
|
||||||
Assert.isTrue(false, "该兑换码不存在或已被使用,请检查该兑换码是否正确!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
appRegister.setStatus(1);
|
appRegister.setStatus(1);
|
||||||
appRegister.setUpdateTime(DateUtils.getNowDate());
|
appRegister.setUpdateTime(DateUtils.getNowDate());
|
||||||
int i = appRegisterMapper.updateAppRegister(appRegister);
|
int i = appRegisterMapper.updateAppRegister(appRegister);
|
||||||
|
|
@ -177,10 +173,16 @@ public class AppRegisterServiceImpl implements IAppRegisterService {
|
||||||
appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null);
|
appUser.setCityId(appRegister.getCityId() != null ? appRegister.getCityId() : null);
|
||||||
appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null);
|
appUser.setTownId(appRegister.getTownId() != null ? appRegister.getTownId() : null);
|
||||||
appUserMapper.insertAppUser(appUser);
|
appUserMapper.insertAppUser(appUser);
|
||||||
if (appExchangeCode != null && appExchangeCode.getId() != null) {
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(appRegister.getInvitationCode())) {
|
||||||
useExchange(appExchangeCode,appUser.getId());
|
AppCode appCode = appCodeMapper.selectAppCodeByCode(appRegister.getInvitationCode());
|
||||||
|
if (appCode != null && appCode.getId() != null) {
|
||||||
|
AppCode entity = new AppCode();
|
||||||
|
entity.setId(appCode.getId());
|
||||||
|
entity.setUserTime(new Date());
|
||||||
|
entity.setUserId(appUser.getId());
|
||||||
|
appCodeMapper.updateAppCode(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendNoteUtil.sendMessage(appRegister.getPhone());
|
sendNoteUtil.sendMessage(appRegister.getPhone());
|
||||||
HttpClient httpClient = HttpClients.createDefault();
|
HttpClient httpClient = HttpClients.createDefault();
|
||||||
String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null;
|
String pushId = appRegister.getPushId() != null ? appRegister.getPushId() : null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?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.ruoyi.app.mapper.AppCodeMapper">
|
||||||
|
|
||||||
|
<resultMap type="AppCode" id="AppCodeResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="code" column="code" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="updateBy" column="updateBy" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="userTime" column="user_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAppCodeVo">
|
||||||
|
select id, code, user_id, create_time, update_time, create_by, updateBy, remark, user_time from app_code
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectAppCodeList" parameterType="AppCode" resultMap="AppCodeResult">
|
||||||
|
select a.id, a.code, a.user_id, a.create_time, a.update_time, a.create_by, a.updateBy, a.remark, a.user_time,u.username as userName
|
||||||
|
from app_code a
|
||||||
|
left join app_user u on u.id = a.user_id
|
||||||
|
<where>
|
||||||
|
<if test="code != null and code != ''"> and a.code = #{code}</if>
|
||||||
|
<if test="userId != null "> and a.user_id = #{userId}</if>
|
||||||
|
<if test="userName != null "> and u.username like concat('%',#{userName},'%')</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''"> and a.updateBy = #{updateBy}</if>
|
||||||
|
<if test="userTime != null "> and a.user_time = #{userTime}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAppCodeById" parameterType="Long" resultMap="AppCodeResult">
|
||||||
|
<include refid="selectAppCodeVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAppCodeByCode" parameterType="Long" resultMap="AppCodeResult">
|
||||||
|
<include refid="selectAppCodeVo"/>
|
||||||
|
where code = #{code}
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAppCode" parameterType="AppCode" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into app_code
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="code != null">code,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="updateBy != null">updateBy,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
<if test="userTime != null">user_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
<if test="userTime != null">#{userTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAppCode" parameterType="AppCode">
|
||||||
|
update app_code
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="code != null">code = #{code},</if>
|
||||||
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="updateBy != null">updateBy = #{updateBy},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="userTime != null">user_time = #{userTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteAppCodeById" parameterType="Long">
|
||||||
|
delete from app_code where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteAppCodeByIds" parameterType="String">
|
||||||
|
delete from app_code where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue