1.增加店家注册接口

master
panqihua 1 year ago
parent c375ffeb5d
commit ac904bd24e
  1. 98
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/store/account/PlatformStoreAccountController.java
  2. 6
      ruoyi-common/pom.xml
  3. 2
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  4. 25
      sql/ttsbg.sql
  5. 161
      ttsbg-platform/src/main/java/com/ruoyi/platform/domain/PlatformStoreAccount.java
  6. 15
      ttsbg-platform/src/main/java/com/ruoyi/platform/domain/vo/PlatformStoreAccountVo.java
  7. 56
      ttsbg-platform/src/main/java/com/ruoyi/platform/mapper/PlatformStoreAccountMapper.java
  8. 4
      ttsbg-platform/src/main/java/com/ruoyi/platform/service/IPlatformSmsService.java
  9. 64
      ttsbg-platform/src/main/java/com/ruoyi/platform/service/IPlatformStoreAccountService.java
  10. 18
      ttsbg-platform/src/main/java/com/ruoyi/platform/service/impl/PlatformSmsServiceImpl.java
  11. 127
      ttsbg-platform/src/main/java/com/ruoyi/platform/service/impl/PlatformStoreAccountServiceImpl.java

@ -0,0 +1,98 @@
package com.ruoyi.platform.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.platform.domain.PlatformStoreAccount;
import com.ruoyi.platform.domain.vo.PlatformStoreAccountVo;
import com.ruoyi.platform.service.IPlatformStoreAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 店家账号Controller
*
* @author ruoyi
* @date 2023-02-10
*/
@RestController
@RequestMapping("/platform/store/account")
public class PlatformStoreAccountController extends BaseController {
@Autowired
private IPlatformStoreAccountService platformStoreAccountService;
@PostMapping("register")
public AjaxResult register(@RequestBody PlatformStoreAccountVo account) {
return success(platformStoreAccountService.register(account));
}
/**
* 查询店家账号列表
*/
@PreAuthorize("@ss.hasPermi('platform:account:list')")
@GetMapping("/list")
public TableDataInfo list(PlatformStoreAccount platformStoreAccount) {
startPage();
List<PlatformStoreAccount> list = platformStoreAccountService.selectPlatformStoreAccountList(platformStoreAccount);
return getDataTable(list);
}
/**
* 导出店家账号列表
*/
@PreAuthorize("@ss.hasPermi('platform:account:export')")
@Log(title = "店家账号", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PlatformStoreAccount platformStoreAccount) {
List<PlatformStoreAccount> list = platformStoreAccountService.selectPlatformStoreAccountList(platformStoreAccount);
ExcelUtil<PlatformStoreAccount> util = new ExcelUtil<PlatformStoreAccount>(PlatformStoreAccount.class);
util.exportExcel(response, list, "店家账号数据");
}
/**
* 获取店家账号详细信息
*/
@PreAuthorize("@ss.hasPermi('platform:account:query')")
@GetMapping(value = "/{storeid}")
public AjaxResult getInfo(@PathVariable("storeid") Long storeid) {
return success(platformStoreAccountService.selectPlatformStoreAccountByStoreid(storeid));
}
/**
* 新增店家账号
*/
@PreAuthorize("@ss.hasPermi('platform:account:add')")
@Log(title = "店家账号", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PlatformStoreAccount platformStoreAccount) {
return toAjax(platformStoreAccountService.insertPlatformStoreAccount(platformStoreAccount));
}
/**
* 修改店家账号
*/
@PreAuthorize("@ss.hasPermi('platform:account:edit')")
@Log(title = "店家账号", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PlatformStoreAccount platformStoreAccount) {
return toAjax(platformStoreAccountService.updatePlatformStoreAccount(platformStoreAccount));
}
/**
* 删除店家账号
*/
@PreAuthorize("@ss.hasPermi('platform:account:remove')")
@Log(title = "店家账号", businessType = BusinessType.DELETE)
@DeleteMapping("/{storeids}")
public AjaxResult remove(@PathVariable Long[] storeids) {
return toAjax(platformStoreAccountService.deletePlatformStoreAccountByStoreids(storeids));
}
}

