添加碳排放标签接口开发
This commit is contained in:
parent
1e67fc698a
commit
719c9eec2e
@ -8,6 +8,7 @@ import net.carbon.model.request.LabelUpdateRequest;
|
||||
import net.carbon.model.vo.LabelVO;
|
||||
import net.carbon.result.Result;
|
||||
import net.carbon.service.LabelService;
|
||||
import net.carbon.utils.JsonData;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -67,5 +68,14 @@ public class LabelController {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/add")
|
||||
public JsonData add(@RequestBody LabelUpdateRequest labelUpdateRequest){
|
||||
int row = labelService.add(labelUpdateRequest);
|
||||
if (row >0){
|
||||
return JsonData.buildCodeAndMsg(1,"添加成功");
|
||||
}
|
||||
return JsonData.buildError("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.carbon.mapper;
|
||||
|
||||
import net.carbon.model.po.LabelDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@ -15,4 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface LabelMapper extends BaseMapper<LabelDO> {
|
||||
|
||||
@Insert("insert into label (name, unit, data_value, attribute, is_system_date, is_delete) values (#{name},#{unit},#{dataValue},#{attribute},#{isSystemDate},#{isDeleted})")
|
||||
int add(LabelDO labelDO);
|
||||
}
|
||||
|
@ -25,4 +25,5 @@ public interface LabelService extends IService<LabelDO> {
|
||||
|
||||
int updateById(LabelUpdateRequest labelUpdateReq);
|
||||
|
||||
int add(LabelUpdateRequest labelUpdateRequest);
|
||||
}
|
||||
|
@ -73,4 +73,13 @@ public class LabelServiceImpl extends ServiceImpl<LabelMapper, LabelDO> implemen
|
||||
int row = labelMapper.updateById(labelDO);
|
||||
return row;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(LabelUpdateRequest labelUpdateRequest) {
|
||||
LabelDO labelDO = new LabelDO();
|
||||
BeanUtils.copyProperties(labelUpdateRequest,labelDO);
|
||||
labelDO.setIsDeleted(0);
|
||||
int row = labelMapper.add(labelDO);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user