feat: 一些调整

This commit is contained in:
曹鹏飞 2025-02-18 17:21:32 +08:00
parent d1244064a6
commit 7b7ddb66c6
17 changed files with 71 additions and 48 deletions

View File

@ -109,8 +109,8 @@ public class AdminUserController extends ControllerBase {
AdminUser adminUser=adminUserService.add(request);
try {
String email = adminUser.getEmail();
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, "cn");
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, "cn")
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, Constant.DEFAULT_LANGUAGE_CODE);
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, Constant.DEFAULT_LANGUAGE_CODE)
.replace("${loginName}",adminUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(email.getBytes()))
.replace("${password}",request.getPassword())
@ -181,8 +181,8 @@ public class AdminUserController extends ControllerBase {
for (Integer id : ids) {
String password = RandomUtil.randomString(6);
AdminUser adminUser = adminUserService.resetPassword(id, password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, "cn");
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, "cn")
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE);
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, Constant.DEFAULT_LANGUAGE_CODE)
.replace("${loginName}",adminUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(adminUser.getEmail().getBytes()))
.replace("${password}",password);
@ -205,8 +205,8 @@ public class AdminUserController extends ControllerBase {
try {
String password = RandomUtil.randomString(6);
AdminUser adminUser=adminUserService.forgetPassword(email, password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, "cn");
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, "cn")
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, Constant.DEFAULT_LANGUAGE_CODE);
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, Constant.DEFAULT_LANGUAGE_CODE)
.replace("${loginName}",adminUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(email.getBytes()))
.replace("${password}",password);
@ -232,12 +232,21 @@ public class AdminUserController extends ControllerBase {
* 生成微信服务号关注二维码
*/
@GetMapping("generateQRCode")
@ApiMark(moduleName = "账号管理", apiName = "生成微信服务号关注二维码")
@ApiMark(moduleName = "账号管理", apiName = "生成微信服务号关注二维码", isPublic = true)
public void generateQRCode(HttpServletResponse response) throws Exception {
response.setContentType(MediaType.IMAGE_PNG_VALUE);
response.getOutputStream().write(wxQRCodeService.generateQRCode(AdminUserUtil.getUserId()));
}
/**
* 获取关注二维码链接
*/
@GetMapping("getFollowUrl")
@ApiMark(moduleName = "账号管理", apiName = "获取关注二维码链接", isPublic = true)
public ApiResult<String> getFollowUrl(){
return ApiResult.success(wxQRCodeService.getFollowUrl(AdminUserUtil.getUserId()));
}
/**
* 设置头像
*/
@ -256,13 +265,12 @@ public class AdminUserController extends ControllerBase {
@PostMapping("updatePassword")
@ApiMark(moduleName = "账号管理", apiName = "更新密码")
public ApiResult<Void> updatePassword(@Valid @RequestBody UpdatePasswordRequest request) {
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_ADMIN, request.getEmail());
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_ADMIN, AdminUserUtil.getEmail());
String captcha = redisTemplate.opsForValue().get(redisKey);
VUtils.trueThrowBusinessError(StrUtil.isBlank(captcha)).throwMessage("验证码已失效,请重新获取");
VUtils.trueThrowBusinessError(StrUtil.equals(captcha, request.getCaptcha())).throwMessage("验证码不正确");
AdminUser adminUser = adminUserService.lambdaQuery().eq(AdminUser::getEmail, request.getEmail()).one();
adminUserService.updatePassword(AdminUserUtil.getUserId(), request.getNewPassword());
redisTemplate.delete(redisKey);
adminUserService.updatePassword(adminUser.getId(), request.getNewPassword());
return ApiResult.success();
}

View File

@ -81,7 +81,6 @@ public class MultilingualController extends ControllerBase {
/**
* 获取启用的语言列表
*
* @return 取语言列表
*/
@GetMapping("getLanguages")
@ -139,7 +138,6 @@ public class MultilingualController extends ControllerBase {
/**
* 删除网页组件
*
* @param ids 组件id列表
*/
@PostMapping("/deleteWebComponent")
@ -153,7 +151,7 @@ public class MultilingualController extends ControllerBase {
* 导出网页组件翻译列表
* @param request 请求参数
*/
@GetMapping("exportWebComponentTranslates")
@PostMapping("exportWebComponentTranslates")
@ApiMark(moduleName = "多语言管理", apiName = "导出网页组件翻译列表")
public void exportWebComponentTranslates(HttpServletResponse response
, @Valid @RequestBody WebComponentSearchRequest request) throws IOException {
@ -276,7 +274,7 @@ public class MultilingualController extends ControllerBase {
/**
* 下载语言文件
*/
@PostMapping("/getWebComponentJson")
@GetMapping("/getWebComponentJson")
@ApiMark(moduleName = "多语言管理", apiName = "下载语言文件")
public ResponseEntity<org.springframework.core.io.Resource> getWebComponentJson(HttpServletResponse response) {
List<Language> languages = languageService.getLanguages();

View File

@ -23,7 +23,11 @@ public class WXQRCodeService {
private RedisTemplate<String, String> redisTemplate;
public byte[] generateQRCode(Integer userId) throws Exception {
Object obj = redisTemplate.opsForHash().get("wx:url:follow", userId);
return QRCodeUtil.generateQRCode(getFollowUrl(userId), 200, 200);
}
public String getFollowUrl(Integer userId) {
Object obj = redisTemplate.opsForHash().get("wx:url:follow:admin", userId);
if (Objects.isNull(obj)) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response1 = restTemplate.getForEntity(Constant.WX_TOKEN_URL, String.class);
@ -31,12 +35,12 @@ public class WXQRCodeService {
WXTokenDTO token = JSONUtil.toBean(text, WXTokenDTO.class);
String accessToken = token.getAccess_token();
String url = Constant.WX_QRCODE + "?access_token=" + accessToken;
String scene_str = "app_" + userId;
String scene_str = "admin_" + userId;
WXQrcodeRequest req = new WXQrcodeRequest().setAction_info(new WXQrcodeActionInfo().setScene(new WXQrcodeScene().setScene_str(scene_str)));
WXQrcodeVO qvo = restTemplate.postForObject(url, req, WXQrcodeVO.class);
obj = qvo.getUrl();
redisTemplate.opsForHash().put("wx:url:follow", userId, obj);
redisTemplate.opsForHash().put("wx:url:follow:admin", userId, obj);
}
return QRCodeUtil.generateQRCode(obj.toString(), 200, 200);
return obj.toString();
}
}

View File

@ -113,8 +113,8 @@ public class TicketScheduledTasks {
adminUserIds.addAll(followUserIds);
}
List<AdminUser> adminUsers = adminUserService.listByIds(adminUserIds);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_TICKET_TIMEOUT, "cn");
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_NOTIFY, "cn")
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_TICKET_TIMEOUT, Constant.DEFAULT_LANGUAGE_CODE);
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_NOTIFY, Constant.DEFAULT_LANGUAGE_CODE)
.replace("${no}", ticket.getNo())
.replace("${title}", ticket.getTitle())
.replace("${createUser}", createUser.getName())

View File

@ -14,6 +14,7 @@ import com.nflg.mobilebroken.common.pojo.ApiResult;
import com.nflg.mobilebroken.common.pojo.PageData;
import com.nflg.mobilebroken.common.pojo.request.*;
import com.nflg.mobilebroken.common.pojo.vo.*;
import com.nflg.mobilebroken.common.util.AdminUserUtil;
import com.nflg.mobilebroken.common.util.AppUserUtil;
import com.nflg.mobilebroken.common.util.MultilingualUtil;
import com.nflg.mobilebroken.common.util.VUtils;
@ -121,13 +122,12 @@ public class UserController extends ControllerBase {
**/
@PostMapping("updatePassword")
public ApiResult<Void> updatePassword(@Valid @RequestBody UpdatePasswordRequest request){
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_APP, request.getEmail());
String redisKey = StrUtil.format(Constant.REDIS_KEY_USER_UPDATE_KAPTCHA_APP, AppUserUtil.getEmail());
String captcha = redisTemplate.opsForValue().get(redisKey);
VUtils.trueThrowBusinessError(StrUtil.isBlank(captcha)).throwMessage("验证码已失效,请重新获取");
VUtils.trueThrowBusinessError(StrUtil.equals(captcha, request.getCaptcha())).throwMessage("验证码不正确");
AppUser appUser = appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).one();
VUtils.trueThrowBusinessError(!StrUtil.equals(captcha, request.getCaptcha())).throwMessage("验证码不正确");
appUserService.updatePassword(AppUserUtil.getUserId(), request.getNewPassword());
redisTemplate.delete(redisKey);
appUserService.updatePassword(appUser.getId(), request.getNewPassword());
return ApiResult.success();
}
@ -324,4 +324,12 @@ public class UserController extends ControllerBase {
response.setContentType(MediaType.IMAGE_PNG_VALUE);
response.getOutputStream().write(wxQRCodeService.generateQRCode(AppUserUtil.getUserId()));
}
/**
* 获取关注二维码链接
*/
@GetMapping("getFollowUrl")
public ApiResult<String> getFollowUrl(){
return ApiResult.success(wxQRCodeService.getFollowUrl(AdminUserUtil.getUserId()));
}
}

