refactor: 优化实体类

This commit is contained in:
Bunny 2024-12-05 23:02:28 +08:00
parent 60592ec580
commit 17ec9cbe3b
68 changed files with 288 additions and 510 deletions

View File

@ -26,7 +26,7 @@ public class ControllerStringParamTrimConfig {
// String 类对象注册编辑器
binder.registerCustomEditor(String.class, propertyEditor);
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return jacksonObjectMapperBuilder -> {
@ -35,8 +35,6 @@ public class ControllerStringParamTrimConfig {
.deserializerByType(String.class, new StdScalarDeserializer<String>(String.class) {
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException {
// 去除全部空格
// return StringUtils.trimAllWhitespace(jsonParser.getValueAsString());
// 仅去除前后空格
return jsonParser.getValueAsString().trim();
}

View File

@ -16,11 +16,11 @@ public class Knife4jConfig {
@Bean
public OpenAPI openAPI() {
// 作者等信息
Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url("http://z-bunny.cn");
Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url("http://bunny-web.site");
// 使用协议
License license = new License().name("MIT").url("https://MUT.com");
// 相关信息
Info info = new Info().title("Bunny-Admin").description("权限管理模板").version("v1.0.0").contact(contact).license(license).termsOfService("MIT");
Info info = new Info().title("家庭理财管理系统").description("家庭理财管理系统").version("v1.0.0").contact(contact).license(license).termsOfService("MIT");
return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
}
@ -28,6 +28,6 @@ public class Knife4jConfig {
// 管理员相关分类接口
@Bean
public GroupedOpenApi groupedOpenAdminApi() {
return GroupedOpenApi.builder().group("默认请求接口").pathsToMatch("/admin/**").build();
return GroupedOpenApi.builder().group("后台管理").pathsToMatch("/admin/**").build();
}
}

View File

@ -23,7 +23,7 @@ public class MybatisPlusConfig {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 分页插件
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
// 设置最大分页为100
// 设置最大分页为 600
paginationInnerInterceptor.setMaxLimit(600L);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
// 乐观锁

View File

@ -10,24 +10,24 @@ import lombok.extern.slf4j.Slf4j;
@Getter
@ToString
@Slf4j
public class BunnyException extends RuntimeException {
public class AuthCustomerException extends RuntimeException {
Integer code;// 状态码
String message;// 描述信息
ResultCodeEnum resultCodeEnum;
public BunnyException(Integer code, String message) {
public AuthCustomerException(Integer code, String message) {
super(message);
this.code = code;
this.message = message;
}
public BunnyException(String message) {
public AuthCustomerException(String message) {
super(message);
this.message = message;
}
public BunnyException(ResultCodeEnum codeEnum) {
public AuthCustomerException(ResultCodeEnum codeEnum) {
super(codeEnum.getMessage());
this.code = codeEnum.getCode();
this.message = codeEnum.getMessage();

View File

@ -21,9 +21,9 @@ import java.util.stream.Collectors;
@Slf4j
public class GlobalExceptionHandler {
// 自定义异常信息
@ExceptionHandler(BunnyException.class)
@ExceptionHandler(AuthCustomerException.class)
@ResponseBody
public Result<Object> exceptionHandler(BunnyException exception) {
public Result<Object> exceptionHandler(AuthCustomerException exception) {
Integer code = exception.getCode() != null ? exception.getCode() : 500;
return Result.error(null, code, exception.getMessage());
}

View File

@ -1,206 +0,0 @@
package cn.bunny.common.service.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpUtil {
public static HttpResponse doGet(String host, String path, String method, Map<String, String> headers, Map<String, String> querys) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, Map<String, String> bodys) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
public static HttpResponse doDelete(String host, String path, String method, Map<String, String> headers, Map<String, String> querys) throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (!sbQuery.isEmpty()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), StandardCharsets.UTF_8));
}
}
}
if (!sbQuery.isEmpty()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslClient(httpClient);
}
return httpClient;
}
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[]{tm}, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (Exception ex) {
throw new RuntimeException();
}
}
}

View File

@ -1,6 +1,6 @@
package cn.bunny.common.service.utils;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import io.jsonwebtoken.*;
import io.micrometer.common.lang.Nullable;
@ -210,14 +210,14 @@ public class JwtHelper {
*/
public static Map<String, Object> getMapByToken(String token) {
try {
if (!StringUtils.hasText(token)) throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
if (!StringUtils.hasText(token)) throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
Claims claims = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token).getBody();
// body 值转为map
return new HashMap<>(claims);
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
}
}
@ -230,14 +230,14 @@ public class JwtHelper {
*/
public static Map<String, Object> getMapByToken(String token, String signKey) {
try {
if (!StringUtils.hasText(token)) throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
if (!StringUtils.hasText(token)) throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(signKey).parseClaimsJws(token);
Claims body = claimsJws.getBody();
// body 值转为map
return new HashMap<>(body);
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
}
}
@ -254,14 +254,14 @@ public class JwtHelper {
@Nullable
private static String getSubjectByTokenHandler(String token, String tokenSignKey) {
try {
if (!StringUtils.hasText(token)) throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
if (!StringUtils.hasText(token)) throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token);
Claims body = claimsJws.getBody();
return body.getSubject();
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
}
}
@ -283,14 +283,14 @@ public class JwtHelper {
*/
public static Long getUserId(String token) {
try {
if (!StringUtils.hasText(token)) throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
if (!StringUtils.hasText(token)) throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token);
Claims claims = claimsJws.getBody();
return Long.valueOf(String.valueOf(claims.get("userId")));
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
}
}
@ -308,7 +308,7 @@ public class JwtHelper {
Claims claims = claimsJws.getBody();
return (String) claims.get("username");
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.TOKEN_PARSING_FAILED);
throw new AuthCustomerException(ResultCodeEnum.TOKEN_PARSING_FAILED);
}
}

View File

@ -1,12 +0,0 @@
package cn.bunny.common.service.utils;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import jakarta.servlet.http.HttpServletResponse;
public class ResponseHandlerUtil {
public static boolean loginAuthHandler(HttpServletResponse response, ResultCodeEnum loginAuth) {
ResponseUtil.out(response, Result.error(loginAuth));
return false;
}
}

View File

@ -1,6 +1,6 @@
package cn.bunny.common.service.utils.minio;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.pojo.common.MinioFilePath;
import cn.bunny.dao.pojo.constant.MinioConstant;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -78,7 +78,7 @@ public class MinioUtil {
public MinioFilePath uploadObjectReturnFilePath(MultipartFile file, String minioPreType) throws IOException {
if (file == null) return null;
String bucketName = properties.getBucketName();
// 上传对象
try {
MinioFilePath minioFile = initUploadFileReturnMinioFilePath(bucketName, minioPreType, file);
@ -87,7 +87,8 @@ public class MinioUtil {
return minioFile;
} catch (Exception exception) {
throw new BunnyException(ResultCodeEnum.UPDATE_ERROR);
exception.printStackTrace();
throw new AuthCustomerException(ResultCodeEnum.UPDATE_ERROR);
}
}
@ -107,7 +108,7 @@ public class MinioUtil {
} catch (Exception exception) {
exception.printStackTrace();
}
throw new BunnyException(ResultCodeEnum.GET_BUCKET_EXCEPTION);
throw new AuthCustomerException(ResultCodeEnum.GET_BUCKET_EXCEPTION);
}
/**
@ -135,7 +136,7 @@ public class MinioUtil {
minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(filename).stream(inputStream, size, -1).build());
} catch (Exception exception) {
log.error("上传文件失败:{}", (Object) exception.getStackTrace());
throw new BunnyException(ResultCodeEnum.UPDATE_ERROR);
throw new AuthCustomerException(ResultCodeEnum.UPDATE_ERROR);
}
}
@ -152,7 +153,7 @@ public class MinioUtil {
Iterable<Result<DeleteError>> results = minioClient.removeObjects(RemoveObjectsArgs.builder().bucket(bucketName).objects(objectList).build());
for (Result<DeleteError> result : results) {
DeleteError error = result.get();
throw new BunnyException("Error in deleting object " + error.objectName() + "; " + error.message());
throw new AuthCustomerException("Error in deleting object " + error.objectName() + "; " + error.message());
}
} catch (Exception exception) {
exception.printStackTrace();
@ -170,7 +171,7 @@ public class MinioUtil {
try {
putObject(bucketName, filepath, file.getInputStream(), file.getSize());
} catch (IOException e) {
throw new BunnyException(e.getMessage());
throw new AuthCustomerException(e.getMessage());
}
}
}

View File

@ -14,8 +14,8 @@ import java.time.LocalDate;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "ExpendWithIncomeDto对象", title = "账单收入和支出查询表单", description = "账单收入和支出查询表单")
public class ExpendWithIncomeDto {
@Schema(name = "IncomeExpenseQueryDto对象", title = "账单收入和支出查询表单", description = "账单收入和支出查询表单")
public class IncomeExpenseQueryDto {
@Schema(name = "userId", title = "绑定的用户id")
private Long userId;

View File

@ -15,8 +15,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BillAddDto对象", title = "账单信息添加内容", description = "账单信息添加内容")
public class BillImportUserDto {
@Schema(name = "BillImportByUserDto对象", title = "账单信息添加内容", description = "账单信息添加内容")
public class BillImportByUserDto {
@Schema(name = "username", title = "类型1 - 收入,-1 - 支出")
@ExcelProperty(index = 0)

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BillAddDto对象", title = "账单信息添加内容", description = "账单信息添加内容")
public class BillAddUserDto {
@Schema(name = "BillAddByUserDto对象", title = "账单信息添加内容", description = "账单信息添加内容")
public class BillAddByUserDto {
@Schema(name = "username", title = "类型1 - 收入,-1 - 支出")
@NotNull(message = "类型不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BillUpdateDto对象", title = "账单信息更新内容", description = "账单信息更新内容")
public class BillUpdateUserDto {
@Schema(name = "BillUpdateByUserDto对象", title = "账单信息更新内容", description = "账单信息更新内容")
public class BillUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BudgetCategoryAddDto对象", title = "预算分类添加", description = "预算分类添加")
public class BudgetCategoryAddUserDto {
@Schema(name = "BudgetCategoryAddByUserDto对象", title = "预算分类添加", description = "预算分类添加")
public class BudgetCategoryAddByUserDto {
@Schema(name = "parentId", title = "父级id")
@NotNull(message = "父级id不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BudgetCategoryUpdateDto对象", title = "预算分类更新", description = "预算分类更新")
public class BudgetCategoryUpdateUserDto {
@Schema(name = "BudgetCategoryUpdateByUserDto对象", title = "预算分类更新", description = "预算分类更新")
public class BudgetCategoryUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -12,8 +12,8 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "CategoryUserAddDto对象", title = "分类信息添加", description = "分类信息添加")
public class CategoryUserAddDto {
@Schema(name = "CategoryAddByUserDto对象", title = "分类信息添加", description = "分类信息添加")
public class CategoryAddByUserDto {
@Schema(name = "categoryName", title = "分类名称")
@NotNull(message = "分类名称不能为空")

View File

@ -12,8 +12,8 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "CategoryUpdateDto对象", title = "分类信息添加", description = "分类信息添加")
public class CategoryUserUpdateDto {
@Schema(name = "CategoryUpdateByUserDto对象", title = "分类信息添加", description = "分类信息添加")
public class CategoryUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "CategoryUserAddDto对象", title = "债务还款计划表添加", description = "债务还款计划表添加")
public class DebtRepaymentPlanAddUserDto {
@Schema(name = "DebtRepaymentPlanAddByUserDto对象", title = "债务还款计划表添加", description = "债务还款计划表添加")
public class DebtRepaymentPlanAddByUserDto {
@Schema(name = "installmentNumber", title = "债务金额")
@NotNull(message = "债务金额不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtRepaymentPlanUpdateDto对象", title = "债务还款计划更新", description = "债务还款计划更新")
public class DebtRepaymentPlanUpdateUserDto {
@Schema(name = "DebtRepaymentPlanUpdateByUserDto对象", title = "债务还款计划更新", description = "债务还款计划更新")
public class DebtRepaymentPlanUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingAddDto对象", title = "债务追踪添加", description = "债务追踪")
public class DebtTrackingAddUserDto {
@Schema(name = "DebtTrackingAddByUserDto对象", title = "债务追踪添加", description = "债务追踪")
public class DebtTrackingAddByUserDto {
@Schema(name = "debtorName", title = "债务人姓名")
@NotNull(message = "债务人姓名不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingUpdateDto对象", title = "债务追踪更新", description = "债务追踪更新")
public class DebtTrackingUpdateUserDto {
@Schema(name = "DebtTrackingUpdateByUserDto对象", title = "债务追踪更新", description = "债务追踪更新")
public class DebtTrackingUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "SavingGoalAddDto对象", title = "用户储值添加", description = "用户储值添加")
public class SavingGoalAddUserDto {
@Schema(name = "SavingGoalAddByUserDto对象", title = "用户储值添加", description = "用户储值添加")
public class SavingGoalAddByUserDto {
@Schema(name = "statusType", title = "完成状态")
@NotNull(message = "完成状态不能为空")

View File

@ -17,8 +17,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "SavingGoalUpdateDto对象", title = "用户储值更新", description = "用户储值更新")
public class SavingGoalUpdateUserDto {
@Schema(name = "SavingGoalUpdateByUserDto对象", title = "用户储值更新", description = "用户储值更新")
public class SavingGoalUpdateByUserDto {
@Schema(name = "id", title = "主键")
@NotNull(message = "id不能为空")

View File

@ -18,8 +18,8 @@ import java.time.LocalDateTime;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "BillUserVo对象", title = "用户账单信息返回内容", description = "用户账单信息返回内容")
public class BillUserExportExcel extends BaseVo {
@Schema(name = "BillExportExcelByUser对象", title = "用户账单信息返回内容", description = "用户账单信息返回内容")
public class BillExportExcelByUser extends BaseVo {
@Schema(name = "username", title = "类型1 - 收入,-1 - 支出")
@ExcelProperty("类型1 - 收入,-1 - 支出")

View File

@ -1,6 +1,6 @@
package cn.bunny.services.aop;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
@ -34,7 +34,7 @@ public class AnnotationScanner {
Class<?> clazz = Class.forName(bd.getBeanClassName());
classes.add(clazz);
} catch (ClassNotFoundException e) {
throw new BunnyException(ResultCodeEnum.CLASS_NOT_FOUND);
throw new AuthCustomerException(ResultCodeEnum.CLASS_NOT_FOUND);
}
}

View File

@ -1,12 +1,12 @@
package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.bill.BillDto;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
import cn.bunny.dao.dto.financial.bill.excel.BillExportDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddByUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateByUserDto;
import cn.bunny.dao.entity.financial.Bill;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -72,7 +72,7 @@ public class BillController {
@Operation(summary = "账单收入和支出图表展示", description = "账单收入和支出图表展示")
@GetMapping("noManage/getExpendOrIncome")
public Mono<Result<ExpendWithIncomeListVo>> getExpendOrIncome(ExpendWithIncomeDto dto) {
public Mono<Result<ExpendWithIncomeListVo>> getExpendOrIncome(IncomeExpenseQueryDto dto) {
ExpendWithIncomeListVo vo = billService.getExpendOrIncome(dto);
return Mono.just(Result.success(vo));
}
@ -105,7 +105,7 @@ public class BillController {
@Operation(summary = "用户添加账单信息", description = "用户添加账单信息")
@PostMapping("noManage/addUserBill")
public Mono<Result<String>> addUserBill(@Valid @RequestBody BillAddUserDto dto) {
public Mono<Result<String>> addUserBill(@Valid @RequestBody BillAddByUserDto dto) {
billService.addUserBill(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@ -119,7 +119,7 @@ public class BillController {
@Operation(summary = "用户更新账单信息", description = "用户更新账单信息")
@PutMapping("noManage/updateUserBill")
public Mono<Result<String>> updateUserBill(@Valid @RequestBody BillUpdateUserDto dto) {
public Mono<Result<String>> updateUserBill(@Valid @RequestBody BillUpdateByUserDto dto) {
billService.updateUserBill(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -3,8 +3,8 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryAddDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryUpdateDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddByUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.BudgetCategory;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -89,7 +89,7 @@ public class BudgetCategoryController {
@Operation(summary = "用户添加预算分类表", description = "用户添加预算分类表")
@PostMapping("noManage/addUserBudgetCategory")
public Mono<Result<String>> addUserBudgetCategory(@Valid @RequestBody BudgetCategoryAddUserDto dto) {
public Mono<Result<String>> addUserBudgetCategory(@Valid @RequestBody BudgetCategoryAddByUserDto dto) {
budgetCategoryService.addUserBudgetCategory(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@ -103,7 +103,7 @@ public class BudgetCategoryController {
@Operation(summary = "用户更新预算分类表", description = "用户更新预算分类表")
@PutMapping("noManage/updateUserBudgetCategory")
public Mono<Result<String>> updateUserBudgetCategory(@Valid @RequestBody BudgetCategoryUpdateUserDto dto) {
public Mono<Result<String>> updateUserBudgetCategory(@Valid @RequestBody BudgetCategoryUpdateByUserDto dto) {
budgetCategoryService.updateUserBudgetCategory(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -2,9 +2,8 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.category.CategoryDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryAddByUserDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.Category;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -81,21 +80,21 @@ public class CategoryController {
@Operation(summary = "用戶分类添加分类信息", description = "用戶分类添加分类信息")
@PostMapping("noManage/addCategoryUser")
public Mono<Result<String>> addCategoryUser(@Valid @RequestBody CategoryUserAddDto dto) {
public Mono<Result<String>> addCategoryUser(@Valid @RequestBody CategoryAddByUserDto dto) {
categoryService.addCategoryUser(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新分类信息", description = "更新分类信息")
@PutMapping("updateCategory")
public Mono<Result<String>> updateCategory(@Valid @RequestBody CategoryUpdateDto dto) {
public Mono<Result<String>> updateCategory(@Valid @RequestBody cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto dto) {
categoryService.updateCategory(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "用户分类更新分类信息", description = "用户分类更新分类信息")
@PutMapping("noManage/updateCategoryUser")
public Mono<Result<String>> updateCategoryUser(@Valid @RequestBody CategoryUserUpdateDto dto) {
public Mono<Result<String>> updateCategoryUser(@Valid @RequestBody CategoryUpdateByUserDto dto) {
categoryService.updateCategoryUser(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -3,8 +3,8 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddByUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -74,7 +74,7 @@ public class DebtRepaymentPlanController {
@Operation(summary = "用户添加债务还款计划表", description = "用户添加债务还款计划表")
@PostMapping("noManage/addUserDebtRepaymentPlan")
public Mono<Result<String>> addUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddUserDto dto) {
public Mono<Result<String>> addUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddByUserDto dto) {
debtRepaymentPlanService.addUserDebtRepaymentPlan(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@ -88,7 +88,7 @@ public class DebtRepaymentPlanController {
@Operation(summary = "用户更新债务还款计划表", description = "用户更新债务还款计划表")
@PutMapping("noManage/updateUserDebtRepaymentPlan")
public Mono<Result<String>> updateUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateUserDto dto) {
public Mono<Result<String>> updateUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateByUserDto dto) {
debtRepaymentPlanService.updateUserDebtRepaymentPlan(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -3,8 +3,8 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddByUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -74,7 +74,7 @@ public class DebtTrackingController {
@Operation(summary = "用户添加债务追踪", description = "用户添加债务追踪")
@PostMapping("noManage/addUserDebtTracking")
public Mono<Result<String>> addUserDebtTracking(@Valid @RequestBody DebtTrackingAddUserDto dto) {
public Mono<Result<String>> addUserDebtTracking(@Valid @RequestBody DebtTrackingAddByUserDto dto) {
debtTrackingService.addUserDebtTracking(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@ -88,7 +88,7 @@ public class DebtTrackingController {
@Operation(summary = "用户更新债务追踪", description = "用户更新债务追踪")
@PutMapping("noManage/updateUserDebtTracking")
public Mono<Result<String>> updateUserDebtTracking(@Valid @RequestBody DebtTrackingUpdateUserDto dto) {
public Mono<Result<String>> updateUserDebtTracking(@Valid @RequestBody DebtTrackingUpdateByUserDto dto) {
debtTrackingService.updateUserDebtTracking(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -3,8 +3,8 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.savingGoal.SavingGoalDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalAddDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalUpdateDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddByUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateByUserDto;
import cn.bunny.dao.entity.financial.SavingGoal;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -74,7 +74,7 @@ public class SavingGoalController {
@Operation(summary = "用户添加储值", description = "用户添加储值")
@PostMapping("noManage/adduserSavingGoal")
public Mono<Result<String>> adduserSavingGoal(@Valid @RequestBody SavingGoalAddUserDto dto) {
public Mono<Result<String>> adduserSavingGoal(@Valid @RequestBody SavingGoalAddByUserDto dto) {
savingGoalService.adduserSavingGoal(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@ -88,7 +88,7 @@ public class SavingGoalController {
@Operation(summary = "用户更新储值", description = "用户更新储值")
@PutMapping("noManage/updateUserSavingGoal")
public Mono<Result<String>> updateUserSavingGoal(@Valid @RequestBody SavingGoalUpdateUserDto dto) {
public Mono<Result<String>> updateUserSavingGoal(@Valid @RequestBody SavingGoalUpdateByUserDto dto) {
savingGoalService.updateUserSavingGoal(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}

View File

@ -1,7 +1,7 @@
package cn.bunny.services.excel;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.dao.dto.financial.bill.excel.BillImportUserDto;
import cn.bunny.dao.dto.financial.bill.excel.BillImportByUserDto;
import cn.bunny.dao.entity.financial.Bill;
import cn.bunny.dao.entity.financial.Category;
import cn.bunny.services.mapper.financial.CategoryMapper;
@ -21,7 +21,7 @@ import java.util.stream.Collectors;
public class BillAddUserDAO {
public void save(List<BillImportUserDto> cachedDataList, BillService billService, CategoryMapper categoryMapper, StrBuilder messageContent, AtomicReference<Integer> index) {
public void save(List<BillImportByUserDto> cachedDataList, BillService billService, CategoryMapper categoryMapper, StrBuilder messageContent, AtomicReference<Integer> index) {
Long userId = BaseContext.getUserId();
// 查询数据
@ -30,13 +30,13 @@ public class BillAddUserDAO {
List<Bill> billList = cachedDataList.stream()
// 判断是否有值
.filter(billImportUserDto -> {
.filter(billImportByUserDto -> {
index.updateAndGet(i -> i == null ? 1 : i + 1);
String billImportUserDtoType = billImportUserDto.getType();
BigDecimal amount = billImportUserDto.getAmount();
LocalDateTime transactionDate = billImportUserDto.getTransactionDate();
String categoryName = billImportUserDto.getCategoryName();
String billImportUserDtoType = billImportByUserDto.getType();
BigDecimal amount = billImportByUserDto.getAmount();
LocalDateTime transactionDate = billImportByUserDto.getTransactionDate();
String categoryName = billImportByUserDto.getCategoryName();
if (StringUtils.isEmpty(billImportUserDtoType)
|| amount == null
|| StringUtils.isEmpty(categoryName)
@ -48,12 +48,12 @@ public class BillAddUserDAO {
}
return true;
})
.map(billImportUserDto -> {
String billImportUserDtoType = billImportUserDto.getType();
String categoryName = billImportUserDto.getCategoryName();
.map(billImportByUserDto -> {
String billImportUserDtoType = billImportByUserDto.getType();
String categoryName = billImportByUserDto.getCategoryName();
Bill bill = new Bill();
BeanUtils.copyProperties(billImportUserDto, bill);
BeanUtils.copyProperties(billImportByUserDto, bill);
// 设置用户id
bill.setUserId(userId);

View File

@ -1,7 +1,7 @@
package cn.bunny.services.excel;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.dao.dto.financial.bill.excel.BillImportUserDto;
import cn.bunny.dao.dto.financial.bill.excel.BillImportByUserDto;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.services.mapper.financial.CategoryMapper;
@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
* 无法被Spring管理必须使用构造函数注入方式
*/
@Slf4j
public class BillAddUserListener implements ReadListener<BillImportUserDto> {
public class BillAddUserListener implements ReadListener<BillImportByUserDto> {
// 缓存数据
private static final int BATCH_COUNT = 100;
@ -41,7 +41,7 @@ public class BillAddUserListener implements ReadListener<BillImportUserDto> {
private final StrBuilder messageContent = new StrBuilder();
// 设置索引查看是第几个数据异常
AtomicReference<Integer> index = new AtomicReference<>(1);
private List<BillImportUserDto> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
private List<BillImportByUserDto> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
public BillAddUserListener(CategoryMapper categoryMapper, MessageMapper messageMapper, MessageReceivedMapper messageReceivedMapper, BillService billService) {
billAddUserDAO = new BillAddUserDAO();
@ -68,7 +68,7 @@ public class BillAddUserListener implements ReadListener<BillImportUserDto> {
* @param data one row value. Is is same as {@link AnalysisContext#readRowHolder()}
*/
@Override
public void invoke(BillImportUserDto data, AnalysisContext context) {
public void invoke(BillImportByUserDto data, AnalysisContext context) {
cachedDataList.add(data);
// 达到BATCH_COUNT了需要去存储一次数据库防止数据几万条数据在内存容易OOM
if (cachedDataList.size() >= BATCH_COUNT) {

View File

@ -1,9 +1,9 @@
package cn.bunny.services.factory;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.dto.financial.bill.excel.BillExportDto;
import cn.bunny.dao.excel.BillUserExportExcel;
import cn.bunny.dao.excel.BillExportExcelByUser;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.user.expendAndIncome.ExpendWithIncome;
import cn.bunny.services.mapper.financial.BillMapper;
@ -42,19 +42,19 @@ public class BillFactory {
String filename = URLEncoder.encode(dateRange, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
// 初始化查询条件将日期向后移一天查询包含当前的数据
ExpendWithIncomeDto expendWithIncomeDto = new ExpendWithIncomeDto();
BeanUtils.copyProperties(dto, expendWithIncomeDto);
expendWithIncomeDto.setEndDate(endDate.plusDays(1));
IncomeExpenseQueryDto incomeExpenseQueryDto = new IncomeExpenseQueryDto();
BeanUtils.copyProperties(dto, incomeExpenseQueryDto);
incomeExpenseQueryDto.setEndDate(endDate.plusDays(1));
// 设置收入和支出的值
AtomicReference<BigDecimal> income = new AtomicReference<>(new BigDecimal(0));
AtomicReference<BigDecimal> expend = new AtomicReference<>(new BigDecimal(0));
// 查询数据
List<ExpendWithIncome> expendWithIncomeList = billMapper.selectListByExpendWithIncomeDto(expendWithIncomeDto);
List<BillUserExportExcel> excelList = expendWithIncomeList.stream().map(expendWithIncome -> {
BillUserExportExcel billUserExportExcel = new BillUserExportExcel();
BeanUtils.copyProperties(expendWithIncome, billUserExportExcel);
List<ExpendWithIncome> expendWithIncomeList = billMapper.selectListByExpendWithIncomeDto(incomeExpenseQueryDto);
List<BillExportExcelByUser> excelList = expendWithIncomeList.stream().map(expendWithIncome -> {
BillExportExcelByUser billExportExcelByUser = new BillExportExcelByUser();
BeanUtils.copyProperties(expendWithIncome, billExportExcelByUser);
// 设置收支类型
String type;
@ -65,14 +65,14 @@ public class BillFactory {
type = "支出";
expend.updateAndGet(bigDecimal -> bigDecimal.add(expendWithIncome.getAmount()));
}
billUserExportExcel.setType(type);
billExportExcelByUser.setType(type);
return billUserExportExcel;
return billExportExcelByUser;
}).toList();
// 查找模板文件
String filenameTemplate = Objects.requireNonNull(getClass().getResource("/static/bill-template.xlsx")).getFile();
if (filenameTemplate == null) throw new BunnyException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
if (filenameTemplate == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(filenameTemplate).build()) {
// 填充数据

View File

@ -1,6 +1,6 @@
package cn.bunny.services.factory;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.common.service.utils.mail.MailSenderUtil;
import cn.bunny.dao.entity.system.EmailTemplate;
import cn.bunny.dao.entity.system.EmailUsers;
@ -33,14 +33,14 @@ public class EmailFactory {
*/
public void sendEmailTemplate(String email, EmailTemplate emailTemplate, HashMap<String, Object> params) {
// 判断邮件模板是否为空
if (emailTemplate == null) throw new BunnyException(ResultCodeEnum.EMAIL_TEMPLATE_IS_EMPTY);
if (emailTemplate == null) throw new AuthCustomerException(ResultCodeEnum.EMAIL_TEMPLATE_IS_EMPTY);
// 查询配置发送邮箱如果没有配置发件者邮箱改用用户列表中默认的如果默认的也为空则报错
Long emailUser = emailTemplate.getEmailUser();
EmailUsers emailUsers;
if (emailUser == null) {
emailUsers = emailUsersMapper.selectOne(Wrappers.<EmailUsers>lambdaQuery().eq(EmailUsers::getIsDefault, true));
if (emailUsers == null) throw new BunnyException(ResultCodeEnum.EMAIL_USER_IS_EMPTY);
if (emailUsers == null) throw new AuthCustomerException(ResultCodeEnum.EMAIL_USER_IS_EMPTY);
} else {
emailUsers = emailUsersMapper.selectOne(Wrappers.<EmailUsers>lambdaQuery().eq(EmailUsers::getId, emailUser));
}
@ -66,7 +66,7 @@ public class EmailFactory {
emailSend.setText(modifiedTemplate[0]);
MailSenderUtil.sendEmail(emailSendInit, emailSend);
} catch (MessagingException e) {
throw new BunnyException(ResultCodeEnum.SEND_MAIL_CODE_ERROR);
throw new AuthCustomerException(ResultCodeEnum.SEND_MAIL_CODE_ERROR);
}
}

View File

@ -1,7 +1,7 @@
package cn.bunny.services.mapper.financial;
import cn.bunny.dao.dto.financial.bill.BillDto;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.entity.financial.Bill;
import cn.bunny.dao.vo.financial.admin.BillVo;
import cn.bunny.dao.vo.financial.user.expendAndIncome.ExpendWithIncome;
@ -46,5 +46,5 @@ public interface BillMapper extends BaseMapper<Bill> {
* @param dto 请求表单
* @return 账单收入和支出
*/
List<ExpendWithIncome> selectListByExpendWithIncomeDto(@Param("dto") ExpendWithIncomeDto dto);
List<ExpendWithIncome> selectListByExpendWithIncomeDto(@Param("dto") IncomeExpenseQueryDto dto);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.security.service.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.user.LoginDto;
import cn.bunny.dao.entity.system.AdminUser;
import cn.bunny.dao.pojo.result.Result;
@ -78,7 +78,7 @@ public class CustomUserDetailsServiceImpl implements cn.bunny.services.security.
// 对登录密码进行md5加密判断是否与数据库中一致
String md5Password = DigestUtils.md5DigestAsHex(password.getBytes());
if (!user.getPassword().equals(md5Password)) throw new BunnyException(ResultCodeEnum.LOGIN_ERROR);
if (!user.getPassword().equals(md5Password)) throw new AuthCustomerException(ResultCodeEnum.LOGIN_ERROR);
return userFactory.buildLoginUserVo(user, readMeDay);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.configuration.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.configuration.WebConfigurationDto;
import cn.bunny.dao.entity.configuration.WebConfiguration;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -26,7 +26,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
private String bashPath;
private static @NotNull String getWebConfigString(InputStream inputStream, Path templatePath) throws IOException {
if (inputStream == null) throw new BunnyException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
if (inputStream == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
// 判断web模板文件是否存在不存在进行复制
boolean exists = Files.exists(templatePath);
@ -80,7 +80,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
String string = getWebConfigString(inputStream, templatePath);
return JSON.parseObject(string, WebConfiguration.class);
} catch (IOException exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
@ -98,7 +98,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
String string = getWebConfigString(inputStream, templatePath);
return JSON.parseObject(string, WebConfigurationVo.class);
} catch (IOException exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.configuration.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.menuIcon.MenuIconAddDto;
import cn.bunny.dao.dto.system.menuIcon.MenuIconDto;
import cn.bunny.dao.dto.system.menuIcon.MenuIconUpdateDto;
@ -105,7 +105,7 @@ public class MenuIconServiceImpl extends ServiceImpl<MenuIconMapper, MenuIcon> i
@CacheEvict(cacheNames = "menuIcon", key = "'menuIconList'", beforeInvocation = true)
public void deleteMenuIcon(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.email.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.email.template.EmailTemplateAddDto;
import cn.bunny.dao.dto.system.email.template.EmailTemplateDto;
import cn.bunny.dao.dto.system.email.template.EmailTemplateUpdateDto;
@ -76,7 +76,7 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
public void updateEmailTemplate(@Valid EmailTemplateUpdateDto dto) {
// 查询是否有这个模板
List<EmailTemplate> emailTemplateList = list(Wrappers.<EmailTemplate>lambdaQuery().eq(EmailTemplate::getId, dto.getId()));
if (emailTemplateList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (emailTemplateList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 更新内容
EmailTemplate emailTemplate = new EmailTemplate();
@ -92,7 +92,7 @@ public class EmailTemplateServiceImpl extends ServiceImpl<EmailTemplateMapper, E
@Override
public void deleteEmailTemplate(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.email.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.email.user.EmailUserUpdateStatusDto;
import cn.bunny.dao.dto.system.email.user.EmailUsersAddDto;
import cn.bunny.dao.dto.system.email.user.EmailUsersDto;
@ -100,7 +100,7 @@ public class EmailUsersServiceImpl extends ServiceImpl<EmailUsersMapper, EmailUs
@Override
public void deleteEmailUsers(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -1,12 +1,12 @@
package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.bill.BillDto;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
import cn.bunny.dao.dto.financial.bill.excel.BillExportDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddByUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateByUserDto;
import cn.bunny.dao.entity.financial.Bill;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.BillVo;
@ -76,14 +76,14 @@ public interface BillService extends IService<Bill> {
*
* @param dto 添加表单
*/
void addUserBill(BillAddUserDto dto);
void addUserBill(BillAddByUserDto dto);
/**
* 用户更新账单信息
*
* @param dto 更新表单
*/
void updateUserBill(BillUpdateUserDto dto);
void updateUserBill(BillUpdateByUserDto dto);
/**
* 账单收入和支出
@ -91,7 +91,7 @@ public interface BillService extends IService<Bill> {
* @param dto 请求表单
* @return 账单收入和支出
*/
ExpendWithIncomeListVo getExpendOrIncome(ExpendWithIncomeDto dto);
ExpendWithIncomeListVo getExpendOrIncome(IncomeExpenseQueryDto dto);
/**
* 导出用户账单

View File

@ -3,8 +3,8 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryAddDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryUpdateDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddByUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.BudgetCategory;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.BudgetCategoryParentVo;
@ -89,12 +89,12 @@ public interface BudgetCategoryService extends IService<BudgetCategory> {
*
* @param dto 添加表单
*/
void addUserBudgetCategory(BudgetCategoryAddUserDto dto);
void addUserBudgetCategory(BudgetCategoryAddByUserDto dto);
/**
* 用户更新预算分类表
*
* @param dto 更新表单
*/
void updateUserBudgetCategory(BudgetCategoryUpdateUserDto dto);
void updateUserBudgetCategory(BudgetCategoryUpdateByUserDto dto);
}

View File

@ -2,9 +2,8 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.category.CategoryDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryAddByUserDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.Category;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.CategoryVo;
@ -58,21 +57,21 @@ public interface CategoryService extends IService<Category> {
*
* @param dto 添加表单
*/
void addCategoryUser(@Valid CategoryUserAddDto dto);
void addCategoryUser(@Valid CategoryAddByUserDto dto);
/**
* * 更新分类信息
*
* @param dto 更新表单
*/
void updateCategory(@Valid CategoryUpdateDto dto);
void updateCategory(@Valid cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto dto);
/**
* * 用户分类更新分类信息
*
* @param dto 更新表单
*/
void updateCategoryUser(@Valid CategoryUserUpdateDto dto);
void updateCategoryUser(@Valid CategoryUpdateByUserDto dto);
/**
* * 用户分类删除分类信息|批量删除分类信息类型

View File

@ -3,8 +3,8 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddByUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo;
@ -67,14 +67,14 @@ public interface DebtRepaymentPlanService extends IService<DebtRepaymentPlan> {
*
* @param dto 添加表单
*/
void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto);
void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddByUserDto dto);
/**
* 用户更新债务还款计划表
*
* @param dto 更新表单
*/
void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto);
void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateByUserDto dto);
/**
* 用户删除债务还款计划表

View File

@ -3,8 +3,8 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddByUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.DebtTrackingVo;
@ -67,14 +67,14 @@ public interface DebtTrackingService extends IService<DebtTracking> {
*
* @param dto 添加表单
*/
void addUserDebtTracking(DebtTrackingAddUserDto dto);
void addUserDebtTracking(DebtTrackingAddByUserDto dto);
/**
* 用户更新债务追踪
*
* @param dto 更新表单
*/
void updateUserDebtTracking(DebtTrackingUpdateUserDto dto);
void updateUserDebtTracking(DebtTrackingUpdateByUserDto dto);
/**
* 用户删除债务追踪

View File

@ -3,8 +3,8 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.savingGoal.SavingGoalDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalAddDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalUpdateDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddByUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateByUserDto;
import cn.bunny.dao.entity.financial.SavingGoal;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.SavingGoalVo;
@ -67,14 +67,14 @@ public interface SavingGoalService extends IService<SavingGoal> {
*
* @param dto 添加表单
*/
void adduserSavingGoal(@Valid SavingGoalAddUserDto dto);
void adduserSavingGoal(@Valid SavingGoalAddByUserDto dto);
/**
* 用户更新储值
*
* @param dto 更新表单
*/
void updateUserSavingGoal(@Valid SavingGoalUpdateUserDto dto);
void updateUserSavingGoal(@Valid SavingGoalUpdateByUserDto dto);
/**
* 用户删除储值

View File

@ -1,15 +1,15 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.bill.BillDto;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.dto.financial.bill.admin.BillAddDto;
import cn.bunny.dao.dto.financial.bill.admin.BillUpdateDto;
import cn.bunny.dao.dto.financial.bill.excel.BillExportDto;
import cn.bunny.dao.dto.financial.bill.excel.BillImportUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateUserDto;
import cn.bunny.dao.dto.financial.bill.excel.BillImportByUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillAddByUserDto;
import cn.bunny.dao.dto.financial.bill.user.BillUpdateByUserDto;
import cn.bunny.dao.entity.financial.Bill;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -162,7 +162,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
* @param dto 添加表单
*/
@Override
public void addUserBill(BillAddUserDto dto) {
public void addUserBill(BillAddByUserDto dto) {
// 保存数据
Bill bill = new Bill();
BeanUtils.copyProperties(dto, bill);
@ -177,7 +177,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
* @param dto 更新表单
*/
@Override
public void updateUserBill(BillUpdateUserDto dto) {
public void updateUserBill(BillUpdateByUserDto dto) {
// 更新内容
Bill bill = new Bill();
BeanUtils.copyProperties(dto, bill);
@ -193,7 +193,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
* @return 账单收入和支出
*/
@Override
public ExpendWithIncomeListVo getExpendOrIncome(ExpendWithIncomeDto dto) {
public ExpendWithIncomeListVo getExpendOrIncome(IncomeExpenseQueryDto dto) {
// 查询时候多加一天就可以查询到最后一个日期到晚上的数据
dto.setEndDate(dto.getEndDate().plusDays(1));
@ -261,9 +261,9 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
@Override
public void importBill(MultipartFile file) {
try {
EasyExcel.read(file.getInputStream(), BillImportUserDto.class, new BillAddUserListener(categoryMapper, messageMapper, messageReceivedMapper, this)).sheet().doRead();
EasyExcel.read(file.getInputStream(), BillImportByUserDto.class, new BillAddUserListener(categoryMapper, messageMapper, messageReceivedMapper, this)).sheet().doRead();
} catch (IOException e) {
throw new BunnyException(ResultCodeEnum.UPDATE_ERROR);
throw new AuthCustomerException(ResultCodeEnum.UPDATE_ERROR);
}
}
@ -278,7 +278,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
List<Bill> billList = list(Wrappers.<Bill>lambdaQuery().in(Bill::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -1,12 +1,12 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.budgetCategory.BudgetCategoryDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryAddDto;
import cn.bunny.dao.dto.financial.budgetCategory.admin.BudgetCategoryUpdateDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryAddByUserDto;
import cn.bunny.dao.dto.financial.budgetCategory.user.BudgetCategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.BudgetCategory;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -148,7 +148,7 @@ public class BudgetCategoryServiceImpl extends ServiceImpl<BudgetCategoryMapper,
List<BudgetCategory> billList = list(Wrappers.<BudgetCategory>lambdaQuery().in(BudgetCategory::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);
@ -175,7 +175,7 @@ public class BudgetCategoryServiceImpl extends ServiceImpl<BudgetCategoryMapper,
* @param dto 添加表单
*/
@Override
public void addUserBudgetCategory(BudgetCategoryAddUserDto dto) {
public void addUserBudgetCategory(BudgetCategoryAddByUserDto dto) {
// 保存数据
BudgetCategory budgetCategory = new BudgetCategory();
BeanUtils.copyProperties(dto, budgetCategory);
@ -190,7 +190,7 @@ public class BudgetCategoryServiceImpl extends ServiceImpl<BudgetCategoryMapper,
* @param dto 更新表单
*/
@Override
public void updateUserBudgetCategory(BudgetCategoryUpdateUserDto dto) {
public void updateUserBudgetCategory(BudgetCategoryUpdateByUserDto dto) {
// 更新内容
BudgetCategory budgetCategory = new BudgetCategory();
BeanUtils.copyProperties(dto, budgetCategory);

View File

@ -1,12 +1,11 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.category.CategoryDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryAddDto;
import cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserAddDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUserUpdateDto;
import cn.bunny.dao.dto.financial.category.user.CategoryAddByUserDto;
import cn.bunny.dao.dto.financial.category.user.CategoryUpdateByUserDto;
import cn.bunny.dao.entity.financial.Category;
import cn.bunny.dao.pojo.constant.UserConstant;
import cn.bunny.dao.pojo.result.PageResult;
@ -131,10 +130,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
* @param dto 分类信息添加
*/
@Override
public void addCategoryUser(@Valid CategoryUserAddDto dto) {
public void addCategoryUser(@Valid CategoryAddByUserDto dto) {
// 查询当前用户添加了多少条
if (count(Wrappers.<Category>lambdaQuery().eq(Category::getIsBuiltin, false)) >= UserConstant.CATEGORY_COUNT) {
throw new BunnyException(ResultCodeEnum.THE_MAXIMUM_BAR_CODE);
throw new AuthCustomerException(ResultCodeEnum.THE_MAXIMUM_BAR_CODE);
}
// 保存数据
@ -152,7 +151,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
* @param dto 分类信息更新
*/
@Override
public void updateCategory(@Valid CategoryUpdateDto dto) {
public void updateCategory(@Valid cn.bunny.dao.dto.financial.category.admin.CategoryUpdateDto dto) {
// 更新内容
Category category = new Category();
BeanUtils.copyProperties(dto, category);
@ -165,7 +164,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
* @param dto 分类信息更新
*/
@Override
public void updateCategoryUser(@Valid CategoryUserUpdateDto dto) {
public void updateCategoryUser(@Valid CategoryUpdateByUserDto dto) {
Long userId = BaseContext.getUserId();
// 判断用户修改的当前内容是否和系统内置的信息一致
@ -173,7 +172,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
Long categoryUserId = category.getUserId();
if (!categoryUserId.equals(userId)) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
// 更新内容

View File

@ -1,12 +1,12 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddByUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -122,7 +122,7 @@ public class DebtRepaymentPlanServiceImpl extends ServiceImpl<DebtRepaymentPlanM
* @param dto 添加表单
*/
@Override
public void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto) {
public void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddByUserDto dto) {
// 保存数据
DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan();
BeanUtils.copyProperties(dto, debtRepaymentPlan);
@ -137,7 +137,7 @@ public class DebtRepaymentPlanServiceImpl extends ServiceImpl<DebtRepaymentPlanM
* @param dto 更新表单
*/
@Override
public void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto) {
public void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateByUserDto dto) {
// 更新内容
DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan();
BeanUtils.copyProperties(dto, debtRepaymentPlan);
@ -157,7 +157,7 @@ public class DebtRepaymentPlanServiceImpl extends ServiceImpl<DebtRepaymentPlanM
List<DebtRepaymentPlan> billList = list(Wrappers.<DebtRepaymentPlan>lambdaQuery().in(DebtRepaymentPlan::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,12 +1,12 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.debtTracking.DebtTrackingDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingAddDto;
import cn.bunny.dao.dto.financial.debtTracking.admin.DebtTrackingUpdateDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingAddByUserDto;
import cn.bunny.dao.dto.financial.debtTracking.user.DebtTrackingUpdateByUserDto;
import cn.bunny.dao.entity.financial.DebtTracking;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -123,7 +123,7 @@ public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, Deb
* @param dto 添加表单
*/
@Override
public void addUserDebtTracking(DebtTrackingAddUserDto dto) {
public void addUserDebtTracking(DebtTrackingAddByUserDto dto) {
// 保存数据
DebtTracking debtTracking = new DebtTracking();
BeanUtils.copyProperties(dto, debtTracking);
@ -138,7 +138,7 @@ public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, Deb
* @param dto 更新表单
*/
@Override
public void updateUserDebtTracking(DebtTrackingUpdateUserDto dto) {
public void updateUserDebtTracking(DebtTrackingUpdateByUserDto dto) {
// 更新内容
DebtTracking debtTracking = new DebtTracking();
BeanUtils.copyProperties(dto, debtTracking);
@ -158,7 +158,7 @@ public class DebtTrackingServiceImpl extends ServiceImpl<DebtTrackingMapper, Deb
List<DebtTracking> billList = list(Wrappers.<DebtTracking>lambdaQuery().in(DebtTracking::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,12 +1,12 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.savingGoal.SavingGoalDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalAddDto;
import cn.bunny.dao.dto.financial.savingGoal.admin.SavingGoalUpdateDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddByUserDto;
import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalUpdateByUserDto;
import cn.bunny.dao.entity.financial.SavingGoal;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -133,7 +133,7 @@ public class SavingGoalServiceImpl extends ServiceImpl<SavingGoalMapper, SavingG
* @param dto 添加表单
*/
@Override
public void adduserSavingGoal(@Valid SavingGoalAddUserDto dto) {
public void adduserSavingGoal(@Valid SavingGoalAddByUserDto dto) {
// 保存数据
SavingGoal savingGoal = new SavingGoal();
BeanUtils.copyProperties(dto, savingGoal);
@ -148,7 +148,7 @@ public class SavingGoalServiceImpl extends ServiceImpl<SavingGoalMapper, SavingG
* @param dto 更新表单
*/
@Override
public void updateUserSavingGoal(@Valid SavingGoalUpdateUserDto dto) {
public void updateUserSavingGoal(@Valid SavingGoalUpdateByUserDto dto) {
// 更新内容
SavingGoal savingGoal = new SavingGoal();
BeanUtils.copyProperties(dto, savingGoal);
@ -168,7 +168,7 @@ public class SavingGoalServiceImpl extends ServiceImpl<SavingGoalMapper, SavingG
List<SavingGoal> billList = list(Wrappers.<SavingGoal>lambdaQuery().in(SavingGoal::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.i18n.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.i18n.I18nAddDto;
import cn.bunny.dao.dto.i18n.I18nDto;
import cn.bunny.dao.dto.i18n.I18nUpdateDto;
@ -99,7 +99,7 @@ public class I18nServiceImpl extends ServiceImpl<I18nMapper, I18n> implements I1
// 查询数据是否存在
List<I18n> i18nList = list(Wrappers.<I18n>lambdaQuery().eq(I18n::getKeyName, keyName).eq(I18n::getTypeName, typeName));
if (!i18nList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
if (!i18nList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_EXIST);
// 保存内容
I18n i18n = new I18n();
@ -119,7 +119,7 @@ public class I18nServiceImpl extends ServiceImpl<I18nMapper, I18n> implements I1
// 查询数据是否存在
List<I18n> i18nList = list(Wrappers.<I18n>lambdaQuery().eq(I18n::getId, id));
if (i18nList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (i18nList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 保存内容
I18n i18n = new I18n();
@ -136,7 +136,7 @@ public class I18nServiceImpl extends ServiceImpl<I18nMapper, I18n> implements I1
@CacheEvict(cacheNames = "i18n", key = "'i18n'", beforeInvocation = true)
public void deleteI18n(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.i18n.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.i18n.I18nTypeAddDto;
import cn.bunny.dao.dto.i18n.I18nTypeDto;
import cn.bunny.dao.dto.i18n.I18nTypeUpdateDto;
@ -61,7 +61,7 @@ public class I18nTypeServiceImpl extends ServiceImpl<I18nTypeMapper, I18nType> i
// 查询添加的数据是否之前添加过
List<I18nType> i18nTypeList = list(Wrappers.<I18nType>lambdaQuery().eq(I18nType::getTypeName, typeName));
if (!i18nTypeList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
if (!i18nTypeList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_EXIST);
// 如果是默认将其它内容设为false
if (isDefault) {
@ -89,7 +89,7 @@ public class I18nTypeServiceImpl extends ServiceImpl<I18nTypeMapper, I18nType> i
// 查询更新的内容是否存在
List<I18nType> i18nTypeList = list(Wrappers.<I18nType>lambdaQuery().eq(I18nType::getId, id));
if (i18nTypeList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (i18nTypeList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 如果是默认将其它内容设为false
if (isDefault) {
@ -112,7 +112,7 @@ public class I18nTypeServiceImpl extends ServiceImpl<I18nTypeMapper, I18nType> i
@CacheEvict(cacheNames = "i18n", key = "'i18nType'", beforeInvocation = true)
public void deleteI18nType(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
baseMapper.deleteBatchIdsWithPhysics(ids);
}

View File

@ -2,7 +2,7 @@ package cn.bunny.services.service.index.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.dao.dto.financial.HomeDto;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.vo.financial.user.expendAndIncome.ExpendWithIncome;
import cn.bunny.dao.vo.financial.user.home.CountTop;
import cn.bunny.dao.vo.financial.user.home.HomeVo;
@ -37,13 +37,13 @@ public class IndexServiceImpl implements IndexService {
LocalDateTime endDate = dto.getEndDate().atStartOfDay();
// 设置查询dto
ExpendWithIncomeDto expendWithIncomeDto = new ExpendWithIncomeDto();
expendWithIncomeDto.setUserId(BaseContext.getUserId());
expendWithIncomeDto.setStartDate(startDate.toLocalDate());
expendWithIncomeDto.setEndDate(endDate.toLocalDate().plusDays(1));// 查询时候多加一天就可以查询到最后一个日期到晚上的数据
IncomeExpenseQueryDto incomeExpenseQueryDto = new IncomeExpenseQueryDto();
incomeExpenseQueryDto.setUserId(BaseContext.getUserId());
incomeExpenseQueryDto.setStartDate(startDate.toLocalDate());
incomeExpenseQueryDto.setEndDate(endDate.toLocalDate().plusDays(1));// 查询时候多加一天就可以查询到最后一个日期到晚上的数据
// 查询收入和支出
List<ExpendWithIncome> homeRanks = billMapper.selectListByExpendWithIncomeDto(expendWithIncomeDto);
List<ExpendWithIncome> homeRanks = billMapper.selectListByExpendWithIncomeDto(incomeExpenseQueryDto);
// 主页卡片数据
Map<String, CountTop> homeCard = homeFactory.homeCard(homeRanks);

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.message.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.message.MessageReceivedDto;
import cn.bunny.dao.dto.system.message.MessageReceivedUpdateDto;
import cn.bunny.dao.dto.system.message.MessageUserDto;
@ -133,7 +133,7 @@ public class MessageReceivedServiceImpl extends ServiceImpl<MessageReceivedMappe
public void userMarkAsRead(List<Long> ids) {
// 判断ids是否为空
if (ids.isEmpty()) {
throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
}
// 更新表中消息状态
@ -156,14 +156,14 @@ public class MessageReceivedServiceImpl extends ServiceImpl<MessageReceivedMappe
public void deleteUserMessageByIds(List<Long> ids) {
// 判断ids是否为空
if (ids.isEmpty()) {
throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
}
// 判断删除的是否是自己的消息
List<MessageReceived> messageReceivedList = list(Wrappers.<MessageReceived>lambdaQuery().in(MessageReceived::getReceivedUserId, ids));
messageReceivedList.forEach(messageReceived -> {
if (!messageReceived.getReceivedUserId().equals(BaseContext.getUserId())) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
});

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.message.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.common.entity.BaseEntity;
import cn.bunny.dao.dto.system.message.MessageAddDto;
import cn.bunny.dao.dto.system.message.MessageDto;
@ -131,7 +131,7 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
@Override
public List<MessageReceivedWithUserVo> getReceivedUserinfoByMessageId(Long messageId) {
if (messageId == null) {
throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
}
return baseMapper.selectUserinfoListByMessageId(messageId);
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.schedule.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.quartz.SchedulersOperationDto;
import cn.bunny.dao.dto.quartz.schedule.SchedulersAddDto;
import cn.bunny.dao.dto.quartz.schedule.SchedulersDto;
@ -134,7 +134,7 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
scheduler.scheduleJob(jobDetail, trigger);
} catch (Exception exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
@ -149,7 +149,7 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
JobKey key = new JobKey(dto.getJobName(), dto.getJobGroup());
scheduler.pauseJob(key);
} catch (SchedulerException exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
@ -164,7 +164,7 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
JobKey key = new JobKey(dto.getJobName(), dto.getJobGroup());
scheduler.resumeJob(key);
} catch (SchedulerException exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
@ -184,7 +184,7 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
scheduler.unscheduleJob(triggerKey);
scheduler.deleteJob(JobKey.jobKey(jobName, jobGroup));
} catch (SchedulerException exception) {
throw new BunnyException(exception.getMessage());
throw new AuthCustomerException(exception.getMessage());
}
}
}

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.dept.DeptAddDto;
import cn.bunny.dao.dto.system.dept.DeptDto;
import cn.bunny.dao.dto.system.dept.DeptUpdateDto;
@ -100,7 +100,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
@Override
@CacheEvict(cacheNames = "dept", key = "'allDept'", beforeInvocation = true)
public void updateDept(DeptUpdateDto dto) {
if (dto.getId().equals(dto.getParentId())) throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
if (dto.getId().equals(dto.getParentId())) throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
// 将管理员用户逗号分隔
String mangerList = dto.getManager().stream().map(String::trim).collect(Collectors.joining(","));
@ -122,7 +122,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
@CacheEvict(cacheNames = "dept", key = "'allDept'", beforeInvocation = true)
public void deleteDept(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 删除当前部门
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.common.service.utils.FileUtil;
import cn.bunny.common.service.utils.minio.MinioProperties;
import cn.bunny.common.service.utils.minio.MinioUtil;
@ -112,7 +112,7 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
files.setDownloadCount(dto.getDownloadCount());
return files;
} catch (IOException e) {
throw new BunnyException(e.getMessage());
throw new AuthCustomerException(e.getMessage());
}
}).toList();
@ -175,7 +175,7 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
// 盘读研数据是否过大
String mb = maxFileSize.replace("MB", "");
if (fileSize / 1024 / 1024 > Long.parseLong(mb)) throw new BunnyException(ResultCodeEnum.DATA_TOO_LARGE);
if (fileSize / 1024 / 1024 > Long.parseLong(mb)) throw new AuthCustomerException(ResultCodeEnum.DATA_TOO_LARGE);
// 插入文件信息
Files adminFiles = new Files();
@ -204,7 +204,7 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
*/
@Override
public void deleteFiles(List<Long> ids) {
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 查询文件路径
List<String> list = list(Wrappers.<Files>lambdaQuery().in(Files::getId, ids)).stream()
@ -233,7 +233,7 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
Files files = getOne(Wrappers.<Files>lambdaQuery().eq(Files::getId, fileId));
// 判断文件是否存在
if (files == null) throw new BunnyException(ResultCodeEnum.FILE_NOT_EXIST);
if (files == null) throw new AuthCustomerException(ResultCodeEnum.FILE_NOT_EXIST);
// 从Minio获取文件
String filepath = files.getFilepath();
@ -313,7 +313,7 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
List<Category> categoryList = categoryMapper.selectList(queryWrapper);
String filenameTemplate = Objects.requireNonNull(getClass().getResource("/static/bill-add-template.xlsx")).getFile();
if (filenameTemplate == null) throw new BunnyException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
if (filenameTemplate == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(filenameTemplate).build()) {
// 填充数据类型数据要填充的在第二个sheet

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.rolePower.power.PowerAddDto;
import cn.bunny.dao.dto.system.rolePower.power.PowerDto;
import cn.bunny.dao.dto.system.rolePower.power.PowerUpdateBatchByParentIdDto;
@ -91,7 +91,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
.or()
.eq(Power::getRequestUrl, dto.getRequestUrl());
List<Power> powerList = list(wrapper);
if (!powerList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_EXIST);
if (!powerList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_EXIST);
// 保存数据
Power power = new Power();
@ -109,8 +109,8 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
public void updatePower(@Valid PowerUpdateDto dto) {
Long id = dto.getId();
List<Power> powerList = list(Wrappers.<Power>lambdaQuery().eq(Power::getId, id));
if (powerList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (dto.getId().equals(dto.getParentId())) throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
if (powerList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
if (dto.getId().equals(dto.getParentId())) throw new AuthCustomerException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
// 更新内容
Power power = new Power();
@ -127,7 +127,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
public void deletePower(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 删除权限
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.rolePower.role.RoleAddDto;
import cn.bunny.dao.dto.system.rolePower.role.RoleDto;
import cn.bunny.dao.dto.system.rolePower.role.RoleUpdateDto;
@ -108,7 +108,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
public void updateRole(@Valid RoleUpdateDto dto) {
// 查询更新的角色是否存在
List<Role> roleList = list(Wrappers.<Role>lambdaQuery().eq(Role::getId, dto.getId()));
if (roleList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (roleList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 更新内容
Role role = new Role();
@ -131,7 +131,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
public void deleteRole(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 删除角色
baseMapper.deleteBatchIdsWithPhysics(ids);

View File

@ -1,6 +1,6 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.router.AssignRolesToRoutersDto;
import cn.bunny.dao.entity.system.RouterRole;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
@ -76,7 +76,7 @@ public class RouterRoleServiceImpl extends ServiceImpl<RouterRoleMapper, RouterR
@Override
public void clearAllRolesSelect(List<Long> routerIds) {
if (routerIds.isEmpty()) {
throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
}
baseMapper.deleteBatchIdsByRouterIdsWithPhysics(routerIds);
}

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.router.RouterAddDto;
import cn.bunny.dao.dto.system.router.RouterManageDto;
import cn.bunny.dao.dto.system.router.RouterUpdateByIdWithRankDto;
@ -222,7 +222,7 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
// 设置路由等级需要大于或等于父级的路由等级
if (routerParent != null && (dto.getRouterRank() < routerParent.getRouterRank())) {
throw new BunnyException(ResultCodeEnum.ROUTER_RANK_NEED_LARGER_THAN_THE_PARENT);
throw new AuthCustomerException(ResultCodeEnum.ROUTER_RANK_NEED_LARGER_THAN_THE_PARENT);
}
// 如果设置的不是外部页面
@ -241,7 +241,7 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
@Override
public void deletedMenuByIds(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 查找子级菜单一起删除
List<Long> longList = list(Wrappers.<Router>lambdaQuery().in(Router::getParentId, ids)).stream().map(Router::getId).toList();
@ -264,14 +264,14 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
Router router = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getId, dto.getId()));
// 判断更新数据是否存在
if (router == null) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (router == null) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 查询当前路由和父级路由
Router routerParent = getOne(Wrappers.<Router>lambdaQuery().eq(Router::getId, router.getParentId()));
// 设置路由等级需要大于或等于父级的路由等级
if (routerParent != null && (dto.getRouterRank() < routerParent.getRouterRank())) {
throw new BunnyException(ResultCodeEnum.ROUTER_RANK_NEED_LARGER_THAN_THE_PARENT);
throw new AuthCustomerException(ResultCodeEnum.ROUTER_RANK_NEED_LARGER_THAN_THE_PARENT);
}
// 更新排序

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.system.user.AssignRolesToUsersDto;
import cn.bunny.dao.entity.system.AdminUser;
import cn.bunny.dao.entity.system.UserRole;
@ -54,7 +54,7 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
*/
@Override
public List<String> getRoleListByUserId(Long userId) {
if (userId == null) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (userId == null) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
List<UserRole> userRoles = userRoleMapper.selectList(Wrappers.<UserRole>lambdaQuery().eq(UserRole::getUserId, userId));
return userRoles.stream().map(userRole -> userRole.getRoleId().toString()).toList();
@ -73,7 +73,7 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
// 查询当前用户
AdminUser adminUser = userMapper.selectOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
if (adminUser == null) {
throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
}
// 删除这个用户下所有已经分配好的角色内容

View File

@ -1,7 +1,7 @@
package cn.bunny.services.service.system.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.common.service.utils.JwtHelper;
import cn.bunny.common.service.utils.ip.IpUtil;
import cn.bunny.dao.dto.system.files.FileUploadDto;
@ -130,8 +130,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
Long userId = JwtHelper.getUserId(dto.getRefreshToken());
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
if (adminUser == null) throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
if (adminUser.getStatus()) throw new BunnyException(ResultCodeEnum.FAIL_NO_ACCESS_DENIED_USER_LOCKED);
if (adminUser == null) throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
if (adminUser.getStatus()) throw new AuthCustomerException(ResultCodeEnum.FAIL_NO_ACCESS_DENIED_USER_LOCKED);
LoginVo buildUserVo = userFactory.buildLoginUserVo(adminUser, dto.getReadMeDay());
RefreshTokenVo refreshTokenVo = new RefreshTokenVo();
@ -172,11 +172,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
@Override
public UserVo getUserinfoById(Long id) {
// 判断请求Id是否为空
if (id == null) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (id == null) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
AdminUser user = getById(id);
// 用户是否存在
if (user == null) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (user == null) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 用户头像
String avatar = user.getAvatar();
@ -202,11 +202,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
// 判断是否存在这个用户
if (adminUser == null) throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
if (adminUser == null) throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
// 判断新密码是否与旧密码相同
if (adminUser.getPassword().equals(md5Password))
throw new BunnyException(ResultCodeEnum.UPDATE_NEW_PASSWORD_SAME_AS_OLD_PASSWORD);
throw new AuthCustomerException(ResultCodeEnum.UPDATE_NEW_PASSWORD_SAME_AS_OLD_PASSWORD);
// 更新用户密码
adminUser = new AdminUser();
@ -231,7 +231,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
// 判断是否存在这个用户
AdminUser user = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
if (user == null) throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
if (user == null) throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
// 上传头像
FileUploadDto uploadDto = FileUploadDto.builder().file(avatar).type(MinioConstant.avatar).build();
@ -255,7 +255,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
*/
@Override
public void forcedOffline(Long id) {
if (id == null) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (id == null) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 根据id查询用户登录前缀
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, id));
@ -341,7 +341,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
// 判断是否存在这个用户
AdminUser user = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
if (user == null) throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
if (user == null) throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
// 检查用户头像
dto.setAvatar(userFactory.checkPostUserAvatar(dto.getAvatar()));
@ -369,14 +369,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
// 判断用户是否存在
if (adminUser == null) throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
if (adminUser == null) throw new AuthCustomerException(ResultCodeEnum.USER_IS_EMPTY);
// 数据库中的密码
String dbPassword = adminUser.getPassword();
password = DigestUtils.md5DigestAsHex(password.getBytes());
// 判断数据库中密码是否和更新用户密码相同
if (dbPassword.equals(password)) throw new BunnyException(ResultCodeEnum.NEW_PASSWORD_SAME_OLD_PASSWORD);
if (dbPassword.equals(password)) throw new AuthCustomerException(ResultCodeEnum.NEW_PASSWORD_SAME_OLD_PASSWORD);
// 更新用户密码
adminUser = new AdminUser();
@ -463,7 +463,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
// 判断更新内容是否存在
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
if (adminUser == null) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
if (adminUser == null) throw new AuthCustomerException(ResultCodeEnum.DATA_NOT_EXIST);
// 如果更新了用户名删除之前的用户数据
if (!dto.getUsername().equals(adminUser.getUsername())) {
@ -500,12 +500,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
@Override
public void deleteAdminUser(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
if (ids.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.REQUEST_IS_EMPTY);
// 根据用户Id列表查询用户角色
List<Role> list = roleMapper.selectListByUserIds(ids);
List<Role> roleList = list.stream().filter(role -> role.getRoleCode().equals("admin") || ids.contains(1L)).toList();
if (!roleList.isEmpty()) throw new BunnyException(ResultCodeEnum.ADMIN_ROLE_CAN_NOT_DELETED);
if (!roleList.isEmpty()) throw new AuthCustomerException(ResultCodeEnum.ADMIN_ROLE_CAN_NOT_DELETED);
// 逻辑删除
removeBatchByIds(ids);

View File

@ -1,11 +1,11 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.financial.bill.ExpendWithIncomeDto;
import cn.bunny.common.service.exception.AuthCustomerException;
import cn.bunny.dao.dto.financial.bill.IncomeExpenseQueryDto;
import cn.bunny.dao.entity.financial.Category;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.dao.excel.BillUserExportExcel;
import cn.bunny.dao.excel.BillExportExcelByUser;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.user.expendAndIncome.ExpendWithIncome;
import cn.bunny.services.mapper.financial.BillMapper;
@ -40,23 +40,23 @@ class BillServiceImplTest {
@Test
void exportBill() {
// 设置数据库查询时间
ExpendWithIncomeDto expendWithIncomeDto = new ExpendWithIncomeDto();
expendWithIncomeDto.setUserId(1849444494908125181L);
expendWithIncomeDto.setStartDate(LocalDate.of(2024, 11, 1));
expendWithIncomeDto.setEndDate(LocalDate.of(2024, 11, 30));
IncomeExpenseQueryDto incomeExpenseQueryDto = new IncomeExpenseQueryDto();
incomeExpenseQueryDto.setUserId(1849444494908125181L);
incomeExpenseQueryDto.setStartDate(LocalDate.of(2024, 11, 1));
incomeExpenseQueryDto.setEndDate(LocalDate.of(2024, 11, 30));
// 设置日期范围
String dateRange = expendWithIncomeDto.getStartDate() + "~" + expendWithIncomeDto.getEndDate();
String dateRange = incomeExpenseQueryDto.getStartDate() + "~" + incomeExpenseQueryDto.getEndDate();
// 设置收入和支出的值
AtomicReference<BigDecimal> income = new AtomicReference<>(new BigDecimal(0));
AtomicReference<BigDecimal> expend = new AtomicReference<>(new BigDecimal(0));
// 查询数据
List<ExpendWithIncome> expendWithIncomeList = billMapper.selectListByExpendWithIncomeDto(expendWithIncomeDto);
List<BillUserExportExcel> excelList = expendWithIncomeList.stream().map(expendWithIncome -> {
BillUserExportExcel billUserExportExcel = new BillUserExportExcel();
BeanUtils.copyProperties(expendWithIncome, billUserExportExcel);
List<ExpendWithIncome> expendWithIncomeList = billMapper.selectListByExpendWithIncomeDto(incomeExpenseQueryDto);
List<BillExportExcelByUser> excelList = expendWithIncomeList.stream().map(expendWithIncome -> {
BillExportExcelByUser billExportExcelByUser = new BillExportExcelByUser();
BeanUtils.copyProperties(expendWithIncome, billExportExcelByUser);
// 设置收支类型
String type;
@ -67,13 +67,13 @@ class BillServiceImplTest {
type = "支出";
expend.updateAndGet(bigDecimal -> bigDecimal.add(expendWithIncome.getAmount()));
}
billUserExportExcel.setType(type);
billExportExcelByUser.setType(type);
return billUserExportExcel;
return billExportExcelByUser;
}).toList();
String filenameTemplate = Objects.requireNonNull(getClass().getResource("/static/bill-template.xlsx")).getFile();
if (filenameTemplate == null) throw new BunnyException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
if (filenameTemplate == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
try (ExcelWriter excelWriter = EasyExcel.write("F:\\数据库备份\\" + dateRange + ".xlsx").withTemplate(filenameTemplate).build()) {
// 填充数据
@ -101,7 +101,7 @@ class BillServiceImplTest {
List<Category> categoryList = categoryMapper.selectList(Wrappers.<Category>lambdaQuery().eq(Category::getUserId, userId));
String filenameTemplate = Objects.requireNonNull(getClass().getResource("/static/bill-add-template.xlsx")).getFile();
if (filenameTemplate == null) throw new BunnyException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
if (filenameTemplate == null) throw new AuthCustomerException(ResultCodeEnum.MISSING_TEMPLATE_FILES);
try (ExcelWriter excelWriter = EasyExcel.write("F:\\数据库备份\\bill-add-template.xlsx").withTemplate(filenameTemplate).build()) {
// 填充数据