Selaa lähdekoodia

员工删除及更新接口

Joburgess 5 vuotta sitten
vanhempi
commit
5d23e7205a

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/EmployeeService.java

@@ -31,4 +31,17 @@ public interface EmployeeService extends BaseService<Integer, Employee> {
      */
     void add(Employee employee) throws Exception;
 
+    /**
+     * 修改员工信息
+     * @param employee
+     */
+    void updateEmployee(Employee employee);
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/24
+     * 删除员工
+     */
+    void deleteEmployee(Long userId);
+
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TeacherService.java

@@ -40,4 +40,11 @@ public interface TeacherService extends BaseService<Integer, Teacher> {
      * @return
      */
     Teacher getDetail(Integer id);
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/9/24
+     * 删除教师
+     */
+    void deleteTeacher(Long userId);
 }

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EmployeeServiceImpl.java

@@ -10,6 +10,9 @@ import java.util.Map;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.entity.Teacher;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -18,6 +21,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
@@ -48,6 +52,8 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee>  imp
 	private ObjectMapper objectMapper;
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
+	@Autowired
+	private TeacherDao teacherDao;
 
 	@Override
 	public BaseDAO<Integer, Employee> getDAO() {
@@ -69,6 +75,21 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee>  imp
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateEmployee(Employee employee) {
+		employeeDao.update(employee);
+		teacherDao.updateUser(employee);
+	}
+
+	@Override
+	public void deleteEmployee(Long userId) {
+		SysUser sysUser=new SysUser();
+		sysUser.setId(userId.intValue());
+		sysUser.setDelFlag(YesOrNoEnum.YES);
+		teacherDao.updateUser(sysUser);
+	}
+
+	@Override
 	public PageInfo queryEmployByOrganId(EmployeeQueryInfo queryInfo) throws IOException {
 		String url = "http://auth-server/queryUserInfo";
 

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherServiceImpl.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
@@ -67,6 +68,14 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher>  imple
 	}
 
 	@Override
+	public void deleteTeacher(Long userId) {
+		SysUser sysUser=new SysUser();
+		sysUser.setId(userId.intValue());
+		sysUser.setDelFlag(YesOrNoEnum.YES);
+		teacherDao.updateUser(sysUser);
+	}
+
+	@Override
 	public PageInfo<Teacher> queryPageDetail(TeacherQueryInfo queryInfo) {
 		PageInfo<Teacher> pageInfo = queryPage(queryInfo);
 		List<Teacher> teachers = pageInfo.getRows();

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TeacherController.java

@@ -51,6 +51,13 @@ public class TeacherController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation(value = "删除教师")
+    @PostMapping("/delete/{userId}")
+    public Object update(@PathVariable("userId") Long userId) {
+        teacherService.deleteTeacher(userId);
+        return succeed();
+    }
+
     @ApiOperation(value = "根据教师编号查询教师基本信息")
     @GetMapping("/get/{id}")
     @ApiParam(value = "教师编号", required = true)

+ 17 - 5
mec-web/src/main/java/com/ym/mec/web/controller/education/EmployeeController.java

@@ -6,13 +6,10 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 import java.io.IOException;
+import java.util.Date;
 
 import org.springframework.beans.factory.annotation.Autowired;
-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 org.springframework.web.bind.annotation.*;
 
 import com.ym.mec.biz.dal.enums.EmployeeOperateEnum;
 import com.ym.mec.biz.dal.page.EmployeeQueryInfo;
@@ -55,4 +52,19 @@ public class EmployeeController extends BaseController {
         }
         return succeed();
     }
+
+    @ApiOperation(value = "修改员工")
+    @PostMapping("/update")
+    public Object update(Employee employee) {
+        employee.setUpdateTime(new Date());
+        employeeService.updateEmployee(employee);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除员工")
+    @PostMapping("/delete/{userId}")
+    public Object update(@PathVariable("userId") Long userId) {
+        employeeService.deleteEmployee(userId);
+        return succeed();
+    }
 }