Commit 2b2e87a1 authored by jichao's avatar jichao

评估--节能改造--认定 更改接口

parent caffdb36
......@@ -7,15 +7,16 @@ import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.business.manage.service.BusSavingService;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.GridModel;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.validation.Valid;
/**
* Created by JiChao on 2018/5/17.
......@@ -23,32 +24,61 @@ import java.util.List;
@Api(tags = "评估--节能改造--认定")
@RestController
@RequestMapping("bussaving")
public class BusSavingController {
public class BusSavingController extends PaginationController<BusSaving> {
@Autowired
private BusSavingService busSavingServiceImpl;
@ApiOperation(value="修改", notes="传list对象")
/* @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串"),
@ApiOperation(value="增加", notes="增加")
@ApiImplicitParams({
@ApiImplicitParam(name = "examiner", value = "检定员", dataType = "字符串"),
@ApiImplicitParam(name = "qualification", value = "执业资质", dataType = "字符串"),
@ApiImplicitParam(name = "tm", value = "从业时间", dataType = "字符串"),
@ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串")
})
@RequestMapping("/save")
public Result save(@Valid BusSaving busSaving) {
Integer result = busSavingServiceImpl.save(busSaving);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "examiner", value = "检定员", dataType = "字符串"),
@ApiImplicitParam(name = "qualification", value = "执业资质", dataType = "字符串"),
@ApiImplicitParam(name = "tm", value = "从业时间", dataType = "字符串"),
@ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串"),
@ApiImplicitParam(name = "type", value = "1:工程造价认定,2:节能认定", dataType = "字符串"),
@ApiImplicitParam(name = "proId", value = "项目表主键", dataType = "字符串,可以不传")
})*/
@ApiImplicitParam(name = "performance", value = "项目业绩", dataType = "字符串")
})
@RequestMapping("/update")
public Result update(@RequestBody List<BusSaving> busSavingList) {
return Result.builder(busSavingServiceImpl.update(busSavingList));
public Result update(@Valid BusSaving busSaving) {
Integer result = busSavingServiceImpl.update(busSaving);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="删除", notes="删除")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串")
})
@RequestMapping("/delete/{id:\\w+}")
public Result delete(@PathVariable String id) {
Integer result = busSavingServiceImpl.delete(id);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@ApiOperation(value="分页查询", notes="分页查询")
@RequestMapping("/findAllByPagination")
public GridModel findAllByPagination() {
busSavingServiceImpl.findAllByPagination(getPaginationUtility());
return getGridModelResponse();
}
@ApiOperation(value="查询", notes="2条记录,工程造价认定、节能认定")
@ApiOperation(value="根据id查找", notes="根据id查找")
@ApiImplicitParams({
@ApiImplicitParam(name = "proId", value = "项目表主键", required = true, dataType = "字符串")
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "字符串")
})
@RequestMapping("/queryBusSaving/{proId:\\w+}")
public Result queryBusSaving(@PathVariable String proId) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busSavingServiceImpl.queryBusSaving(proId));
@RequestMapping("/findBusSaving/{id:\\w+}")
public Result findBusSaving(@PathVariable String id) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, busSavingServiceImpl.findBusSaving(id));
}
}
......@@ -25,7 +25,7 @@ public class BusSaving {
private String qualification;
private String tm;
private String performance;
private String type;
private String proId;
// private String type;
// private String proId;
}
package org.rcisoft.business.manage.service;
import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import java.util.List;
......@@ -14,24 +15,30 @@ public interface BusSavingService {
* 保存
* @return
*/
PersistModel save(List<BusSaving> busSavingList);
Integer save(BusSaving busSaving);
/**
* 修改
* @return
*/
PersistModel update(List<BusSaving> busSavingList);
Integer update(BusSaving busSaving);
/**
* 删除
* @return
*/
PersistModel delete(String proId);
Integer delete(String id);
/**
* 分页查询
* @return
*/
List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility);
/**
* 根据proId查询
* 查询单条
* @param id
* @return
*/
List<BusSaving> queryBusSaving(String proId);
BusSaving findBusSaving(String id);
}
......@@ -5,6 +5,7 @@ import org.rcisoft.business.manage.dao.BusSavingRepository;
import org.rcisoft.business.manage.entity.BusSaving;
import org.rcisoft.business.manage.service.BusSavingService;
import org.rcisoft.business.overview.entity.BusProjectArea;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -12,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.UUID;
/**
* Created by JiChao on 2018/5/17.
......@@ -24,56 +26,40 @@ public class BusSavingServiceImpl implements BusSavingService {
@Transactional
@Override
public PersistModel save(List<BusSaving> busSavingList) {
int result = 0;
for (BusSaving busSaving : busSavingList) {
result += busSavingRepository.insertSelective(busSaving);
}
return new PersistModel(result);
public Integer save(BusSaving busSaving) {
String id = UUID.randomUUID().toString().replaceAll("-", "");
busSaving.setId(id);
return busSavingRepository.insertSelective(busSaving);
}
@Transactional
@Override
public PersistModel update(List<BusSaving> busSavingList) {
int result = 0;
String message = "";
for (BusSaving busSaving : busSavingList) {
String id = busSaving.getId();
if (StringUtils.isNotEmpty(id)) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
result += busSavingRepository.updateByExampleSelective(busSaving, example);
message = "更新成功";
} else {
message = "ID为空,更新失败";
}
}
return new PersistModel(result, message);
public Integer update(BusSaving busSaving) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", busSaving.getId());
return busSavingRepository.updateByExampleSelective(busSaving, example);
}
@Transactional
@Override
public PersistModel delete(String proId) {
int result = 0;
String message = "";
public Integer delete(String id) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotEmpty(proId)) {
criteria.andEqualTo("proId", proId);
result += busSavingRepository.deleteByExample(example);
message = "删除成功";
} else {
message = "项目ID为空,删除失败";
}
return new PersistModel(result, message);
criteria.andEqualTo("id", id);
return busSavingRepository.deleteByExample(example);
}
@Override
public List<BusSaving> queryBusSaving(String proId) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("proId", proId);
return busSavingRepository.selectByExample(example);
public List<BusSaving> findAllByPagination(PageUtil<BusSaving> paginationUtility) {
return busSavingRepository.selectAll();
}
@Override
public BusSaving findBusSaving(String id) {
BusSaving busSaving = new BusSaving();
busSaving.setId(id);
return busSavingRepository.selectOne(busSaving);
}
}
......@@ -7,8 +7,8 @@
<result column="QUALIFICATION" jdbcType="VARCHAR" property="qualification"/>
<result column="TM" jdbcType="VARCHAR" property="tm"/>
<result column="PERFORMANCE" jdbcType="VARCHAR" property="performance"/>
<result column="TYPE" jdbcType="VARCHAR" property="type"/>
<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>
<!--<result column="TYPE" jdbcType="VARCHAR" property="type"/>-->
<!--<result column="PRO_ID" jdbcType="VARCHAR" property="proId"/>-->
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment