perf: 优化电压线路的add方法

dev
huangfeng 7 months ago
parent 94067a15ff
commit af18f17054

@ -58,13 +58,9 @@ public class DyLevelController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/add") @RequestMapping("/add")
@Log(title = "增加电压", type = "查询") @Log(title = "增加电压", type = "查询")
public ResponseReult<String> addDy(@RequestBody DyLevel vo) { public ResponseReult<DyLevel> addDy(@RequestBody DyLevel vo) {
ServiceBody<String> serviceBody = dyLevelService.add(vo); dyLevelService.add(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) { return ResponseReult.success(vo);
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
} }
@ApiOperation(value = "删除电压", notes = "删除电压", httpMethod = "POST") @ApiOperation(value = "删除电压", notes = "删除电压", httpMethod = "POST")

@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Api(value = "线路接口", tags = "线路相关") @Api(value = "线路接口", tags = "线路相关")
@RestController @RestController
@ -48,13 +50,9 @@ public class LineController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/addLine") @RequestMapping("/addLine")
@Log(title = "添加线路", type = "新增") @Log(title = "添加线路", type = "新增")
public ResponseReult<String> addLine(@RequestBody @Validated LineVo vo) { public ResponseReult<List<Lines>> addLine(@RequestBody @Validated LineVo vo) {
ServiceBody<String> serviceBody = lineService.addLine(vo); List<Lines> list = lineService.addLine(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) { return ResponseReult.success(list);
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
} }
@ApiOperation(value = "删除线路", notes = "删除线路接口", httpMethod = "POST") @ApiOperation(value = "删除线路", notes = "删除线路接口", httpMethod = "POST")

@ -306,11 +306,13 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.DyLevel"> <insert id="insert" parameterType="com.shxy.xymanager_common.entity.DyLevel">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
insert into dy_level (id, name, dy_value, SELECT LAST_INSERT_ID()
</selectKey>
insert into dy_level (name, dy_value,
status, create_time, update_time status, create_time, update_time
) )
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{dyValue,jdbcType=INTEGER}, values (#{name,jdbcType=VARCHAR}, #{dyValue,jdbcType=INTEGER},
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
) )

@ -167,11 +167,13 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.Lines"> <insert id="insert" parameterType="com.shxy.xymanager_common.entity.Lines">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
insert into lines (id, name, bs_manufacturer, SELECT LAST_INSERT_ID()
</selectKey>
insert into lines (name, bs_manufacturer,
dy_level_id, status, create_time, dy_level_id, status, create_time,
update_time) update_time)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{bsManufacturer,jdbcType=VARCHAR}, values (#{name,jdbcType=VARCHAR}, #{bsManufacturer,jdbcType=VARCHAR},
#{dyLevelId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{dyLevelId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}) #{updateTime,jdbcType=TIMESTAMP})

@ -310,10 +310,11 @@ public class DyLevelServiceImpl implements DyLevelService {
} }
@Override @Override
public ServiceBody<String> add(DyLevel vo) { public void add(DyLevel vo) {
vo.setStatus(1);
vo.setCreateTime(new Date()); vo.setCreateTime(new Date());
dyLevelDao.insertSelective(vo); vo.setUpdateTime(new Date());
return Asserts.success("success"); dyLevelDao.insert(vo);
} }
@Override @Override

@ -209,16 +209,17 @@ public class LineServiceImpl implements LineService {
*/ */
@Override @Override
@CacheEvict(cacheNames = {"permissionfull", "permissionover", "fulltree"}, allEntries = true) @CacheEvict(cacheNames = {"permissionfull", "permissionover", "fulltree"}, allEntries = true)
public ServiceBody<String> addLine(LineVo vo) { public List<Lines> addLine(LineVo vo) {
List<Lines> lines = BeanUtil.copyToList(vo.getList(), Lines.class, CopyOptions.create().ignoreCase()); List<Lines> lines = BeanUtil.copyToList(vo.getList(), Lines.class, CopyOptions.create().ignoreCase());
Date date = new Date(); Date date = new Date();
int i = linesDao.insertList(lines, CommonStatus.EFFECTIVE.value(), date, date); for (Lines line: lines){
if (i != 0) { line.setStatus(1);
cacheService.updateLineMap(); line.setCreateTime(date);
return Asserts.success("录入成功"); line.setUpdateTime(date);
} else { linesDao.insert(line);
return Asserts.error("录入失败");
} }
cacheService.updateLineMap();
return lines;
} }
/** /**

@ -49,7 +49,7 @@ public interface DyLevelService {
*/ */
ServiceBody<TerminalPhotosModel> getLastTowerList(String requestIp, LastTowerVo vo); ServiceBody<TerminalPhotosModel> getLastTowerList(String requestIp, LastTowerVo vo);
ServiceBody<String> add(DyLevel vo); void add(DyLevel vo);
ServiceBody<String> delete(LineIdVo vo); ServiceBody<String> delete(LineIdVo vo);

@ -32,7 +32,7 @@ public interface LineService {
* *
* @return * @return
*/ */
ServiceBody<String> addLine(LineVo vo); List<Lines> addLine(LineVo vo);
/** /**
* 线 * 线

Loading…
Cancel
Save