服务端接口设计
salary/SalaryController
@RestController
@RequestMapping("/salary/sob")
public class SalaryController {
@Autowired
SalaryService salaryService;
@GetMapping("/")
public List getAllSalary(){
return salaryService.getAllSalary();
}
@PostMapping("/")
public RespBean addSalary(@RequestBody Salary salary) {
if (salaryService.addSalary(salary) == 1) {
return RespBean.ok("添加成功");
}
return RespBean.error("添加失败");
}
@DeleteMapping("/{id}")
public RespBean deleteSalary(@PathVariable Integer id) {
if (salaryService.deleteSalary(id)==1) {
return RespBean.ok("删除成功");
}
return RespBean.error("删除失败");
}
@PutMapping("/")
public RespBean updateSalary(@RequestBody Salary salary) {
if (salaryService.updateSalary(salary) == 1) {
return RespBean.ok("更改成功");
}
return RespBean.error("更改失败");
}
}
salarySerice
@Service
public class SalaryService {
@Autowired
SalaryMapper salaryMapper;
public List getAllSalary() {
return salaryMapper.getAllSalary();
}
public Integer addSalary(Salary salary) {
return salaryMapper.insertSelective(salary);
}
public Integer deleteSalary(Integer id) {
return salaryMapper.deleteByPrimaryKey(id);
}
public Integer updateSalary(Salary salary) {
return salaryMapper.updateByPrimaryKeySelective(salary);
}
}
mapper
public interface SalaryMapper {
int deleteByPrimaryKey(Integer id);
int insert(Salary record);
int insertSelective(Salary record);
Salary selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Salary record);
int updateByPrimaryKey(Salary record);
List getAllSalary();
}
xml
id, basicSalary, bonus, lunchSalary, trafficSalary, allSalary, pensionBase, pensionPer,
createDate, medicalBase, medicalPer, accumulationFundBase, accumulationFundPer, name
delete from salary
where id = #{id,jdbcType=INTEGER}
insert into salary (id, basicSalary, bonus,
lunchSalary, trafficSalary, allSalary,
pensionBase, pensionPer, createDate,
medicalBase, medicalPer, accumulationFundBase,
accumulationFundPer, name)
values (#{id,jdbcType=INTEGER}, #{basicsalary,jdbcType=INTEGER}, #{bonus,jdbcType=INTEGER},
#{lunchsalary,jdbcType=INTEGER}, #{trafficsalary,jdbcType=INTEGER}, #{allsalary,jdbcType=INTEGER},
#{pensionbase,jdbcType=INTEGER}, #{pensionper,jdbcType=REAL}, #{createdate,jdbcType=TIMESTAMP},
#{medicalbase,jdbcType=INTEGER}, #{medicalper,jdbcType=REAL}, #{accumulationfundbase,jdbcType=INTEGER},
#{accumulationfundper,jdbcType=REAL}, #{name,jdbcType=VARCHAR})
insert into salary
id,
basicSalary,
bonus,
lunchSalary,
trafficSalary,
allSalary,
pensionBase,
pensionPer,
createDate,
medicalBase,
medicalPer,
accumulationFundBase,
accumulationFundPer,
name,
#{id,jdbcType=INTEGER},
#{basicsalary,jdbcType=INTEGER},
#{bonus,jdbcType=INTEGER},
#{lunchsalary,jdbcType=INTEGER},
#{trafficsalary,jdbcType=INTEGER},
#{allsalary,jdbcType=INTEGER},
#{pensionbase,jdbcType=INTEGER},
#{pensionper,jdbcType=REAL},
#{createdate,jdbcType=TIMESTAMP},
#{medicalbase,jdbcType=INTEGER},
#{medicalper,jdbcType=REAL},
#{accumulationfundbase,jdbcType=INTEGER},
#{accumulationfundper,jdbcType=REAL},
#{name,jdbcType=VARCHAR},
update salary
basicSalary = #{basicsalary,jdbcType=INTEGER},
bonus = #{bonus,jdbcType=INTEGER},
lunchSalary = #{lunchsalary,jdbcType=INTEGER},
trafficSalary = #{trafficsalary,jdbcType=INTEGER},
allSalary = #{allsalary,jdbcType=INTEGER},
pensionBase = #{pensionbase,jdbcType=INTEGER},
pensionPer = #{pensionper,jdbcType=REAL},
createDate = #{createdate,jdbcType=TIMESTAMP},
medicalBase = #{medicalbase,jdbcType=INTEGER},
medicalPer = #{medicalper,jdbcType=REAL},
accumulationFundBase = #{accumulationfundbase,jdbcType=INTEGER},
accumulationFundPer = #{accumulationfundper,jdbcType=REAL},
name = #{name,jdbcType=VARCHAR},
where id = #{id,jdbcType=INTEGER}
update salary
set basicSalary = #{basicsalary,jdbcType=INTEGER},
bonus = #{bonus,jdbcType=INTEGER},
lunchSalary = #{lunchsalary,jdbcType=INTEGER},
trafficSalary = #{trafficsalary,jdbcType=INTEGER},
allSalary = #{allsalary,jdbcType=INTEGER},
pensionBase = #{pensionbase,jdbcType=INTEGER},
pensionPer = #{pensionper,jdbcType=REAL},
createDate = #{createdate,jdbcType=TIMESTAMP},
medicalBase = #{medicalbase,jdbcType=INTEGER},
medicalPer = #{medicalper,jdbcType=REAL},
accumulationFundBase = #{accumulationfundbase,jdbcType=INTEGER},
accumulationFundPer = #{accumulationfundper,jdbcType=REAL},
name = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
页面设计
添加工资账套
编辑
删除