|
@@ -0,0 +1,77 @@
|
|
|
+package com.yonge.cooleshow.admin.controller;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.EmployeeDao;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Employee;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.EmployeeService;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
+
|
|
|
+@RequestMapping("employee")
|
|
|
+@Api(tags = "员工管理")
|
|
|
+@RestController
|
|
|
+public class EmployeeController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EmployeeService employeeService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增员工")
|
|
|
+ @PostMapping("/add")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('employee/add')")
|
|
|
+ public Object add(@RequestBody Employee employee) throws Exception {
|
|
|
+ employeeService.add(employee);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改员工")
|
|
|
+ @PostMapping("/update")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('employee/update')")
|
|
|
+ public Object update(@RequestBody Employee employee) {
|
|
|
+ employee.setUpdateTime(new Date());
|
|
|
+ employeeService.updateEmployee(employee);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取所有员工")
|
|
|
+ @GetMapping("/findAll")
|
|
|
+ @PreAuthorize("@pcs.hasPermissions('employee/findAll')")
|
|
|
+ public Object findAll() {
|
|
|
+ return succeed(employeeService.findAll(null));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取用户信息")
|
|
|
+ @GetMapping("/queryUserInfo")
|
|
|
+ public Object apiQueryUserInfo() {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if(sysUser != null && sysUser.getId() != null){
|
|
|
+ Employee employee = employeeService.get(sysUser.getId());
|
|
|
+ employee.setRoles(employeeDao.queryUserRole(sysUser.getId()));
|
|
|
+ employee.setContactAddress(employee.getContactAddress());
|
|
|
+ employee.setPostalCode(employee.getPostalCode());
|
|
|
+
|
|
|
+ return succeed(employee);
|
|
|
+ }
|
|
|
+ return failed("获取用户信息失败");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|