tlias管理系统-修改部门功能实现
This commit is contained in:
@@ -53,4 +53,26 @@ public class DeptController {
|
||||
deptService.add(dept);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/*
|
||||
根据部门id查询部门数据(点击编辑时,内容回显)
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public Result getDeptById(@PathVariable Integer id){
|
||||
log.info("查询部门:id--{}",id);
|
||||
//调用业务层,获取部门数据
|
||||
Dept dept = deptService.getDeptById(id);
|
||||
return Result.success(dept);
|
||||
}
|
||||
|
||||
/*
|
||||
根据id修改部门
|
||||
*/
|
||||
@PutMapping
|
||||
public Result update(@RequestBody Dept dept){
|
||||
log.info("更新部门:{}",dept);
|
||||
//调用业务层更新部门名称
|
||||
deptService.update(dept);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.inmind.mapper;
|
||||
|
||||
import com.inmind.pojo.Dept;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,4 +19,12 @@ public interface DeptMapper {
|
||||
@Insert("insert into dept (name, create_time, update_time) " +
|
||||
"VALUES (#{name},#{createTime},#{updateTime})")
|
||||
void insert(Dept dept);
|
||||
|
||||
//根据id查询部门
|
||||
@Select("select * from dept where id = #{id}")
|
||||
Dept getDeptById(Integer id);
|
||||
|
||||
//根据id更新部门名称
|
||||
@Update("update dept set name = #{name},update_time = #{updateTime} where id = #{id} ")
|
||||
void update(Dept dept);
|
||||
}
|
||||
|
||||
@@ -13,4 +13,10 @@ public interface DeptService {
|
||||
|
||||
//新增部门
|
||||
void add(Dept dept);
|
||||
|
||||
//根据id查询部门
|
||||
Dept getDeptById(Integer id);
|
||||
|
||||
//根据id更新部门
|
||||
void update(Dept dept);
|
||||
}
|
||||
|
||||
@@ -36,4 +36,19 @@ public class DeptServiceImpl implements DeptService {
|
||||
dept.setUpdateTime(LocalDateTime.now());
|
||||
deptMapper.insert(dept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dept getDeptById(Integer id) {
|
||||
//调用Mapper查询部门数据即可
|
||||
Dept dept = deptMapper.getDeptById(id);
|
||||
return dept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Dept dept) {
|
||||
//补充更新时间数据
|
||||
dept.setUpdateTime(LocalDateTime.now());
|
||||
//调用mapper更新部门
|
||||
deptMapper.update(dept);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user