分页查询,逻辑删除

ackage com.jingsheng.mes.sys.controller;

import com.github.pagehelper.PageInfo;
import com.jingsheng.common.model.model.BaseResponse;
import com.jingsheng.mes.dal.entity.mysql.LcjBoardEfficiency;
import com.jingsheng.mes.dal.request.board.LcjBoardEfficiencyRequest;
import com.jingsheng.mes.dal.request.board.LcjUpdateRequest;
import com.jingsheng.mes.sys.service.LcjKaoHeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/lcjKaoHe")
@Api(value = "设备效率", tags = {"LiuChangjian考核任务"})
public class LcjKaoHeController {

    @Autowired
    private LcjKaoHeService lcjKaoHeService;
    
 	@GetMapping("/selectAll")
    public BaseResponse<PageInfo<LcjBoardEfficiency>> getList(LcjBoardEfficiencyRequest request) {
        return new BaseResponse<>(lcjKaoHeService.selectKaoHeList(request));
    }
    @PutMapping("/updateIsDel/{id}")
    @ApiOperation(value = "updateIsDel", notes = "逻辑删除数据")
    public BaseResponse<Boolean> updateIsDel(@PathVariable(value = "id") Long id) {
        return new BaseResponse(lcjKaoHeService.updateIsDel(id));
    }
}
package com.jingsheng.mes.sys.service;

import com.github.pagehelper.PageInfo;
import com.jingsheng.mes.dal.entity.mysql.LcjBoardEfficiency;
import com.jingsheng.mes.dal.request.board.LcjBoardEfficiencyRequest;
import com.jingsheng.mes.dal.request.board.LcjUpdateRequest;

public interface LcjKaoHeService {

PageInfo<LcjBoardEfficiency> selectKaoHeList(LcjBoardEfficiencyRequest request);

Boolean updateIsDel(Long id);
}
package com.jingsheng.mes.sys.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jingsheng.mes.dal.entity.mysql.LcjBoardEfficiency;
import com.jingsheng.mes.dal.mapper.mysql.LcjBoardEfficiencyMapper;
import com.jingsheng.mes.dal.request.board.LcjBoardEfficiencyRequest;
import com.jingsheng.mes.dal.request.board.LcjUpdateRequest;
import com.jingsheng.mes.sys.service.LcjKaoHeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class LcjKaoHeServiceImpl implements LcjKaoHeService {

    @Autowired
    private LcjBoardEfficiencyMapper lcjBoardEfficiencyMapper;
	@Override
    public PageInfo<LcjBoardEfficiency> selectKaoHeList(LcjBoardEfficiencyRequest request) {
        Page<LcjBoardEfficiency> page = PageHelper.startPage(request.getPageNum(), request.getPageSize());
        List<LcjBoardEfficiency> list = lcjBoardEfficiencyMapper.selectGroupById(request);
        PageInfo<LcjBoardEfficiency> pageInfo = new PageInfo<>(page);
        pageInfo.setList(list);
        return pageInfo;
    }

	@Override
    public Boolean updateIsDel(Long id) {
        LcjBoardEfficiency lcjBoardEfficiency = new LcjBoardEfficiency();
        lcjBoardEfficiency.setId(id);
        lcjBoardEfficiency.setIsDel(1);
        return lcjBoardEfficiencyMapper.updateByPrimaryKeySelective(lcjBoardEfficiency) > 0;
    }
 }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jingsheng.mes.dal.mapper.mysql.LcjBoardEfficiencyMapper">
    <resultMap id="BaseResultMap" type="com.jingsheng.mes.dal.entity.mysql.LcjBoardEfficiency">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="scheduling_time" jdbcType="VARCHAR" property="schedulingTime" />
        <result column="efficiency_value" jdbcType="DECIMAL" property="efficiencyValue" />
        <result column="efficiency_target_value" jdbcType="INTEGER" property="efficiencyTargetValue" />
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
        <result column="equipment_operation_time" jdbcType="INTEGER" property="equipmentOperationTime" />
        <result column="equipment_startup_time" jdbcType="INTEGER" property="equipmentStartupTime" />
        <result column="is_del" jdbcType="INTEGER" property="isDel" />
    </resultMap>
    <select id="selectGroupById" resultMap="BaseResultMap">
        SELECT
        efficiency.id, efficiency.scheduling_time, efficiency.efficiency_value, efficiency.efficiency_target_value, efficiency.create_time, efficiency.update_time
        FROM
        lcj_board_efficiency efficiency
        LEFT JOIN js_scheduling_detail detail ON efficiency.scheduling_time = DATE_FORMAT(detail.scheduling_time, '%Y-%m-%d' )
        WHERE
        detail.scheduling_id = 1
        <if test="req.startTime != null and req.startTime != '' and req.endTime != null and req.endTime != '' ">
            and  DATE_FORMAT(detail.scheduling_time, '%Y-%m-%d' ) BETWEEN #{req.startTime} AND #{req.endTime}
        </if>
            and efficiency.is_del = 0
        ORDER BY DATE_FORMAT(detail.scheduling_time, '%Y-%m-%d' ) desc
    </select>

</mapper>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值