This commit is contained in:
张良(004796)
2024-04-18 15:33:43 +08:00
parent 6ca720bd9f
commit 5f4ad8c3b0
20 changed files with 198 additions and 23 deletions

View File

@@ -16,6 +16,12 @@
</description> </description>
<dependencies> <dependencies>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<!-- spring-boot-devtools --> <!-- spring-boot-devtools -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@@ -0,0 +1,29 @@
package com.ruoyi.test;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.util.PinYinUtil;
import com.ruoyi.xq.domain.AreaCode;
import com.ruoyi.xq.service.AreaCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class RefreshArea {
@Autowired
private AreaCodeService areaCodeService;
public void refreshPinyin(){
List<AreaCode> list = areaCodeService.list();
for (AreaCode areaCode : list) {
String firstSpell = PinYinUtil.getFirstSpell(areaCode.getName());
areaCodeService.update(Wrappers.lambdaUpdate(AreaCode.class)
.eq(AreaCode::getCode, areaCode.getCode())
.set(AreaCode::getFirstSpell, firstSpell));
}
}
}

View File

@@ -0,0 +1,89 @@
package com.ruoyi.util;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* 拼音工具类
*/
public class PinYinUtil {
/**
* 将字符串中的中文转化为拼音,其他字符不变
*
* @param inputString
* @return
*/
public static String getPingYin(String inputString) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
format.setVCharType(HanyuPinyinVCharType.WITH_V);
char[] input = inputString.trim().toCharArray();
String output = "";
try {
for (int i = 0; i < input.length; i++) {
if (java.lang.Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);
output += temp[0];
} else
output += java.lang.Character.toString(input[i]);
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
return output;
}
/**
* 获取汉字串拼音首字母,英文字符不变
* @param chinese 汉字串
* @return 汉语拼音首字母
*/
public static String getFirstSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat);
if (temp != null) {
pybf.append(temp[0].charAt(0));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(arr[i]);
}
}
return pybf.toString().replaceAll("\\W", "").trim();
}
/**
* 获取汉字串拼音,英文字符不变
* @param chinese 汉字串
* @return 汉语拼音
*/
public static String getFullSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
try {
pybf.append(PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat)[0]);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(arr[i]);
}
}
return pybf.toString();
}
}

View File