@ -139,6 +139,12 @@
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
</dependency>
</dependencies>
</project>

@ -119,6 +119,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/platform/config/**").permitAll()
//平台短信发送
.antMatchers("/platform/public/sms/send").permitAll()
//店家注册
.antMatchers("/platform/store/account/register").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()

@ -12,17 +12,20 @@ CREATE TABLE IF NOT EXISTS `platform_sms`
CREATE TABLE IF NOT EXISTS `platform_store_account`
(
`storeId` INTEGER NOT NULL auto_increment,
`mobile` VARCHAR(255) NOT NULL COMMENT '中国大陆手机号',
`password` VARCHAR(255) NOT NULL COMMENT 'HS512 加密',
`status` INTEGER NOT NULL COMMENT '枚举值、详看数据字典编码',
`registerDate` VARCHAR(255) NOT NULL COMMENT 'yyyy-MM-dd',
`nickname` VARCHAR(255) NOT NULL COMMENT '待确定格式',
`sex` INTEGER NOT NULL COMMENT '枚举值、详看数据字典编码',
`avatar` VARCHAR(255) NOT NULL COMMENT '待确定存储格式',
`loginDate` VARCHAR(255) NOT NULL COMMENT 'yyyy-MM-dd',
PRIMARY KEY (`storeId`)
) ENGINE = InnoDB COMMENT '店家账号表';
storeId int auto_increment
primary key,
mobile varchar(255) not null comment '中国大陆手机号',
password varchar(255) not null comment 'HS512 加密',
status int not null comment '枚举值、详看数据字典编码',
registerDate datetime not null comment 'yyyy-MM-dd',
nickname varchar(255) not null comment '待确定格式',
sex int not null comment '枚举值、详看数据字典编码',
avatar varchar(255) null comment '待确定存储格式',
loginDate datetime null comment 'yyyy-MM-dd',
constraint platform_store_account_mobile_uindex
unique (mobile)
)
comment '店家账号表';
# TODO:熟悉框架建立的表,后面可能要再调整

@ -0,0 +1,161 @@
package com.ruoyi.platform.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 店家账号对象 platform_store_account
*
* @author ruoyi
* @date 2023-02-10
*/
public class PlatformStoreAccount extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
@TableId(type = IdType.AUTO)
private Long storeid;
/**
* 中国大陆手机号
*/
@Excel(name = "中国大陆手机号")
private String mobile;
/**
* HS512 加密
*/
@Excel(name = "HS512 加密")
private String password;
/**
* 枚举值详看数据字典编码
*/
@Excel(name = "枚举值、详看数据字典编码")
private Long status;
/**
* yyyy-MM-dd
*/
@Excel(name = "yyyy-MM-dd")
private Date registerdate;
/**
* 待确定格式
*/
@Excel(name = "待确定格式")
private String nickname;
/**
* 枚举值详看数据字典编码
*/
@Excel(name = "枚举值、详看数据字典编码")
private Long sex;
/**
* 待确定存储格式
*/
@Excel(name = "待确定存储格式")
private String avatar;
/**
* yyyy-MM-dd
*/
@Excel(name = "yyyy-MM-dd")
private Date logindate;
public void setStoreid(Long storeid) {
this.storeid = storeid;
}
public Long getStoreid() {
return storeid;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getMobile() {
return mobile;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setStatus(Long status) {
this.status = status;
}
public Long getStatus() {
return status;
}
public void setRegisterdate(Date registerdate) {
this.registerdate = registerdate;
}
public Date getRegisterdate() {
return registerdate;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getNickname() {
return nickname;
}
public void setSex(Long sex) {
this.sex = sex;
}
public Long getSex() {
return sex;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getAvatar() {
return avatar;
}
public void setLogindate(Date logindate) {
this.logindate = logindate;
}
public Date getLogindate() {
return logindate;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("storeid", getStoreid())
.append("mobile", getMobile())
.append("password", getPassword())
.append("status", getStatus())
.append("registerdate", getRegisterdate())
.append("nickname", getNickname())
.append("sex", getSex())
.append("avatar", getAvatar())
.append("logindate", getLogindate())
.toString();
}
}

@ -0,0 +1,15 @@
package com.ruoyi.platform.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PlatformStoreAccountVo {
@NotBlank
private String mobile;
@NotBlank
private String password;
@NotBlank
private String verificationCode;
}

@ -0,0 +1,56 @@
package com.ruoyi.platform.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.platform.domain.PlatformStoreAccount;
import java.util.List;
public interface PlatformStoreAccountMapper extends BaseMapper<PlatformStoreAccount> {
/**
* 查询店家账号
*
* @param storeid 店家账号主键
* @return 店家账号
*/
public PlatformStoreAccount selectPlatformStoreAccountByStoreid(Long storeid);
/**
* 查询店家账号列表
*
* @param platformStoreAccount 店家账号
* @return 店家账号集合
*/
public List<PlatformStoreAccount> selectPlatformStoreAccountList(PlatformStoreAccount platformStoreAccount);
/**
* 新增店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
public int insertPlatformStoreAccount(PlatformStoreAccount platformStoreAccount);
/**
* 修改店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
public int updatePlatformStoreAccount(PlatformStoreAccount platformStoreAccount);
/**
* 删除店家账号
*
* @param storeid 店家账号主键
* @return 结果
*/
public int deletePlatformStoreAccountByStoreid(Long storeid);
/**
* 批量删除店家账号
*
* @param storeids 需要删除的数据主键集合
* @return 结果
*/
public int deletePlatformStoreAccountByStoreids(Long[] storeids);
}

@ -66,5 +66,7 @@ public interface IPlatformSmsService {
* @param integer
* @return 结果
*/
String send(String mobile, Integer integer);
public String send(String mobile, Integer integer);
public boolean existsSms(String mobile, String code);
}

@ -0,0 +1,64 @@
package com.ruoyi.platform.service;
import com.ruoyi.platform.domain.PlatformStoreAccount;
import com.ruoyi.platform.domain.vo.PlatformStoreAccountVo;
import java.util.List;
/**
* 店家账号Service接口
*
* @author ruoyi
* @date 2023-02-10
*/
public interface IPlatformStoreAccountService {
/**
* 查询店家账号
*
* @param storeid 店家账号主键
* @return 店家账号
*/
public PlatformStoreAccount selectPlatformStoreAccountByStoreid(Long storeid);
/**
* 查询店家账号列表
*
* @param platformStoreAccount 店家账号
* @return 店家账号集合
*/
public List<PlatformStoreAccount> selectPlatformStoreAccountList(PlatformStoreAccount platformStoreAccount);
/**
* 新增店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
public int insertPlatformStoreAccount(PlatformStoreAccount platformStoreAccount);
/**
* 修改店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
public int updatePlatformStoreAccount(PlatformStoreAccount platformStoreAccount);
/**
* 批量删除店家账号
*
* @param storeids 需要删除的店家账号主键集合
* @return 结果
*/
public int deletePlatformStoreAccountByStoreids(Long[] storeids);
/**
* 删除店家账号信息
*
* @param storeid 店家账号主键
* @return 结果
*/
public int deletePlatformStoreAccountByStoreid(Long storeid);
public String register(PlatformStoreAccountVo account);
}

@ -89,14 +89,26 @@ public class PlatformSmsServiceImpl implements IPlatformSmsService {
return platformSmsMapper.deletePlatformSmsById(id);
}
/**
* 检查手机号是否存在有效短信验证码
*
* @return
*/
@Override
public String send(String mobile, Integer smsTime) {
public boolean existsSms(String mobile, String code) {
LambdaQueryWrapper<PlatformSms> wrapper = new LambdaQueryWrapper<>();
Date d = new Date();
wrapper.select(PlatformSms::getId).eq(PlatformSms::getMobile, mobile).le(PlatformSms::getSendtime, d).ge(PlatformSms::getDeadtime, d);
if (code != null) {
wrapper.eq(PlatformSms::getCode, code);
}
PlatformSms sms = platformSmsMapper.selectOne(wrapper);
if (sms != null) {
return sms != null;
}
@Override
public String send(String mobile, Integer smsTime) {
if (existsSms(mobile, null)) {
return "短信发送过于频繁";
} else {
String code = RandomStringUtils.randomNumeric(6);

@ -0,0 +1,127 @@
package com.ruoyi.platform.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.platform.domain.PlatformStoreAccount;
import com.ruoyi.platform.domain.vo.PlatformStoreAccountVo;
import com.ruoyi.platform.mapper.PlatformStoreAccountMapper;
import com.ruoyi.platform.service.IPlatformSmsService;
import com.ruoyi.platform.service.IPlatformStoreAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 店家账号Service业务层处理
*
* @author ruoyi
* @date 2023-02-10
*/
@Service
public class PlatformStoreAccountServiceImpl implements IPlatformStoreAccountService {
@Autowired
private PlatformStoreAccountMapper platformStoreAccountMapper;
@Autowired
private IPlatformSmsService platformSmsService;
/**
* 查询店家账号
*
* @param storeid 店家账号主键
* @return 店家账号
*/
@Override
public PlatformStoreAccount selectPlatformStoreAccountByStoreid(Long storeid) {
return platformStoreAccountMapper.selectPlatformStoreAccountByStoreid(storeid);
}
/**
* 查询店家账号列表
*
* @param platformStoreAccount 店家账号
* @return 店家账号
*/
@Override
public List<PlatformStoreAccount> selectPlatformStoreAccountList(PlatformStoreAccount platformStoreAccount) {
return platformStoreAccountMapper.selectPlatformStoreAccountList(platformStoreAccount);
}
/**
* 新增店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
@Override
public int insertPlatformStoreAccount(PlatformStoreAccount platformStoreAccount) {
return platformStoreAccountMapper.insertPlatformStoreAccount(platformStoreAccount);
}
/**
* 修改店家账号
*
* @param platformStoreAccount 店家账号
* @return 结果
*/
@Override
public int updatePlatformStoreAccount(PlatformStoreAccount platformStoreAccount) {
return platformStoreAccountMapper.updatePlatformStoreAccount(platformStoreAccount);
}
/**
* 批量删除店家账号
*
* @param storeids 需要删除的店家账号主键
* @return 结果
*/
@Override
public int deletePlatformStoreAccountByStoreids(Long[] storeids) {
return platformStoreAccountMapper.deletePlatformStoreAccountByStoreids(storeids);
}
/**
* 删除店家账号信息
*
* @param storeid 店家账号主键
* @return 结果
*/
@Override
public int deletePlatformStoreAccountByStoreid(Long storeid) {
return platformStoreAccountMapper.deletePlatformStoreAccountByStoreid(storeid);
}
//检查手机号是否已注册
public boolean exist(String mobile) {
LambdaQueryWrapper<PlatformStoreAccount> wrapper = new LambdaQueryWrapper<>();
wrapper.select(PlatformStoreAccount::getStoreid).eq(PlatformStoreAccount::getMobile, mobile);
return platformStoreAccountMapper.selectOne(wrapper) != null;
}
@Override
public String register(PlatformStoreAccountVo account) {
//检查验证码是否有效
if (platformSmsService.existsSms(account.getMobile(), account.getVerificationCode())) {
if (exist(account.getMobile())) {
return "手机号已注册";
} else {
PlatformStoreAccount newAccount = new PlatformStoreAccount();
newAccount.setMobile(account.getMobile());
newAccount.setPassword(SecurityUtils.encryptPassword(account.getPassword()));
newAccount.setStatus(1L);
newAccount.setRegisterdate(new Date());
newAccount.setNickname(newAccount.getMobile());
newAccount.setSex(0L);
if (platformStoreAccountMapper.insert(newAccount) > 0) {
return "注册成功";
} else {
return "注册失败";
}
}
} else {
return "无效验证码";
}
}
}
Loading…
Cancel
Save