Skip to content

Commit

Permalink
Merge pull request #6 from moshuying/dev
Browse files Browse the repository at this point in the history
进入到角色页面
  • Loading branch information
moshuying authored May 14, 2021
2 parents 82ab407 + 83f7466 commit 466cd8b
Show file tree
Hide file tree
Showing 32 changed files with 576 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
idea
2 changes: 1 addition & 1 deletion back/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

\.idea/
.idea/

target/

Expand Down
22 changes: 0 additions & 22 deletions back/.idea/compiler.xml

This file was deleted.

6 changes: 0 additions & 6 deletions back/.idea/encodings.xml

This file was deleted.

14 changes: 0 additions & 14 deletions back/.idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions back/.idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions back/.idea/vcs.xml

This file was deleted.

121 changes: 0 additions & 121 deletions back/.idea/workspace.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public Result login(
// 返回Ant Design Admin提供的登录返回格式
LoginResultDTO loginResultDTO = new LoginResultDTO();

// 设置过期时间,和application-*.yml文件中的过期时间设定一致
final long expireTime = this.jwtUtil.getJwtProperties().getExpireTime().toMillis();
loginResultDTO.setExpireAt(new Date(new Date().getTime()+expireTime *60*1000));
loginResultDTO.setToken(token);
loginResultDTO.setUserName(name);
Map<String,Object> roles = new HashMap<String,Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import com.zoctan.seedling.service.DepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
Expand All @@ -15,36 +18,43 @@
* @author MoShuYing
* @date 2021/05/12
*/
@PreAuthorize("hasAuthority('ADMIN')")
@Tag(name = "部门接口")
@RestController
@RequestMapping("/department")
public class DepartmentController {
@Resource
private DepartmentService departmentService;

@Operation(description = "部门添加")
@PostMapping
public Result add(@RequestBody Department department) {
departmentService.save(department);
return ResultGenerator.genOkResult();
}

@Operation(description = "部门删除")
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
departmentService.deleteById(id);
return ResultGenerator.genOkResult();
}

@Operation(description = "部门更新")
@PatchMapping
public Result update(@RequestBody Department department) {
departmentService.update(department);
return ResultGenerator.genOkResult();
}

@Operation(description = "获取部门详细信息")
@GetMapping("/{id}")
public Result detail(@PathVariable Long id) {
Department department = departmentService.getById(id);
return ResultGenerator.genOkResult(department);
}

@Operation(description = "分页查询部门")
@GetMapping
public Result list(@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "0") Integer size) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.zoctan.seedling.controller;

import com.zoctan.seedling.core.response.Result;
import com.zoctan.seedling.core.response.ResultGenerator;
import com.zoctan.seedling.entity.Employee;
import com.zoctan.seedling.service.EmployeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
* @author MoShuYing
* @date 2021/05/13
*/
@PreAuthorize("hasAuthority('ADMIN')")
@Tag(name = "员工接口")
@RestController
@RequestMapping("/employee")
public class EmployeeController {
@Resource
private EmployeeService employeeService;

@Operation(description = "员工添加")
@PostMapping
public Result add(@RequestBody Employee employee) {
employeeService.save(employee);
return ResultGenerator.genOkResult();
}

@Operation(description = "员工删除")
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
employeeService.deleteById(id);
return ResultGenerator.genOkResult();
}

@Operation(description = "员工更新")
@PatchMapping
public Result update(@RequestBody Employee employee) {
employeeService.update(employee);
return ResultGenerator.genOkResult();
}

@Operation(description = "员工信息细节")
@GetMapping("/{id}")
public Result detail(@PathVariable Long id) {
Employee employee = employeeService.getById(id);
return ResultGenerator.genOkResult(employee);
}

@Operation(description = "分页查询员工")
@GetMapping
public Result list(@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "0") Integer size) {
PageHelper.startPage(page, size);
List<Employee> list = employeeService.listAll();
PageInfo<Employee> pageInfo = PageInfo.of(list);
return ResultGenerator.genOkResult(pageInfo);
}
}
4 changes: 3 additions & 1 deletion back/src/main/java/com/zoctan/seedling/core/jwt/JwtUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public class JwtUtil {
@Resource private JwtConfigurationProperties jwtProperties;
@Resource private RedisUtils redisUtils;
@Resource private RsaUtils rsaUtils;

public JwtConfigurationProperties getJwtProperties(){
return this.jwtProperties;
}
/** 根据 token 得到账户名 */
public Optional<String> getName(final String token) {
final Optional<Claims> claims = this.parseToken(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class LoginResultDTO extends AbstractConverter<LoginResultDTO, LoginResul
private String token;

@Schema(name = "过期时间")
private Date expireAt = new Date(new Date().getTime()+30*60*1000);
private Date expireAt;

private List<Object> permissions = new ArrayList<>();
private List<Object> roles = new ArrayList<>();
Expand Down
9 changes: 9 additions & 0 deletions back/src/main/java/com/zoctan/seedling/dto/RoleDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import java.io.Serializable;

/**
Expand All @@ -24,6 +25,14 @@ public class RoleDTO extends AbstractConverter<RoleDTO, RoleDO> implements Seria
@Schema(name = "角色名称")
private String name;

/** 角色编号 */
@Column(name = "sn")
private String sn;

/** 角色权限 */
@Column(name = "permission")
private String permission;

@Override
protected RoleDTO setDTO() {
return this;
Expand Down
Loading

0 comments on commit 466cd8b

Please sign in to comment.