feat: oss
This commit is contained in:
37
sms-auth/sms-auth-controller/pom.xml
Normal file
37
sms-auth/sms-auth-controller/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>sms-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>sms-auth-controller</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>sms-auth-controller</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>sms-auth-domain</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>sms-auth-infra</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname GlobalConfig
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.subject.application.config
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-16 15:57
|
||||
* @Description: MVC全局处理
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class GlobalConfig extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
super.configureMessageConverters(converters);
|
||||
converters.add(mappingJackson2HttpMessageConverter());
|
||||
}
|
||||
private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(){
|
||||
ObjectMapper objectMapper=new ObjectMapper();
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
MappingJackson2HttpMessageConverter converter=new MappingJackson2HttpMessageConverter(objectMapper);
|
||||
return converter;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
package com.landaiqing.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.auth.common.entity.PageInfo;
|
||||
import com.landaiqing.auth.common.entity.PageResult;
|
||||
import com.landaiqing.auth.common.entity.Result;
|
||||
import com.landaiqing.auth.common.util.MessageUtil;
|
||||
import com.landaiqing.convert.PermissionDTOConvert;
|
||||
import com.landaiqing.convert.StudentInfoDtoConvert;
|
||||
import com.landaiqing.domain.bo.PermissionBO;
|
||||
import com.landaiqing.domain.bo.StudentBO;
|
||||
import com.landaiqing.domain.service.StudentDomainService;
|
||||
import com.landaiqing.domain.service.StudentPermissionDomainService;
|
||||
import com.landaiqing.dto.PermissionDTO;
|
||||
import com.landaiqing.dto.StudentDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname StudentController
|
||||
* @BelongsProject: student-Management-system
|
||||
* @BelongsPackage: com.landaiqing.controller
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-03-04 23:17
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/student/")
|
||||
@Slf4j
|
||||
public class StudentController {
|
||||
@Resource
|
||||
private StudentDomainService studentDomainService;
|
||||
@Resource
|
||||
private StudentPermissionDomainService studentPermissionDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 头像上传
|
||||
* @param: [studentDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/3/4 23:47
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
public Result<Boolean> uploadAvatar(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("StudentController.uploadAvatar.dto:{}", JSON.toJSONString(studentDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(studentDTO.getUrl()), "url不能为空!");
|
||||
Preconditions.checkNotNull(studentDTO.getId(), "id不能为空!");
|
||||
StudentBO studentBO = StudentInfoDtoConvert.INSTANCE.convertDtoToBO(studentDTO);
|
||||
return Result.ok(studentDomainService.uploadAvatar(studentBO));
|
||||
} catch (Exception e) {
|
||||
log.error("StudentController.uploadAvatar.error:{}", e.getMessage(), e);
|
||||
return Result.fail("上传头像失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 分页查询所有学生信息
|
||||
* @param: [studentDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<com.landaiqing.auth.common.entity.PageResult < com.landaiqing.dto.StudentDTO>>
|
||||
* @author landaiqing
|
||||
* @date: 2024/3/5 12:03
|
||||
*/
|
||||
@RequestMapping("queryAllStudent")
|
||||
public Result<PageResult<StudentDTO>> queryAllStudent(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("StudentController.queryAllStudent.dto:{}", JSON.toJSONString(studentDTO));
|
||||
}
|
||||
StudentBO studentBO = StudentInfoDtoConvert.INSTANCE.convertDtoToBO(studentDTO);
|
||||
studentBO.getPageNo();
|
||||
studentBO.getPageSize();
|
||||
PageResult<StudentBO> pageResult = studentDomainService.queryAllStudentByPage(studentBO);
|
||||
return Result.ok(pageResult);
|
||||
} catch (Exception e) {
|
||||
log.error("StudentController.queryAllStudent.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询失败失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询指定学生的权限
|
||||
* @param: [studentDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.util.List < com.landaiqing.dto.PermissionDTO>>
|
||||
* @author landaiqing
|
||||
* @date: 2024/3/5 12:03
|
||||
*/
|
||||
@RequestMapping("queryPermission")
|
||||
public Result<List<PermissionDTO>> queryStudentPermission(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("StudentController.queryStudentPermission.dto:{}", JSON.toJSONString(studentDTO));
|
||||
}
|
||||
StudentBO studentBO = StudentInfoDtoConvert.INSTANCE.convertDtoToBO(studentDTO);
|
||||
List<PermissionBO> permissionBOS = studentPermissionDomainService.queryStudentPermission(studentBO);
|
||||
List<PermissionDTO> permissionDTOS = PermissionDTOConvert.INSTANCE.convertBoToDtoList(permissionBOS);
|
||||
return Result.ok(permissionDTOS);
|
||||
} catch (Exception e) {
|
||||
log.error("StudentController.queryStudentPermission.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询失败失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试国际化
|
||||
* en_US 英文 http://127.0.0.1:3001/en_US
|
||||
* zh_CN 中文 http://127.0.0.1:3001/zh_CN
|
||||
*/
|
||||
@GetMapping("/{language}")
|
||||
public String test(@PathVariable String language) {
|
||||
|
||||
String text2 = MessageUtil.get("sutdent_center", language);
|
||||
return text2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 登录
|
||||
* @param: [studentDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/3/5 17:28
|
||||
*/
|
||||
@RequestMapping("login")
|
||||
public Result<Boolean> login(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("StudentController.queryStudentPermission.dto:{}", JSON.toJSONString(studentDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(studentDTO.getUsername()), "用户名不能为空!");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(studentDTO.getPassword()), "密码不能为空!");
|
||||
StudentBO studentBO = StudentInfoDtoConvert.INSTANCE.convertDtoToBO(studentDTO);
|
||||
Boolean result = studentDomainService.login(studentBO);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
log.error("StudentController.queryStudentPermission.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询失败失败!");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.landaiqing.convert;
|
||||
|
||||
import com.landaiqing.domain.bo.PermissionBO;
|
||||
import com.landaiqing.domain.bo.StudentBO;
|
||||
import com.landaiqing.dto.PermissionDTO;
|
||||
import com.landaiqing.dto.StudentDTO;
|
||||
import com.landaiqing.infra.basic.entity.Permission;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname PermissionDTOConvert
|
||||
* @BelongsProject: student-Management-system
|
||||
* @BelongsPackage: com.landaiqing.convert
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-03-05 11:55
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionDTOConvert {
|
||||
PermissionDTOConvert INSTANCE= Mappers.getMapper(PermissionDTOConvert.class);
|
||||
PermissionBO convertDtoToBO(PermissionDTO permissionDTO);
|
||||
List<PermissionDTO> convertBoToDtoList(List<PermissionBO> permissionBOList);
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.landaiqing.convert;
|
||||
|
||||
import com.landaiqing.domain.bo.StudentBO;
|
||||
import com.landaiqing.dto.StudentDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Classname StudentInfoDtoConvert
|
||||
* @BelongsProject: student-Management-system
|
||||
* @BelongsPackage: com.landaiqing.convert
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-03-04 23:22
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface StudentInfoDtoConvert {
|
||||
StudentInfoDtoConvert INSTANCE= Mappers.getMapper(StudentInfoDtoConvert.class);
|
||||
|
||||
StudentBO convertDtoToBO(StudentDTO studentDTO);
|
||||
List<StudentDTO> convertBOToDTOList(List<StudentBO> studentBOList);
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (PermissionBO)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-03-04 22:29:35
|
||||
*/
|
||||
@Data
|
||||
public class PermissionDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String menuUrl;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Integer show;
|
||||
|
||||
private String icon;
|
||||
|
||||
private String permissionKey;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,85 @@
|
||||
package com.landaiqing.dto;
|
||||
|
||||
import com.landaiqing.auth.common.entity.PageInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (StudentDTO)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-03-04 22:25:32
|
||||
*/
|
||||
@Data
|
||||
public class StudentDTO extends PageInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
private String sno;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 班级
|
||||
*/
|
||||
private Integer className;
|
||||
/**
|
||||
* 年级
|
||||
*/
|
||||
private Integer grade;
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer sex;
|
||||
/**
|
||||
* 头像链接
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private Date dateOfBirth;
|
||||
/**
|
||||
* email
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
/**
|
||||
* 班级id
|
||||
*/
|
||||
private Long classId;
|
||||
/**
|
||||
* 年级id
|
||||
*/
|
||||
private Long gradeId;
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private Integer roleId;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
private String url;
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user