日考18
commit
deedeb79bc
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.bwie</groupId>
|
||||||
|
<artifactId>bwie-modules</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>bwie-jisuan</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 系统公共 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bwie</groupId>
|
||||||
|
<artifactId>bwie-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringBoot Web-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Druid -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.8</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mybatis 依赖配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Pagehelper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tobato</groupId>
|
||||||
|
<artifactId>fastdfs-client</artifactId>
|
||||||
|
<version>1.26.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.bwie.jisuan;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.bwie.jisuan
|
||||||
|
* @Project:day13
|
||||||
|
* @name:JiSuanApplication
|
||||||
|
* @Date:2024/8/7 8:43
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class JiSuanApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(JiSuanApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.bwie.jisuan.controller;
|
||||||
|
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.jisuan.service.JiSuanService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.bwie.jisuan.controller
|
||||||
|
* @Project:day13
|
||||||
|
* @name:JiSuanCController
|
||||||
|
* @Date:2024/8/7 8:38
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/jisuan")
|
||||||
|
public class JiSuanCController {
|
||||||
|
@Autowired
|
||||||
|
private JiSuanService jiSuanService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加法
|
||||||
|
*/
|
||||||
|
@PostMapping("/add")
|
||||||
|
public Result add(){
|
||||||
|
return jiSuanService.add();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 减法
|
||||||
|
*/
|
||||||
|
@PostMapping("/subtract")
|
||||||
|
public Result subtract(){
|
||||||
|
return jiSuanService.subtract();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乘法
|
||||||
|
*/
|
||||||
|
@PostMapping("/multiply")
|
||||||
|
public Result multiply(){
|
||||||
|
return jiSuanService.multiply();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 除法
|
||||||
|
*/
|
||||||
|
@PostMapping("/divide")
|
||||||
|
public Result divide(){
|
||||||
|
return jiSuanService.divide();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bwie.jisuan.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.bwie.jisuan.mapper
|
||||||
|
* @Project:day13
|
||||||
|
* @name:JiSuanMapper
|
||||||
|
* @Date:2024/8/7 8:38
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface JiSuanMapper {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.bwie.jisuan.service;
|
||||||
|
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.bwie.jisuan.service
|
||||||
|
* @Project:day13
|
||||||
|
* @name:JiSuanService
|
||||||
|
* @Date:2024/8/7 8:39
|
||||||
|
*/
|
||||||
|
public interface JiSuanService {
|
||||||
|
Result add();
|
||||||
|
|
||||||
|
Result subtract();
|
||||||
|
|
||||||
|
Result multiply();
|
||||||
|
|
||||||
|
Result divide();
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.bwie.jisuan.service.impl;
|
||||||
|
|
||||||
|
import com.bwie.common.result.Result;
|
||||||
|
import com.bwie.jisuan.service.JiSuanService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:weiran
|
||||||
|
* @Package:com.bwie.jisuan.service.impl
|
||||||
|
* @Project:day13
|
||||||
|
* @name:JiSuanServiceImpl
|
||||||
|
* @Date:2024/8/7 8:39
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class JiSuanServiceImpl implements JiSuanService {
|
||||||
|
|
||||||
|
private static BigDecimal num1= BigDecimal.valueOf(10);
|
||||||
|
private static BigDecimal num2= BigDecimal.valueOf(5);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result add() {
|
||||||
|
BigDecimal num3= num1.add(num2);
|
||||||
|
return Result.success(num3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result subtract() {
|
||||||
|
BigDecimal num3= num1.subtract(num2);
|
||||||
|
return Result.success(num3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result multiply() {
|
||||||
|
BigDecimal num3= num1.multiply(num2);
|
||||||
|
return Result.success(num3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result divide() {
|
||||||
|
BigDecimal num3= num1.divide(num2,2);
|
||||||
|
return Result.success(num3);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.bwie.jisuan.utils;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: 0107day02
|
||||||
|
* @BelongsPackage: com.bw.config
|
||||||
|
* @Author: zhupengfei
|
||||||
|
* @CreateTime: 2023-02-01 08:52
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FastUtil {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FastFileStorageClient storageClient ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
public String upload(MultipartFile multipartFile) throws Exception{
|
||||||
|
String originalFilename = multipartFile.getOriginalFilename().
|
||||||
|
substring(multipartFile.getOriginalFilename().
|
||||||
|
lastIndexOf(".") + 1);
|
||||||
|
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||||
|
multipartFile.getInputStream(),
|
||||||
|
multipartFile.getSize(),originalFilename , null);
|
||||||
|
return storePath.getFullPath() ;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*/
|
||||||
|
public String deleteFile(String fileUrl) {
|
||||||
|
if (StringUtils.isEmpty(fileUrl)) {
|
||||||
|
log.info("fileUrl == >>文件路径为空...");
|
||||||
|
return "文件路径不能为空";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||||
|
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return "删除成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9003
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: bwie-jisuan
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 122.51.12.81:8848
|
||||||
|
namespace: nacos
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 122.51.12.81:8848
|
||||||
|
namespace: nacos
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.bwie.user.mapper.XXXMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue