master
WeiRan 2024-08-08 09:03:57 +08:00
commit 07b8c33561
8 changed files with 223 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package com.bwie.student;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorweiran
* @Packagecom.bwie.student
* @Projectweek3
* @nameStudent
* @Date2024/8/8 8:37
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Student {
private Integer id;
private String name;
private String subject;
private Double score;
}

View File

@ -0,0 +1,31 @@
package com.bwie.student.controller;
import com.bwie.common.result.Result;
import com.bwie.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Authorweiran
* @Packagecom.bwie.student.controller
* @Projectweek3
* @nameStudentController
* @Date2024/8/8 8:39
*/
@RestController
@RequestMapping("/student")
public class StudentController {
@Autowired
private StudentService studentService;
/**
*
*/
public Result out(){
return Result.success(studentService.out());
}
}

View File

@ -0,0 +1,14 @@
package com.bwie.student.mapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @Authorweiran
* @Packagecom.bwie.student.mapper
* @Projectweek3
* @nameStudentMapper
* @Date2024/8/8 8:36
*/
@Mapper
public interface StudentMapper {
}

View File

@ -0,0 +1,16 @@
package com.bwie.student.service;
import com.bwie.student.Student;
import java.util.List;
/**
* @Authorweiran
* @Packagecom.bwie.student.service
* @Projectweek3
* @nameStudentService
* @Date2024/8/8 8:39
*/
public interface StudentService {
List<Student> out();
}

View File

@ -0,0 +1,50 @@
package com.bwie.student.service.impl;
import com.bwie.student.Student;
import com.bwie.student.service.StudentService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* @Authorweiran
* @Packagecom.bwie.student.service.impl
* @Projectweek3
* @nameStudentServiceImpl
* @Date2024/8/8 8:39
*/
@Service
public class StudentServiceImpl implements StudentService {
@Override
public List<Student> out() {
return null;
}
public static void main(String[] args) {
//创建5名学生(Student)对像,并放入集合中
ArrayList<Student> students = new ArrayList<>();
Student student1 = new Student(0, "张三", "语文", 78.0);
Student student2 = new Student(0, "李四", "语文", 88.0);
Student student3 = new Student(0, "王五", "语文", 79.0);
Student student4 = new Student(0, "赵六", "语文", 83.0);
Student student5 = new Student(0, "田七", "语文", 87.0);
students.add(student1);
students.add(student2);
students.add(student3);
students.add(student4);
students.add(student5);
Double avg=null;
for (Student student : students) {
avg+=student.getScore();
System.out.println("姓名为:"+student.getName()+"\n");
}
System.out.println("平均值为:"+(avg/5));
}
}

View File

@ -0,0 +1,55 @@
package com.bwie.student.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 "删除成功";
}
}

View File

@ -0,0 +1,29 @@
# 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-user
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 122.51.12.81:8848
config:
# 配置中心地址
server-addr: 122.51.12.81:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -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.student.mapper.StudentMapper">
</mapper>