@@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit;
* *
* @author Lion Li * @author Lion Li
*/ */
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件 @SpringBootTest
@DisplayName("单元测试案例") @DisplayName("单元测试案例")
public class DemoUnitTest { public class DemoUnitTest {

View File

@@ -0,0 +1,19 @@
package com.ruoyi.test.business;
import com.ruoyi.test.RefreshArea;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
@Slf4j
public class RefreshTest {
@Autowired
private RefreshArea refreshArea;
@Test
public void refresh(){
refreshArea.refreshPinyin();
}
}

View File

@@ -1,10 +1,13 @@
package com.ruoyi.xq.controller.app; package com.ruoyi.xq.controller.app;
import cn.dev33.satoken.annotation.SaIgnore; import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.BeanConvertUtil;
import com.ruoyi.xq.domain.AreaCode; import com.ruoyi.xq.domain.AreaCode;
import com.ruoyi.xq.dto.app.areacode.AreaCodeHomeVo;
import com.ruoyi.xq.dto.app.areacode.AreaCodeQuery; import com.ruoyi.xq.dto.app.areacode.AreaCodeQuery;
import com.ruoyi.xq.dto.app.areacode.AreaCodeTree; import com.ruoyi.xq.dto.app.areacode.AreaCodeTree;
import com.ruoyi.xq.dto.app.setting.AgreementDTO; import com.ruoyi.xq.dto.app.setting.AgreementDTO;
@@ -54,6 +57,16 @@ public class SettingAppController {
return R.ok(new AgreementDTO(anchorJoinAgreement)); return R.ok(new AgreementDTO(anchorJoinAgreement));
} }
@GetMapping("/areaCode/homeCity")
@Operation(summary = "获取首页城市选择列表")
@Log(title = "获取首页城市选择列表", businessType = BusinessType.OTHER, isSaveDb = false)
public R<List<AreaCodeHomeVo>> homeCity(){
List<AreaCode> list = areaCodeService.list(Wrappers.lambdaQuery(AreaCode.class).eq(AreaCode::getLevel, "city"));
List<AreaCodeHomeVo> vos = BeanConvertUtil.convertListTo(list, AreaCodeHomeVo::new);
return R.ok(vos);
}
@GetMapping("/areaCode/list") @GetMapping("/areaCode/list")
@Operation(summary = "获取省市区编码接口") @Operation(summary = "获取省市区编码接口")
@Log(title = "获取省市区编码接口", businessType = BusinessType.OTHER, isSaveDb = false) @Log(title = "获取省市区编码接口", businessType = BusinessType.OTHER, isSaveDb = false)

View File

@@ -28,6 +28,7 @@ public class AreaCode implements Serializable {
* 名字 * 名字
*/ */
private String name; private String name;
private String firstSpell;
/** /**
* country:国家、province:省份直辖市会在province和city显示、city:市直辖市会在province和city显示、district:区县 * country:国家、province:省份直辖市会在province和city显示、city:市直辖市会在province和city显示、district:区县
*/ */

View File

@@ -89,8 +89,11 @@ public class User implements Serializable {
/** /**
* 居住地代码 * 居住地代码
*/ */
private String residenceCode; private Integer residenceCode;
// private String residenceCityCode; /**
* 居住地城市编码
*/
private Integer residenceCityCode;
/** /**
* 居住城市 * 居住城市
*/ */

View File

@@ -35,6 +35,8 @@ public class UserAuth implements Serializable {
* 用户号 * 用户号
*/ */
private String usercode; private String usercode;
private Integer alreadyAuthNum;
/** /**
* 实名认证 0-待提交 1-审核中 2-审核通过(认证成功) 3-审核失败 * 实名认证 0-待提交 1-审核中 2-审核通过(认证成功) 3-审核失败
*/ */

View File

@@ -119,7 +119,7 @@ public class UserInfo implements Serializable {
* 择偶条件-地区 * 择偶条件-地区
*/ */
private String filterResidence; private String filterResidence;
private String filterResidenceCode; private Integer filterResidenceCode;
/** /**
* 择偶条件-年收入 * 择偶条件-年收入
*/ */

View File

@@ -0,0 +1,10 @@
package com.ruoyi.xq.dto.app.areacode;
import lombok.Data;
@Data
public class AreaCodeHomeVo {
private Integer code;
private String name;
private String firstSpell;
}

View File

@@ -22,7 +22,7 @@ public class DynamicQuery {
private Integer ageEnd; private Integer ageEnd;
@Schema(description = "居住地") @Schema(description = "居住地")
private String residenceCode; private Integer residenceCode;
@Schema(description = "1-最新发布 2-热门动态") @Schema(description = "1-最新发布 2-热门动态")
private Integer sortBy = 1; private Integer sortBy = 1;

View File

@@ -41,10 +41,12 @@ public class HomePageReq extends PageQuery {
private Integer marriage; private Integer marriage;
@Schema(description = "教育") @Schema(description = "教育")
private Integer education; private Integer education;
@Schema(description = "居住城市编码")
private String residenceCityCode;
// @Schema(description = "居住地") // @Schema(description = "居住地")
// private String residenceCode; // private Integer residenceCode;
@Schema(description = "居住地城市中文") // @Schema(description = "居住地城市中文")
private String residenceCodeStr; // private String residenceCodeStr;
@Schema(description = "VIP查询限制") @Schema(description = "VIP查询限制")
private VipQuery vipQuery; private VipQuery vipQuery;

View File

@@ -29,7 +29,7 @@ public class UpdateBaseInfoReq {
* 居住地 * 居住地
*/ */
@Schema(description = "居住地") @Schema(description = "居住地")
private String residenceCode; private Integer residenceCode;
/** /**
* 户籍地 * 户籍地
*/ */

View File

@@ -30,7 +30,7 @@ public class UpdateUserFullInfoReq {
private String wxCode; private String wxCode;
@Schema(description = "居住地") @Schema(description = "居住地")
private String residenceCode; private Integer residenceCode;
@Schema(description = "户籍地") @Schema(description = "户籍地")
private String addressCode; private String addressCode;
@Schema(description = "学历") @Schema(description = "学历")
@@ -87,7 +87,7 @@ public class UpdateUserFullInfoReq {
@Schema(description = "择偶条件-学历") @Schema(description = "择偶条件-学历")
private Integer filterEducation; private Integer filterEducation;
@Schema(description = "择偶条件-地区Code") @Schema(description = "择偶条件-地区Code")
private String filterResidenceCode; private Integer filterResidenceCode;
@Schema(description = "择偶条件-年收入") @Schema(description = "择偶条件-年收入")
private Integer filterAnnualIncome; private Integer filterAnnualIncome;
@Schema(description = "择偶条件-小孩情况") @Schema(description = "择偶条件-小孩情况")

View File

@@ -67,7 +67,7 @@ public class CurrentUserFullInfoVo {
* 居住地 * 居住地
*/ */
@Schema(description = "居住地") @Schema(description = "居住地")
private String residenceCode; private Integer residenceCode;
@Schema(description = "居住地名称") @Schema(description = "居住地名称")
private String residenceName; private String residenceName;
@Schema(description = "居住地城市") @Schema(description = "居住地城市")
@@ -216,7 +216,7 @@ public class CurrentUserFullInfoVo {
@Schema(description = "择偶条件-地区") @Schema(description = "择偶条件-地区")
private String filterResidence; private String filterResidence;
@Schema(description = "择偶条件-地区Code") @Schema(description = "择偶条件-地区Code")
private String filterResidenceCode; private Integer filterResidenceCode;
/** /**
* 择偶条件-年收入 * 择偶条件-年收入
*/ */

View File

@@ -47,7 +47,7 @@ public class CurrentUserInfoVo {
@Schema(description = "居住地名称") @Schema(description = "居住地名称")
private String residenceName; private String residenceName;
@Schema(description = "居住地编码") @Schema(description = "居住地编码")
private String residenceCode; private Integer residenceCode;
@Schema(description = "户籍地名称") @Schema(description = "户籍地名称")
private String addressName; private String addressName;
@Schema(description = "户籍地编码") @Schema(description = "户籍地编码")
@@ -65,9 +65,6 @@ public class CurrentUserInfoVo {
@Schema(description = "imToken") @Schema(description = "imToken")
private String imToken; private String imToken;
@Schema(description = "交换微信次数")
private Integer wxExchangeNum = 0;
@Schema(description = "已认证数量") @Schema(description = "已认证数量")
private Integer alreadyAuthNum = 0; private Integer alreadyAuthNum = 0;
@@ -90,7 +87,7 @@ public class CurrentUserInfoVo {
* 交换微信次数 * 交换微信次数
*/ */
@Schema(description = "交换微信次数") @Schema(description = "交换微信次数")
private Integer wxTransNum; private Integer wxTransNum = 0;
/** /**
* 相册 * 相册
*/ */

View File

@@ -62,7 +62,7 @@ public class HomeUserVo {
@Schema(description = "居住地名称") @Schema(description = "居住地名称")
private String residenceName; private String residenceName;
@Schema(description = "居住地编码") @Schema(description = "居住地编码")
private String residenceCode; private Integer residenceCode;
/** /**
* 户籍地 * 户籍地
*/ */
@@ -208,7 +208,7 @@ public class HomeUserVo {
private String filterResidence; private String filterResidence;
@Schema(description = "择偶条件-地区Code") @Schema(description = "择偶条件-地区Code")
private String filterResidenceCode; private Integer filterResidenceCode;
/** /**
* 择偶条件-年收入 * 择偶条件-年收入
*/ */

View File

@@ -111,6 +111,8 @@ public class CurrentUserManager {
vo.setFinishBaseStatus(user.getFinishBaseStatus()); vo.setFinishBaseStatus(user.getFinishBaseStatus());
vo.setBaseStep(user.getBaseStep()); vo.setBaseStep(user.getBaseStep());
vo.setImToken(user.getImToken()); vo.setImToken(user.getImToken());
UserAuth userAuth = userAuthService.getByUserId(userId);
vo.setAlreadyAuthNum(userAuth.getAlreadyAuthNum());
List<UserPictures> userPictures = userPicturesService.listByUserIdAuditingAndSuccess(user.getId()); List<UserPictures> userPictures = userPicturesService.listByUserIdAuditingAndSuccess(user.getId());
vo.setUserPicturesList(BeanConvertUtil.convertListTo(userPictures, UserPicturesDTO::new)); vo.setUserPicturesList(BeanConvertUtil.convertListTo(userPictures, UserPicturesDTO::new));
UserVip userVip = userVipService.getByUserVipMaster(userId); UserVip userVip = userVipService.getByUserVipMaster(userId);
@@ -143,10 +145,11 @@ public class CurrentUserManager {
updateUser.setAddressCode(req.getAddressCode()); updateUser.setAddressCode(req.getAddressCode());
updateUser.setAddressName(areaCode.getName()); updateUser.setAddressName(areaCode.getName());
} }
if(StringUtils.isNotEmpty(req.getResidenceCode())){ if(req.getResidenceCode() != null){
AreaCode areaCode = areaCodeService.getById(req.getResidenceCode()); AreaCode areaCode = areaCodeService.getById(req.getResidenceCode());
updateUser.setResidenceCode(req.getResidenceCode()); updateUser.setResidenceCode(req.getResidenceCode());
updateUser.setResidenceName(areaCode.getName()); updateUser.setResidenceName(areaCode.getName());
updateUser.setResidenceCityCode(areaCode.getPcode());
updateUser.setResidenceCityName(areaCode.getPname()); updateUser.setResidenceCityName(areaCode.getPname());
} }
if(req.getHeight() != null){ if(req.getHeight() != null){
@@ -263,7 +266,7 @@ public class CurrentUserManager {
updateUser.setAddressCode(req.getAddressCode()); updateUser.setAddressCode(req.getAddressCode());
updateUser.setAddressName(areaCode.getFullname()); updateUser.setAddressName(areaCode.getFullname());
} }
if(StringUtils.isNotEmpty(req.getResidenceCode())){ if(req.getResidenceCode() != null){
AreaCode areaCode = areaCodeService.getById(req.getResidenceCode()); AreaCode areaCode = areaCodeService.getById(req.getResidenceCode());
updateUser.setResidenceCode(req.getResidenceCode()); updateUser.setResidenceCode(req.getResidenceCode());
updateUser.setResidenceName(areaCode.getFullname()); updateUser.setResidenceName(areaCode.getFullname());
@@ -273,7 +276,7 @@ public class CurrentUserManager {
userService.updateById(updateUser); userService.updateById(updateUser);
UserInfo updateUserInfo = BeanConvertUtil.convertTo(req, UserInfo::new); UserInfo updateUserInfo = BeanConvertUtil.convertTo(req, UserInfo::new);
if(StringUtils.isNotEmpty(req.getFilterResidenceCode())){ if(req.getFilterResidenceCode() != null){
AreaCode areaCode = areaCodeService.getById(req.getResidenceCode()); AreaCode areaCode = areaCodeService.getById(req.getResidenceCode());
updateUserInfo.setFilterResidenceCode(req.getFilterResidenceCode()); updateUserInfo.setFilterResidenceCode(req.getFilterResidenceCode());
updateUserInfo.setFilterResidence(areaCode.getFullname()); updateUserInfo.setFilterResidence(areaCode.getFullname());

View File

@@ -220,6 +220,7 @@ public class LoginManager {
userAuth.setUserId(user.getId()); userAuth.setUserId(user.getId());
userAuth.setPhone(user.getMobile()); userAuth.setPhone(user.getMobile());
userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode()); userAuth.setPhoneAuth(AuditEnum.SUCCESS.getCode());
userAuth.setAlreadyAuthNum(1);
userAuthService.save(userAuth); userAuthService.save(userAuth);
UserExtend userExtend = new UserExtend(); UserExtend userExtend = new UserExtend();
userExtend.setUsercode(usercode); userExtend.setUsercode(usercode);