DMallPersonGroupHourCountDataDao.java 2.55 KB
package com.viontech.keliu.dao;

import com.viontech.keliu.entity.DMallPersonGroupDayCountData;
import com.viontech.keliu.entity.DMallPersonGroupHourCountData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: zhuhai
 * Date: 2023-03-28
 * Time: 19:32
 */
@Repository
public class DMallPersonGroupHourCountDataDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    private static final String SQL_INSERT = "insert into d_mall_person_group_hour_count_data(mall_id,count_date,total_person_num,staff_num,customer_num,customer_adult_num,customer_child_num,customer_alone,customer_group,count_time,hour) values(?,?,?,?,?,?,?,?,?,?,?)";

    private static final String SQL_QUERY = "select id, mall_id,count_date,total_person_num,staff_num,customer_num,customer_adult_num,customer_child_num,customer_alone,customer_group,count_time,hour from d_mall_person_group_hour_count_data where count_date=? and mall_id = ? and count_time= ?";

    private static final String SQL_UPDATE = "update d_mall_person_group_hour_count_data set total_person_num = ?, staff_num = ?, customer_num = ?, customer_adult_num = ?, customer_child_num = ?, customer_alone = ?, customer_group = ? where id = ?";
    public void create(DMallPersonGroupHourCountData countData) {
        jdbcTemplate.update(SQL_INSERT, countData.getMallId(), countData.getCountDate(), countData.getTotalPersonNum(), countData.getStaffNum(), countData.getCustomerNum(), countData.getCustomerAdultNum(), countData.getCustomerChildNum(), countData.getCustomerAlone(), countData.getCustomerGroup(), countData.getCountTime(), countData.getHour());
    }

    public List<DMallPersonGroupHourCountData> selectByMallIdAndCountDate(Long mallId, Date countDate, Date countTime) {
        RowMapper<DMallPersonGroupHourCountData> rowMapper = new BeanPropertyRowMapper<>(DMallPersonGroupHourCountData.class);
        return jdbcTemplate.query(SQL_QUERY, rowMapper, countDate, mallId, countTime);
    }

    public void update(DMallPersonGroupHourCountData countData) {
        jdbcTemplate.update(SQL_UPDATE, countData.getTotalPersonNum(), countData.getStaffNum(), countData.getCustomerNum(), countData.getCustomerAdultNum(), countData.getCustomerChildNum(), countData.getCustomerAlone(), countData.getCustomerGroup(), countData.getId());
    }

}