tlias管理系统--员工管理--新增员工实现功能1
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.inmind.controller;
|
package com.inmind.controller;
|
||||||
|
|
||||||
|
import com.inmind.pojo.Emp;
|
||||||
import com.inmind.pojo.PageBean;
|
import com.inmind.pojo.PageBean;
|
||||||
import com.inmind.pojo.Result;
|
import com.inmind.pojo.Result;
|
||||||
import com.inmind.service.EmpService;
|
import com.inmind.service.EmpService;
|
||||||
@@ -42,4 +43,12 @@ public class EmpController {
|
|||||||
empService.delete(ids);
|
empService.delete(ids);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Result save(@RequestBody Emp emp){
|
||||||
|
log.info("新增员工:{}",emp);
|
||||||
|
//调用业务层执行新增操作
|
||||||
|
empService.save(emp);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.inmind.mapper;
|
|||||||
|
|
||||||
import com.inmind.pojo.Emp;
|
import com.inmind.pojo.Emp;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
@@ -39,4 +40,12 @@ public interface EmpMapper {
|
|||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
void delete(List<Integer> ids);
|
void delete(List<Integer> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增员工操作
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
@Insert("insert into emp(username,name,gender,image,job,entrydate,create_time,update_time) " +
|
||||||
|
"values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{createTime},#{updateTime})")
|
||||||
|
void save(Emp emp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.inmind.service;
|
package com.inmind.service;
|
||||||
|
|
||||||
|
import com.inmind.pojo.Emp;
|
||||||
import com.inmind.pojo.PageBean;
|
import com.inmind.pojo.PageBean;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -24,4 +25,10 @@ public interface EmpService {
|
|||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
void delete(List<Integer> ids);
|
void delete(List<Integer> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增员工
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
void save(Emp emp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -76,4 +77,16 @@ public class EmpServiceImpl implements EmpService {
|
|||||||
public void delete(List<Integer> ids) {
|
public void delete(List<Integer> ids) {
|
||||||
empMapper.delete(ids);
|
empMapper.delete(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增员工
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(Emp emp) {
|
||||||
|
//补充基本属性
|
||||||
|
emp.setCreateTime(LocalDateTime.now());
|
||||||
|
emp.setUpdateTime(LocalDateTime.now());
|
||||||
|
empMapper.save(emp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user