From 985a261c6fedfd0b7418616b42beed8e8913b5c9 Mon Sep 17 00:00:00 2001
From: aiShuiJiaoDeXioShou <2832294398@qq.com>
Date: Mon, 9 Sep 2024 14:38:01 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=90=8D?=
=?UTF-8?q?=EF=BC=8C=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
acdr-ui/.vscode/settings.json | 3 +-
acdr-ui/src/components/AddressCell.vue | 36 ++++++
acdr-ui/src/pages.json | 5 +-
acdr-ui/src/pages/index/index.vue | 27 +++--
acdr-ui/src/pages/settings/index.vue | 114 ++++++++++++++----
acdr-ui/src/static/addresscell/location.png | Bin 0 -> 1604 bytes
.../acdr/common/verify/UserNameValidator.java | 62 ++++++++++
.../setting/controller/SettingController.java | 79 ++++++++++++
.../master/setting/entity/AccountInfo.java | 21 ++++
.../user/service/impl/UsersServiceImpl.java | 3 +-
10 files changed, 309 insertions(+), 41 deletions(-)
create mode 100644 acdr-ui/src/components/AddressCell.vue
create mode 100644 acdr-ui/src/static/addresscell/location.png
create mode 100644 acdr/src/main/java/com/yskj/acdr/common/verify/UserNameValidator.java
create mode 100644 acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java
create mode 100644 acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java
diff --git a/acdr-ui/.vscode/settings.json b/acdr-ui/.vscode/settings.json
index 21db4690..32c7ef4e 100644
--- a/acdr-ui/.vscode/settings.json
+++ b/acdr-ui/.vscode/settings.json
@@ -61,5 +61,6 @@
".eslintrc.cjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,.stylelintrc.*,.eslintrc-auto-import.json,.editorconfig,.commitlint.cjs",
"vite.config.ts": "tsconfig.*.json,uno.config.ts,tsconfig.json,uni-pages.d.ts",
"manifest.config.ts": "manifest.config.ts,pages.config.ts"
- }
+ },
+ "vue3snippets.enable-compile-vue-file-on-did-save-code": true
}
diff --git a/acdr-ui/src/components/AddressCell.vue b/acdr-ui/src/components/AddressCell.vue
new file mode 100644
index 00000000..bb634b83
--- /dev/null
+++ b/acdr-ui/src/components/AddressCell.vue
@@ -0,0 +1,36 @@
+
+
+
+
+ {{
+ !addressDetail.addressComponent
+ ? '正在加载...'
+ : `${addressDetail.addressComponent.city} ${addressDetail.addressComponent.district}`
+ }}
+
+
+
+
+
+
+
diff --git a/acdr-ui/src/pages.json b/acdr-ui/src/pages.json
index 5cc05c5c..e9bc3333 100644
--- a/acdr-ui/src/pages.json
+++ b/acdr-ui/src/pages.json
@@ -299,10 +299,7 @@
{
"path": "pages/settings/index",
"type": "page",
- "style": {
- "navigationBarTitleText": "设置页面"
- },
- "needLogin": true
+ "style": {}
},
{
"path": "pages/space/index",
diff --git a/acdr-ui/src/pages/index/index.vue b/acdr-ui/src/pages/index/index.vue
index 5445ad12..db0e7c9e 100644
--- a/acdr-ui/src/pages/index/index.vue
+++ b/acdr-ui/src/pages/index/index.vue
@@ -10,6 +10,7 @@
+
{
-// isLoading.value = false
-// }, 2000)
-
-const toExtended = () => {
- // 跳转到extended 页面
- uni.navigateTo({
- url: '/pages/extended/index',
- })
-}
-
// 获取当前页面的宠物信息
const getPetInfo = async () => {
try {
const res = await httpGet('/petInfo/index')
if (res.code === 200) {
petInfo.value = res.data
+ } else {
+ toast(res.message)
}
} catch (error) {
console.log(error)
}
}
+const toExtended = () => {
+ // 跳转到extended 页面
+ uni.navigateTo({
+ url: '/pages/extended/index',
+ })
+}
+
const toPath = (path) => {
uni.navigateTo({
url: path,
@@ -113,7 +112,9 @@ const toPath = (path) => {
}
onLoad(async () => {
+ isLoading.value = true
await getPetInfo()
+ isLoading.value = false
})
diff --git a/acdr-ui/src/pages/settings/index.vue b/acdr-ui/src/pages/settings/index.vue
index 426f8a13..94573a90 100644
--- a/acdr-ui/src/pages/settings/index.vue
+++ b/acdr-ui/src/pages/settings/index.vue
@@ -1,12 +1,3 @@
-
-{
- style: {
- navigationBarTitleText: '设置页面',
- },
- needLogin: true,
-}
-
-
@@ -22,37 +13,64 @@
- 账户设置
-
- 手机号绑定
- 191****0915
+
+ 账户名称
+ {{ sinfo.userName }}
-
+
+ 手机号绑定
+ {{ sinfo.phone }}
+
+
+
实名认证
- 已实名
+ 已实名
+ 未实名
+
+
+
+ 修改用户名
+
+
+
+
+
+
+
+
+
+
-
diff --git a/acdr-ui/src/static/addresscell/location.png b/acdr-ui/src/static/addresscell/location.png
new file mode 100644
index 0000000000000000000000000000000000000000..29aed1076d4a69c33a88954531928ed8e2a2f119
GIT binary patch
literal 1604
zcmV-K2D|x*P)Px){z*hZRCr$PT3u`uRTTct%$@CTr~*cP(kQ%$veOON*&5@2BB(K9f+7)L{7EE|
z$b*t7io$~=MiPi5DldXYBJn3tYZOh?1a=ms-G$T`ZIlP&11T6tOS|)TbhoXM+U~vc
zw+*)Ut(osT=R4n=d+zK^3A23BEUzDP2F!K9EO%gT3(WEcXzUOi>9elPXuJ|kix{*J
z#0zRSfaw&02SGgG1k}^gX`g7+jY)kAaDRTj=kNw1+yvle#lpT}#7i)WBZ@xHy~?IhvTC&^wE7%8}}bL=E8M-Bk3oEI5~8Fr2t6We-zCK<01`2v
zHtm6(3i%R)5U?SM(;>D2)pOo=xESTA3k<(zi010yjbRMv8S0AroDkapx6j%_gcnsS
z;3gklivz#aJ&&TFGoX)TpjFh(V8%;Er@cir_f)vp26!dQ2GAuF!Nl-7M*mazWM0(>
zai$r>O45qLv@Kcgde@b*Oc#Lr^NW0!e^C)oSul+1-B(#u(b06OO$7?wpvAPL5c%kh
zWq|7N^V?jw9V1EwO@NFuEzpMzDJSkQjBCJa3_LAUS-E5wJU;Mb*oo`p>1aAB?*amL
z=%&3v#>5w0wCV|0IzI)2FA*I
z$-Q<5-n`LB`o!60h@nhpn!0^sht26T+VYjdI*Fr2BK2$J=wFztI}py{s1
zGoa6U3xr4O8qn&%yC`A@{MigKBIy9e9?@w(HX{bOz1CLJ@O<4Fpa*a+9g3u{>0~>|
z)9P|Lz&0aiZ;q58?hNqDT~9L8>$2qT{1N!g=Rf($IQpmo<8+G*1|nXsXN$X~z-a*S
zwm`{R1>gf&a?bduEF6}>&byu&Y=h<~Jr>_DO#8!7!T$x0Wk993>l$67ewF0@yb9d*
ziV75Bs0re1lM>bscu7;P_@fed3Q#Nqs`1>CRU#m(A|Pn-;I)q;FoG%Jb?)N2-u{X_VzHG
z$=KK(z{k6m`aYH8h=|J7b=y998
z0e#lmzdw?^6RAKMiD|XyEF6%*!dy?>fbm(-1ICIlLZn#Y10q{oEyaZdq+>t|CjtjS
zw~;$i2w9&Lo{9nEv!J>S)=Cv902tU|#CY{xFGXqwIAyC#V^jxX+;u`HzLB!U-{S_F
zil3SR)ntC3^$ZhY{ai)D$6o5k;N%2e$=VO#fk=0cut#L0zwuScnQ8}A1#oZo6`mFx
zBw(?Mpa~2EKZ`)Wg>r}f2*V4DP2GU8ftbG!;BYT4170I?#cKDYx*B3YwF0+fZ6(zI
zhVW0Ngxw-*uTQn|@!$Gn
zFbf|wqWEf#hIT-$3y$R?2j
zfY54FAj}z%f~gl&$hi) 6) {
+ errorString = "用户名长度大于6";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能以特殊字符开头(仅允许字母或数字开头)
+ if (!Character.isLetterOrDigit(userName.charAt(0))) {
+ errorString = "用户名不能以特殊字符开头";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能全是数字
+ if (userName.matches("\\d+")) {
+ errorString = "用户名不能全是数字";
+ System.out.println(errorString);
+ return false;
+ }
+
+ // 用户名不能包含违法词语
+ for (String word : ILLEGAL_WORDS) {
+ if (userName.toLowerCase().contains(word)) {
+ errorString = "用户名包含违法词语: " + word;
+ System.out.println(errorString);
+ return false;
+ }
+ }
+
+ // 所有条件都符合,验证通过
+ return true;
+ }
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java b/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java
new file mode 100644
index 00000000..46236293
--- /dev/null
+++ b/acdr/src/main/java/com/yskj/acdr/master/setting/controller/SettingController.java
@@ -0,0 +1,79 @@
+package com.yskj.acdr.master.setting.controller;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.StrUtil;
+import com.yskj.acdr.common.cache.GlobalRedisCache;
+import com.yskj.acdr.common.response.GlobalResponse;
+import com.yskj.acdr.common.verify.UserNameValidator;
+import com.yskj.acdr.master.setting.entity.AccountInfo;
+import com.yskj.acdr.master.user.entity.Users;
+import com.yskj.acdr.master.user.service.AuthenticationService;
+import com.yskj.acdr.master.user.service.UsersService;
+import jakarta.annotation.Resource;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("/setting")
+@RestController
+public class SettingController {
+
+ @Resource
+ private UsersService usersService;
+
+ @Resource
+ private AuthenticationService authService;
+
+ @Resource
+ private GlobalRedisCache redisCache;
+
+ @Resource
+ private UserNameValidator userValid;
+
+ /**
+ * 获取账户信息
+ * @return 账户信息类
+ */
+ @GetMapping("/info")
+ public GlobalResponse info() {
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ return GlobalResponse.success(
+ new AccountInfo().setIsAuth(authService.isRealName())
+ .setPhone(users.getPhone())
+ .setUserName(users.getNickname())
+ );
+ }
+
+ /**
+ * 修改手机号
+ */
+ @PostMapping("/updatePhone")
+ @Transactional
+ public GlobalResponse updatePhone(String code,String newPhone) {
+ // 验证验证码
+ String cachedCode = redisCache.get(newPhone);
+ if (cachedCode == null || !cachedCode.equals(code)) {
+ return GlobalResponse.failure("验证码错误或已过期");
+ }
+ // 更新用户手机号
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ users.setPhone(newPhone);
+ return GlobalResponse.success(usersService.updateById(users));
+ }
+
+ /**
+ * 修改用户名称
+ */
+ @PostMapping("/updateUserName")
+ @Transactional
+ public GlobalResponse updateUserName(String userName) {
+ // 这里添加验证信息
+ if (!userValid.valid(userName)) {
+ return GlobalResponse.failure("用户名不合理,%s,请重新输入!".formatted(userValid.getErrorString()));
+ }
+ // 更新用户手机号
+ Users users = usersService.getById(StpUtil.getLoginIdAsLong());
+ users.setNickname(userName);
+ return GlobalResponse.success(usersService.updateById(users));
+ }
+
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java b/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java
new file mode 100644
index 00000000..cf6a261a
--- /dev/null
+++ b/acdr/src/main/java/com/yskj/acdr/master/setting/entity/AccountInfo.java
@@ -0,0 +1,21 @@
+package com.yskj.acdr.master.setting.entity;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "AccountInfo", description = "账户信息类")
+public class AccountInfo {
+
+ // 手机号信息
+ private String phone;
+
+ // 用户名信息
+ private String userName;
+
+ // 是否实名认证
+ private Boolean isAuth;
+
+}
diff --git a/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java b/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
index 072a62de..32af9ea0 100644
--- a/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
+++ b/acdr/src/main/java/com/yskj/acdr/master/user/service/impl/UsersServiceImpl.java
@@ -17,6 +17,7 @@ import com.yskj.acdr.master.user.service.UsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yskj.acdr.utils.MutualHttpUtil;
import com.yskj.acdr.utils.ProfileUtil;
+import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -56,7 +57,7 @@ public class UsersServiceImpl extends ServiceImpl implements
@Value("${profiles:active}")
private String debug;
- @Autowired
+ @Resource
private GlobalRedisCache redisCache;
@Override