Skip to content

Commit

Permalink
Apply Google Java Style Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiser-Yang authored and github-actions[bot] committed Aug 21, 2024
1 parent 875ff6f commit 8be100b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
37 changes: 18 additions & 19 deletions src/main/java/edu/cmipt/gcs/controller/UserController.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
package edu.cmipt.gcs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.cmipt.gcs.pojo.user.UserDTO;
import edu.cmipt.gcs.pojo.user.UserPO;
import edu.cmipt.gcs.service.UserService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
@Tag(name = "User", description = "User Related APIs")
public class UserController {
@Autowired
private UserService userService;
@Autowired private UserService userService;

@PostMapping
@Operation(
summary = "Create a new user",
description = "Create a new user with the given information",
tags = { "User", "Post Method" }
)
summary = "Create a new user",
description = "Create a new user with the given information",
tags = {"User", "Post Method"})
@ApiResponses({
@ApiResponse(responseCode = "200", description = "User created successfully"),
@ApiResponse(responseCode = "400", description = "User creation failed")
@ApiResponse(responseCode = "200", description = "User created successfully"),
@ApiResponse(responseCode = "400", description = "User creation failed")
})
public ResponseEntity<Void> createUser(@RequestBody UserDTO user) {
if (user == null ||
user.getUsername() == null ||
user.getEmail() == null ||
user.getUserPassword() == null) {
if (user == null
|| user.getUsername() == null
|| user.getEmail() == null
|| user.getUserPassword() == null) {
return ResponseEntity.badRequest().build();
}
// there may be some check before....
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/cmipt/gcs/dao/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

import edu.cmipt.gcs.pojo.user.UserPO;

public interface UserMapper extends BaseMapper<UserPO> {
}
public interface UserMapper extends BaseMapper<UserPO> {}
19 changes: 16 additions & 3 deletions src/main/java/edu/cmipt/gcs/pojo/user/UserDTO.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package edu.cmipt.gcs.pojo.user;

import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;

@Data
@Schema(description = "User Data Transfer Object")
public class UserDTO {
@Schema(accessMode = Schema.AccessMode.READ_ONLY, description = "User ID")
private Long id;
@Schema(description = "Username", requiredMode = Schema.RequiredMode.REQUIRED, example = "admin")

@Schema(
description = "Username",
requiredMode = Schema.RequiredMode.REQUIRED,
example = "admin")
private String username;
@Schema(description = "Email", requiredMode = Schema.RequiredMode.REQUIRED, example = "[email protected]")

@Schema(
description = "Email",
requiredMode = Schema.RequiredMode.REQUIRED,
example = "[email protected]")
private String email;
@Schema(description = "User Password (Unencrypted)", requiredMode = Schema.RequiredMode.REQUIRED, example = "admin")

@Schema(
description = "User Password (Unencrypted)",
requiredMode = Schema.RequiredMode.REQUIRED,
example = "admin")
private String userPassword;
}
5 changes: 3 additions & 2 deletions src/main/java/edu/cmipt/gcs/pojo/user/UserPO.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.baomidou.mybatisplus.annotation.TableName;

import edu.cmipt.gcs.util.MD5Converter;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.LocalDateTime;

@Data
Expand All @@ -18,8 +20,7 @@ public class UserPO {
private String userPassword;
private LocalDateTime gmtCreated;
private LocalDateTime gmtUpdated;
@TableLogic
private LocalDateTime gmtDeleted;
@TableLogic private LocalDateTime gmtDeleted;

public UserPO(UserDTO userDTO) {
this.id = userDTO.getId();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/cmipt/gcs/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

import edu.cmipt.gcs.pojo.user.UserPO;

public interface UserService extends IService<UserPO> {
}
public interface UserService extends IService<UserPO> {}
7 changes: 3 additions & 4 deletions src/main/java/edu/cmipt/gcs/service/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package edu.cmipt.gcs.service;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import edu.cmipt.gcs.dao.UserMapper;
import edu.cmipt.gcs.pojo.user.UserPO;

import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements UserService {
}
public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements UserService {}
1 change: 0 additions & 1 deletion src/test/java/edu/cmipt/gcs/dao/UserMapperTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.cmipt.gcs.dao;

import com.baomidou.mybatisplus.core.toolkit.Assert;

import edu.cmipt.gcs.pojo.user.UserPO;

Expand Down

0 comments on commit 8be100b

Please sign in to comment.