View File

@ -23,7 +23,11 @@ public class WXQRCodeService {
private RedisTemplate<String, String> redisTemplate;
public byte[] generateQRCode(Integer userId) throws Exception {
Object obj = redisTemplate.opsForHash().get("wx:url:follow", userId);
return QRCodeUtil.generateQRCode(getFollowUrl(userId), 200, 200);
}
public String getFollowUrl(Integer userId) {
Object obj = redisTemplate.opsForHash().get("wx:url:follow:app", userId);
if (Objects.isNull(obj)) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response1 = restTemplate.getForEntity(Constant.WX_TOKEN_URL, String.class);
@ -35,8 +39,8 @@ public class WXQRCodeService {
WXQrcodeRequest req = new WXQrcodeRequest().setAction_info(new WXQrcodeActionInfo().setScene(new WXQrcodeScene().setScene_str(scene_str)));
WXQrcodeVO qvo = restTemplate.postForObject(url, req, WXQrcodeVO.class);
obj = qvo.getUrl();
redisTemplate.opsForHash().put("wx:url:follow", userId, obj);
redisTemplate.opsForHash().put("wx:url:follow:app", userId, obj);
}
return QRCodeUtil.generateQRCode(obj.toString(), 200, 200);
return obj.toString();
}
}

View File

@ -2,6 +2,8 @@ package com.nflg.mobilebroken.common.constant;
public class Constant {
public static final String DEFAULT_LANGUAGE_CODE="cn";
public static final String DICTIONARY_TYPE_SERVICE_EVALUATION = "ServiceEvaluation";
// public static final String DICTIONARY_TYPE_SERVICE_EVALUATION_SELECT = "ServiceEvaluationSelect";

View File

@ -1,6 +1,7 @@
package com.nflg.mobilebroken.common.pojo.request;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nflg.mobilebroken.common.constant.Constant;
import lombok.Data;
import javax.validation.constraints.Email;
@ -35,7 +36,7 @@ public class PrimaryAppUserAddRequest {
private String email;
//语言编码
private String languageCode="cn";
private String languageCode= Constant.DEFAULT_LANGUAGE_CODE;
//手机
private String phone;

View File

@ -7,10 +7,6 @@ import javax.validation.constraints.NotBlank;
@Data
public class UpdatePasswordRequest {
//用户邮箱
@NotBlank(message = "邮箱不能为空")
private String email;
// 验证码
@NotBlank(message = "验证码不能为空")
private String captcha;

View File

@ -2,7 +2,6 @@ package com.nflg.mobilebroken.common.pojo.request;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
@ -13,6 +12,5 @@ public class WebComponentTraslateRequest {
private Integer languageId;
//翻译值
@NotEmpty
private String value;
}

View File

@ -1,6 +1,7 @@
package com.nflg.mobilebroken.common.util;
import cn.hutool.core.map.MapUtil;
import com.nflg.mobilebroken.common.constant.Constant;
import java.util.Map;
import java.util.Optional;
@ -14,7 +15,7 @@ public class MultilingualUtil {
public static String getLanguage() {
String language = THREAD_LOCAL.get();
if (language == null) {
language = "cn";
language = Constant.DEFAULT_LANGUAGE_CODE;
}
return language;
}

View File

@ -63,7 +63,7 @@ public class AppUser implements Serializable {
/**
* 状态0待激活1-启用2禁用
*/
private byte state;
private Byte state;
/**
* 区域id

View File

@ -193,10 +193,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
@Override
public void updatePassword(Integer id, String newPassword) {
AdminUser user = new AdminUser()
.setId(id)
.setPassword(PASSWORDENCODER.encode(newPassword))
.setUpdateTime(LocalDateTime.now());
AdminUser user = getById(id);
user.setPassword(PASSWORDENCODER.encode(newPassword)).setUpdateBy(id).setUpdateTime(LocalDateTime.now());
updateById(user);
}

View File

@ -120,10 +120,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
@Override
public void updatePassword(Integer userId, String password) {
AppUser user=new AppUser()
.setId(userId)
.setPassword(PASSWORDENCODER.encode(password))
.setUpdateTime(LocalDateTime.now());
AppUser user=getById(userId);
user.setPassword(PASSWORDENCODER.encode(password)).setUpdateBy(userId).setUpdateTime(LocalDateTime.now());
updateById(user);
}
@ -168,7 +166,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
// .setCreateBy(AdminUserUtil.getUserId())
.setCreateTime(LocalDateTime.now())
.setState(UserState.ToBeActivated.getState())
.setExpireTime(LocalDateTime.of(LocalDateTime.now().getYear(), 12, 31, 0, 0, 0).toLocalDate());
.setExpireTime(LocalDateTime.of(LocalDateTime.now().getYear(), 12, 31, 8, 0, 0).toLocalDate());
save(user);
return user;
}

View File

@ -131,6 +131,10 @@ public class DictionaryItemTranslateServiceImpl extends ServiceImpl<DictionaryIt
@Override
public String getValueByCode(String dictionaryCode, String dictionaryItemCode,String language) {
return baseMapper.getValueByCode(dictionaryCode, dictionaryItemCode,language);
String value = baseMapper.getValueByCode(dictionaryCode, dictionaryItemCode,language);
if (StrUtil.isNotBlank(value) || StrUtil.equals(language,Constant.DEFAULT_LANGUAGE_CODE)) {
return value;
}
return baseMapper.getValueByCode(dictionaryCode, dictionaryItemCode, language);
}
}

View File

@ -38,7 +38,10 @@
</foreach>
</select>
<select id="getInfo" resultType="com.nflg.mobilebroken.common.pojo.vo.AppUserVO">
SELECT u.id,u.area_id AS 'areaId',c.agency_company_name AS 'companyName',u.`name`,u.email,u.avatar,a.`name` AS 'areaName',u.state AS 'userState',uc.`name` AS 'createBy',u.create_time AS 'createTime',uu.`name` AS 'updateBy',u.update_time AS 'updateTime',u.last_login_time AS 'lastLoginTime',u.expire_time AS 'expireTime',u.is_primary AS 'isPrimary'
SELECT u.id,u.area_id AS 'areaId',c.agency_company_name AS 'companyName',u.`name`,u.email,u.avatar,a.`name` AS 'areaName'
,u.state AS 'userState',uc.`name` AS 'createBy',u.create_time AS 'createTime',uu.`name` AS 'updateBy'
,u.update_time AS 'updateTime',u.last_login_time AS 'lastLoginTime',u.expire_time AS 'expireTime'
,u.is_primary AS 'isPrimary',u.login_name AS 'loginName',u.phone
FROM app_user u
INNER JOIN t_base_customer c ON u.company_id=c.id
INNER JOIN app_area a ON u.area_id=a.id

View File

@ -46,7 +46,7 @@
</select>
<select id="getValueByCode" resultType="java.lang.String">
SELECT IFNULL(dit.`value`,di.`value`) AS 'value'
SELECT dit.`value`
FROM dictionary d
INNER JOIN dictionary_item di ON d.id=di.dictionary_id
LEFT JOIN dictionary_item_translate dit ON dit.dictionary_item_id=di.id AND dit.language_code=#{language}