tlias管理系统--部门管理--修改部门
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@RequestMapping("/depts")
|
||||||
public class DeptController {
|
public class DeptController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -26,7 +27,7 @@ public class DeptController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @RequestMapping(value = "/depts",method = RequestMethod.GET)
|
// @RequestMapping(value = "/depts",method = RequestMethod.GET)
|
||||||
@GetMapping("/depts")
|
@GetMapping
|
||||||
public Result getDeptList(){
|
public Result getDeptList(){
|
||||||
log.info("查询所有部门数据");
|
log.info("查询所有部门数据");
|
||||||
//调用业务层的查询部门的功能
|
//调用业务层的查询部门的功能
|
||||||
@@ -34,7 +35,7 @@ public class DeptController {
|
|||||||
return Result.success(deptList);
|
return Result.success(deptList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/depts/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public Result delete(@PathVariable Integer id){
|
public Result delete(@PathVariable Integer id){
|
||||||
log.info("删除部门:{}",id);
|
log.info("删除部门:{}",id);
|
||||||
deptService.delete(id);
|
deptService.delete(id);
|
||||||
@@ -42,10 +43,25 @@ public class DeptController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/depts")
|
@PostMapping
|
||||||
public Result add(@RequestBody Dept dept){
|
public Result add(@RequestBody Dept dept){
|
||||||
log.info("新增部门:{}",dept);
|
log.info("新增部门:{}",dept);
|
||||||
deptService.add(dept);
|
deptService.add(dept);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result getDeptById(@PathVariable Integer id){
|
||||||
|
log.info("根据id查询部门:{}",id);
|
||||||
|
Dept dept = deptService.getDeptById(id);
|
||||||
|
return Result.success(dept);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
public Result update(@RequestBody Dept dept){
|
||||||
|
log.info("更新部门:{}",dept);
|
||||||
|
deptService.update(dept);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.inmind.mapper;
|
package com.inmind.mapper;
|
||||||
|
|
||||||
import com.inmind.pojo.Dept;
|
import com.inmind.pojo.Dept;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.apache.ibatis.annotations.Insert;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -19,4 +16,10 @@ public interface DeptMapper {
|
|||||||
//insert into dept (name,create_time,update_time) values ()
|
//insert into dept (name,create_time,update_time) values ()
|
||||||
@Insert("insert into dept (name,create_time,update_time) values (#{name},#{createTime},#{updateTime})")
|
@Insert("insert into dept (name,create_time,update_time) values (#{name},#{createTime},#{updateTime})")
|
||||||
void insert(Dept dept);
|
void insert(Dept dept);
|
||||||
|
|
||||||
|
@Select("select * from dept where id = #{id}")
|
||||||
|
Dept getDeptById(Integer id);
|
||||||
|
|
||||||
|
@Update("update dept set name = #{name},update_time = #{updateTime} where id = #{id}")
|
||||||
|
void update(Dept dept);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,16 @@ public interface DeptService {
|
|||||||
*/
|
*/
|
||||||
void add(Dept dept);
|
void add(Dept dept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询部门
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Dept getDeptById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新部门数据
|
||||||
|
* @param dept
|
||||||
|
*/
|
||||||
|
void update(Dept dept);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,27 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
deptMapper.insert(dept);
|
deptMapper.insert(dept);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询部门
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Dept getDeptById(Integer id) {
|
||||||
|
Dept dept = deptMapper.getDeptById(id);
|
||||||
|
return dept;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新部门数据
|
||||||
|
* @param dept
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void update(Dept dept) {
|
||||||
|
//设置新的修改时间
|
||||||
|
dept.setUpdateTime(LocalDateTime.now());
|
||||||
|
//使用Mapper更新部门
|
||||||
|
deptMapper.update(dept);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user