提交 4f94774e 编写于 作者: Q qinyingjie

fix:mybatis-plus自动生成代码

上级 9306a2c1
......@@ -124,6 +124,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.kwan.springbootkwan.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo;
import com.kwan.springbootkwan.service.AdsDimFinancialYearWeekInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* (AdsDimFinancialYearWeekInfo)表控制层
*
* @author makejava
* @since 2022-12-22 17:25:11
*/
@RestController
@RequestMapping("adsDimFinancialYearWeekInfo")
public class AdsDimFinancialYearWeekInfoController {
/**
* 服务对象
*/
@Resource
private AdsDimFinancialYearWeekInfoService adsDimFinancialYearWeekInfoService;
/**
* 通过主键查询单条数据
*/
@GetMapping("/{financialYear}/{financialYearWeek}")
public List<AdsDimFinancialYearWeekInfo> selectOne(@PathVariable Integer financialYear, @PathVariable Integer financialYearWeek) {
return this.adsDimFinancialYearWeekInfoService.list(new QueryWrapper<AdsDimFinancialYearWeekInfo>()
.ne("financial_year", financialYear)
.ne("financial_year_week", financialYearWeek)
);
}
}
\ No newline at end of file
package com.kwan.springbootkwan.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@TableName(value = "ads_dim_financial_year_week_info")
@ApiModel(value = "财年周")
public class AdsDimFinancialYearWeekInfo extends Model<AdsDimFinancialYearWeekInfo> {
//财年
private Integer financialYear;
//第n财年周
private Integer financialYearWeek;
//财年开始日期
private Date financialYearStart;
//财年结束日期
private Date financialYearEnd;
//周开始
private Date weekStartDay;
//周结束
private Date weekEndDay;
//财年周所在季节区间,0:跨9月1号,1:3月到8月,2:9月到2月
private Integer weekInSeason;
public Integer getFinancialYear() {
return financialYear;
}
public void setFinancialYear(Integer financialYear) {
this.financialYear = financialYear;
}
public Integer getFinancialYearWeek() {
return financialYearWeek;
}
public void setFinancialYearWeek(Integer financialYearWeek) {
this.financialYearWeek = financialYearWeek;
}
public Date getFinancialYearStart() {
return financialYearStart;
}
public void setFinancialYearStart(Date financialYearStart) {
this.financialYearStart = financialYearStart;
}
public Date getFinancialYearEnd() {
return financialYearEnd;
}
public void setFinancialYearEnd(Date financialYearEnd) {
this.financialYearEnd = financialYearEnd;
}
public Date getWeekStartDay() {
return weekStartDay;
}
public void setWeekStartDay(Date weekStartDay) {
this.weekStartDay = weekStartDay;
}
public Date getWeekEndDay() {
return weekEndDay;
}
public void setWeekEndDay(Date weekEndDay) {
this.weekEndDay = weekEndDay;
}
public Integer getWeekInSeason() {
return weekInSeason;
}
public void setWeekInSeason(Integer weekInSeason) {
this.weekInSeason = weekInSeason;
}
}
package com.kwan.springbootkwan.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo;
import org.apache.ibatis.annotations.Mapper;
/**
* mapper文件
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/12/19 16:12
*/
@Mapper
public interface AdsDimFinancialYearWeekInfoMapper extends BaseMapper<AdsDimFinancialYearWeekInfo> {
}
package com.kwan.springbootkwan.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo;
/**
* (AdsDimFinancialYearWeekInfo)表服务接口
*
* @author makejava
* @since 2022-12-22 17:25:11
*/
public interface AdsDimFinancialYearWeekInfoService extends IService<AdsDimFinancialYearWeekInfo> {
}
package com.kwan.springbootkwan.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo;
import com.kwan.springbootkwan.mapper.AdsDimFinancialYearWeekInfoMapper;
import com.kwan.springbootkwan.service.AdsDimFinancialYearWeekInfoService;
import org.springframework.stereotype.Service;
/**
* (AdsDimFinancialYearWeekInfo)表服务实现类
*
* @author makejava
* @since 2022-12-22 17:25:11
*/
@Service("adsDimFinancialYearWeekInfoService")
public class AdsDimFinancialYearWeekInfoServiceImpl extends ServiceImpl<AdsDimFinancialYearWeekInfoMapper, AdsDimFinancialYearWeekInfo> implements AdsDimFinancialYearWeekInfoService {
}
......@@ -49,9 +49,9 @@ spring:
# mysql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 15671628341Qwe.
password: 716288qwe
#mybatis-plus配置
mybatis-plus:
......
<?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.kwan.springbootkwan.mapper.AdsDimFinancialYearWeekInfoDao">
<resultMap type="com.kwan.springbootkwan.entity.AdsDimFinancialYearWeekInfo" id="AdsDimFinancialYearWeekInfoMap">
<result property="financialYear" column="financial_year" jdbcType="INTEGER"/>
<result property="financialYearWeek" column="financial_year_week" jdbcType="INTEGER"/>
<result property="financialYearStart" column="financial_year_start" jdbcType="TIMESTAMP"/>
<result property="financialYearEnd" column="financial_year_end" jdbcType="TIMESTAMP"/>
<result property="weekStartDay" column="week_start_day" jdbcType="TIMESTAMP"/>
<result property="weekEndDay" column="week_end_day" jdbcType="TIMESTAMP"/>
<result property="weekInSeason" column="week_in_season" jdbcType="INTEGER"/>
</resultMap>
<!-- 批量插入 -->
<insert id="insertBatch" keyProperty="" useGeneratedKeys="true">
insert into kwan.ads_dim_financial_year_week_info(financial_year, financial_year_week, financial_year_start, financial_year_end, week_start_day, week_end_day, week_in_season)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.financialYear}, #{entity.financialYearWeek}, #{entity.financialYearStart}, #{entity.financialYearEnd}, #{entity.weekStartDay}, #{entity.weekEndDay}, #{entity.weekInSeason})
</foreach>
</insert>
<!-- 批量插入或按主键更新 -->
<insert id="insertOrUpdateBatch" keyProperty="" useGeneratedKeys="true">
insert into kwan.ads_dim_financial_year_week_info(financial_year, financial_year_week, financial_year_start, financial_year_end, week_start_day, week_end_day, week_in_season)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.financialYear}, #{entity.financialYearWeek}, #{entity.financialYearStart}, #{entity.financialYearEnd}, #{entity.weekStartDay}, #{entity.weekEndDay}, #{entity.weekInSeason})
</foreach>
on duplicate key update
financial_year = values(financial_year) , financial_year_week = values(financial_year_week) , financial_year_start = values(financial_year_start) , financial_year_end = values(financial_year_end) , week_start_day = values(week_start_day) , week_end_day = values(week_end_day) , week_in_season = values(week_in_season) </insert>
</mapper>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册