diff --git a/pom.xml b/pom.xml index dc46fb8..c3c07ea 100644 --- a/pom.xml +++ b/pom.xml @@ -238,6 +238,40 @@ 2.0.3 + + + + com.aliyun + dysmsapi20170525 + 2.0.24 + + + + org.projectlombok + lombok + 1.18.38 + provided + + + + org.apache.httpcomponents + httpcore + 4.4.10 + + + + + org.apache.httpcomponents + httpclient + 4.5.6 + + + + cn.hutool + hutool-all + 5.8.36 + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ShopUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ShopUserController.java new file mode 100644 index 0000000..a6ae296 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/client/ShopUserController.java @@ -0,0 +1,65 @@ +package com.ruoyi.web.controller.client; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.ShopUser; +import com.ruoyi.common.core.domain.entity.ShopUserResq; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.framework.web.service.SysLoginService; +import com.ruoyi.system.service.AliConfigService; +import com.ruoyi.system.service.ShopUserService; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.SwaggerDefinition; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@RequestMapping("/client") +@RestController +public class ShopUserController { + + @Autowired + private SysLoginService loginService; + @Autowired + private AliConfigService aliConfigService; + @Autowired + private ShopUserService shopUserService; + + + /** + * 获取验证码 + */ + @PostMapping("/getCode") + public AjaxResult getCode(@RequestBody ShopUser shopUser){ + String result = aliConfigService.sendMsg(shopUser); + if (result != null){ + return AjaxResult.success(); + } + return AjaxResult.error("发送验证码失败"); + } + + + /** + * 登录方法 + * + * @return 结果 + */ + @PostMapping("/shopLogin") + public AjaxResult shopLogin(@RequestBody ShopUserResq userResq) + { + AjaxResult ajax = AjaxResult.success(); + ShopUser shopUser = shopUserService.login(userResq); + if (shopUser.getMsg() != null){ + return AjaxResult.error(shopUser.getMsg()); + }else { + // 生成令牌 + String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword()); + ajax.put("userinfo", shopUser); + ajax.put(Constants.TOKEN, token); + return ajax; + } + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 3a0322e..ec32de6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -49,21 +49,6 @@ public class SysLoginController @Autowired private ISysConfigService configService; - /** - * 登录方法 - * - * @param shopUser 登录信息 - * @return 结果 - */ - @PostMapping("/shopLogin") - public AjaxResult shopLogin(@RequestBody ShopUser shopUser) - { - AjaxResult ajax = AjaxResult.success(); - // 生成令牌 - String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword()); - ajax.put(Constants.TOKEN, token); - return ajax; - } /** * 登录方法 diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index d9e02dc..9bbc596 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -135,7 +135,37 @@ org jaudiotagger + + com.alibaba.fastjson2 + fastjson2 + 2.0.40 + + + com.aliyun + dysmsapi20170525 + + + + org.projectlombok + lombok + + + + org.apache.httpcomponents + httpcore + + + + + org.apache.httpcomponents + httpclient + + + + cn.hutool + hutool-all + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java index 0b0635e..82bea00 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUser.java @@ -1,43 +1,27 @@ package com.ruoyi.common.core.domain.entity; +import lombok.Data; +import lombok.Getter; + +@Data public class ShopUser { + /** + * 1 账号密码 2 验证码 3 一键登录 + */ + private int method; + @Getter private String username; private String password; + private String phone; private Long userId; - public String getUsername() { - return username; - } + private String uMtoken; - public void setUsername(String username) { - this.username = username; - } + private String code; - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public Long getUserId() { - return userId; - } - - public void setUserId(Long userId) { - this.userId = userId; - } + private String msg; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUserResq.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUserResq.java new file mode 100644 index 0000000..2e2af81 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/ShopUserResq.java @@ -0,0 +1,25 @@ +package com.ruoyi.common.core.domain.entity; + + +import lombok.Data; +import lombok.Getter; + +@Data +public class ShopUserResq { + /** + * 1 账号密码 2 验证码 3 一键登录 + */ + private String method; + + private String username; + + private String password; + + private String phone; + + private Long userId; + + private String uMtoken; + + private String code; +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RestTemplateConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RestTemplateConfig.java new file mode 100644 index 0000000..aba6f33 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RestTemplateConfig.java @@ -0,0 +1,21 @@ +package com.ruoyi.framework.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +import java.time.Duration; + +@Configuration +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder builder) { + return builder + .setConnectTimeout(Duration.ofSeconds(5)) + .setReadTimeout(Duration.ofSeconds(5)) + .build(); + } + +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index d94028a..8f2c85a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -130,7 +130,7 @@ public class SecurityConfig .authorizeHttpRequests((requests) -> { permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - requests.antMatchers("/login", "/register","/shopLogin", "/captchaImage").permitAll() + requests.antMatchers("/login", "/register","/client/shopLogin", "/captchaImage","/client/getCode").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ShopUserDetailServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ShopUserDetailServiceImpl.java index bdebd18..445847c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ShopUserDetailServiceImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ShopUserDetailServiceImpl.java @@ -24,7 +24,7 @@ public class ShopUserDetailServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - ShopUser member = shopUserMapper.selectShopUserByPhone(username); //验证登录用户,查询数据库,如果这个mapper定义在自己的模块,引入maven依赖不用我多说吧? + ShopUser member = shopUserMapper.selectShopUserByUsername(username); //验证登录用户,查询数据库,如果这个mapper定义在自己的模块,引入maven依赖不用我多说吧? System.out.println("这里是会员登录"+member); if (StringUtils.isNull(member)) { log.info("登录用户:{} 不存在.", username); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/AliConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/AliConfig.java new file mode 100644 index 0000000..645089c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/AliConfig.java @@ -0,0 +1,66 @@ +package com.ruoyi.system.config; + +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.aliyun.teaopenapi.models.Config; +import com.ruoyi.common.core.domain.entity.ShopUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static com.alibaba.fastjson2.JSONObject.toJSONString; + +public class AliConfig { + private static final Logger log = LoggerFactory.getLogger(AliConfig.class); + public static Client createClient() { + Config config = new Config() + // 配置 AccessKey ID,请确保代码运行环境配置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 + .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")) + // 配置 AccessKey Secret,请确保代码运行环境配置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 + .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")); + // System.getenv()方法表示获取系统环境变量,不要直接在getenv()中填入AccessKey信息。 + + // 配置 Endpoint。中国站请使用dysmsapi.aliyuncs.com + config.endpoint = "dysmsapi.aliyuncs.com"; + + try { + return new Client(config); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + public static String sendMsg(ShopUser shopUser) { + // 初始化请求客户端 + Client client = AliConfig.createClient(); + + // 1. 生成6位验证码 + String code = String.valueOf((int)((Math.random()*9+1)*100000)); + + String templateParam = "{\"name\":\"" + shopUser.getUsername() + "\",\"number\":\""+ shopUser.getPhone() +"\"}"; + + // 构造API请求对象,请替换请求参数值 + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setPhoneNumbers(shopUser.getPhone()) + .setSignName("music") + .setTemplateCode(code) + .setTemplateParam(templateParam); // TemplateParam为序列化后的JSON字符串。 + + // 获取响应对象 + SendSmsResponse sendSmsResponse; + try { + sendSmsResponse = client.sendSms(sendSmsRequest); + } catch (Exception e) { + throw new RuntimeException(e); + } + + log.info("aliyun 发送验证码返回信息:{}", toJSONString(sendSmsResponse)); + + if (sendSmsResponse.getStatusCode() == 200){ + return code; + } + return null; + } + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java new file mode 100644 index 0000000..e507e88 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/config/UmengConfig.java @@ -0,0 +1,110 @@ +package com.ruoyi.system.config; + +import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.common.utils.uuid.UUID; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; +import java.util.Map; + +@Component +public class UmengConfig { + + public CloseableHttpResponse send(String token){ + String umAppkey = "xxxx"; + String appKey = "5df88f83570df3b8d40012337"; + String appSecret = "xxxx"; + // 下面的url要和阿里云云市场购买的商品对应 + String url = "https://verify5.market.alicloudapi.com/api/v1/mobile/info?appkey=" + umAppkey; + HttpPost httpPost = new HttpPost(url); + /** + * body + */ + JSONObject object = new JSONObject(); + object.put("token", token); + StringEntity stringEntity = new StringEntity(object.toJSONString(), StandardCharsets.UTF_8); + httpPost.setEntity(stringEntity); + /** + * header + */ + httpPost.setHeader("Content-Type", "application/json; charset=UTF-8"); + httpPost.setHeader("Accept", "application/json"); + httpPost.setHeader("X-Ca-Version", "1"); + httpPost.setHeader("X-Ca-Signature-Headers", "X-Ca-Version,X-Ca-Stage,X-Ca-Key,X-Ca-Timestamp"); + httpPost.setHeader("X-Ca-Stage", "RELEASE"); + httpPost.setHeader("X-Ca-Key", appKey); + httpPost.setHeader("X-Ca-Timestamp", String.valueOf(System.currentTimeMillis())); + httpPost.setHeader("X-Ca-Nonce", UUID.randomUUID().toString()); + httpPost.setHeader("Content-MD5", Base64.encodeBase64String(DigestUtils.md5(object.toJSONString()))); + /** + * sign + */ + String stringToSign = getSignString(httpPost); + Mac hmacSha256; + try { + hmacSha256 = Mac.getInstance("HmacSHA256"); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + byte[] keyBytes = appSecret.getBytes(StandardCharsets.UTF_8); + try { + hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, "HmacSHA256")); + } catch (InvalidKeyException e) { + throw new RuntimeException(e); + } + String sign = new String(Base64.encodeBase64(hmacSha256.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)))); + httpPost.setHeader("X-Ca-Signature", sign); + /** + * execute + */ + CloseableHttpClient httpclient = HttpClients.createDefault(); + try { + CloseableHttpResponse response = httpclient.execute(httpPost); + return response; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + + + public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException { + + } + + private static String getSignString(HttpPost httpPost) { + Header[] headers = httpPost.getAllHeaders(); + Map map = new HashMap<>(); + for (Header header : headers) { + map.put(header.getName(), header.getValue()); + } + return httpPost.getMethod() + "\n" + + map.get("Accept") + "\n" + + map.get("Content-MD5") + "\n" + + map.get("Content-Type") + "\n\n" + + "X-Ca-Key:" + map.get("X-Ca-Key") + "\n" + + "X-Ca-Stage:" + map.get("X-Ca-Stage") + "\n" + + "X-Ca-Timestamp:" + map.get("X-Ca-Timestamp") + "\n" + + "X-Ca-Version:" + map.get("X-Ca-Version") + "\n" + + httpPost.getURI().getPath() + "?" + httpPost.getURI().getQuery(); + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java index fda444b..399fe5b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ShopUserMapper.java @@ -9,5 +9,13 @@ import org.apache.ibatis.annotations.Select; @Mapper public interface ShopUserMapper { - ShopUser selectShopUserByPhone(@Param("username") String username); + ShopUser selectShopUserByPhone(@Param("phone") String phone); + + + ShopUser selectShopUserByUsername(@Param("username") String username); + + ShopUser selectShopUserByUsernameAndPass(@Param("username") String username,@Param("password") String password); + + int insert(ShopUser shopUser); + } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/AliConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/AliConfigService.java new file mode 100644 index 0000000..d528986 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/AliConfigService.java @@ -0,0 +1,9 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.ShopUser; + +public interface AliConfigService { + + String sendMsg(ShopUser shopUser); + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/MusicHandleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/MusicHandleService.java index f57f3c3..1a0fe22 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/MusicHandleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/MusicHandleService.java @@ -1,13 +1,5 @@ package com.ruoyi.system.service; -import org.apache.tomcat.jni.File; - -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; -import java.io.IOException; - public interface MusicHandleService { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ShopUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ShopUserService.java new file mode 100644 index 0000000..b6df452 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ShopUserService.java @@ -0,0 +1,10 @@ +package com.ruoyi.system.service; + +import com.ruoyi.common.core.domain.entity.ShopUser; +import com.ruoyi.common.core.domain.entity.ShopUserResq; + +public interface ShopUserService { + + ShopUser login(ShopUserResq shopUser); + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AliConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AliConfigServiceImpl.java new file mode 100644 index 0000000..6a84378 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AliConfigServiceImpl.java @@ -0,0 +1,35 @@ +package com.ruoyi.system.service.impl; + +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.ruoyi.common.core.domain.entity.ShopUser; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.system.config.AliConfig; +import com.ruoyi.system.service.AliConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +@Service +public class AliConfigServiceImpl implements AliConfigService { + @Autowired + private RedisCache redisCache; + + + @Override + public String sendMsg(ShopUser shopUser) { + String phone = shopUser.getPhone(); + if (phone == null || phone.isEmpty()) { + return "手机号不能为空"; + } + // 1. 生成6位验证码 + String code = AliConfig.sendMsg(shopUser); + if (code != null){ + // 2. 存入Redis,5分钟有效 + redisCache.setCacheObject("sms_code:" + phone, code, 5, java.util.concurrent.TimeUnit.MINUTES); + } + return code; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java new file mode 100644 index 0000000..a4ea03c --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ShopUserServiceImpl.java @@ -0,0 +1,82 @@ +package com.ruoyi.system.service.impl; + +import cn.hutool.core.util.IdUtil; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.entity.ShopUser; +import com.ruoyi.common.core.domain.entity.ShopUserResq; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.config.UmengConfig; +import com.ruoyi.system.mapper.ShopUserMapper; +import com.ruoyi.system.service.ShopUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Transactional +@Service +public class ShopUserServiceImpl implements ShopUserService { + + @Autowired + private RedisCache redisCache; + @Autowired + private UmengConfig umengConfig; + @Autowired + private ShopUserMapper shopUserMapper; + + @Override + public ShopUser login(ShopUserResq shopUser) { + switch (shopUser.getMethod()){ + case "1": + // 账号密码 + // 生成令牌 + ShopUser member = shopUserMapper.selectShopUserByUsernameAndPass(shopUser.getUsername(),shopUser.getPassword()); + if (member == null){ + ShopUser msg = new ShopUser(); + msg.setMsg("用户名或密码错误"); + return msg; + }else { + return member; + } + case "2": + // 验证码 + String code = redisCache.getCacheObject(shopUser.getPhone()); + String reqCode = shopUser.getCode(); + if (code.equals(reqCode)){ + // 登录 + return loginAndRegis(shopUser); + }else { + ShopUser msg = new ShopUser(); + msg.setMsg("验证码错误"); + return msg; + } + case "3": + // 一键 todo: 完善功能 + String uMtoken = shopUser.getUMtoken(); + umengConfig.send(uMtoken); + break; + } + return null; + } + + public ShopUser loginAndRegis(ShopUserResq shopUser) { + ShopUser member = shopUserMapper.selectShopUserByPhone(shopUser.getUsername()); + if (StringUtils.isNull(member)) { + // 走注册在登录 + member = new ShopUser(); + member.setUserId(IdUtil.getSnowflakeNextId()); + member.setUsername(shopUser.getPhone()); + member.setPhone(shopUser.getPhone()); + member.setPassword(IdUtil.fastUUID()); + member.setUsername(shopUser.getUsername()); + int insertCount = shopUserMapper.insert(member); + if (insertCount > 0){ + return member; + }else { + return null; + } + } + return member; + } + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml index 88f54b9..21c6ca4 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ShopUserMapper.xml @@ -3,6 +3,49 @@ + + + + + + + + INSERT INTO shop_user + + user_id, + username, + password, + phone, + nickname, + sex, + birthday, + addr, + register_time, + status, + vip, + online, + + + #{userId}, + #{username}, + #{password}, + #{phone}, + #{nickname}, + #{sex}, + #{birthday}, + #{addr}, + #{registerTime}, + #{status}, + #{vip}, + #{online}, + + + + \ No newline at end of file