基础管理
This commit is contained in:
parent
c4b5a29bd6
commit
af9c62b454
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.bonus.base.controller;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.TbProDepart;
|
||||||
|
import com.bonus.base.service.TbProDepartService;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目部(TbProDepart)表控制层
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-09 11:09:30
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/tbProDepart")
|
||||||
|
public class TbProDepartController extends BaseController {
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private TbProDepartService tbProDepartService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param tbProDepart 筛选条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@GetMapping
|
||||||
|
public TableDataInfo queryByPage(TbProDepart tbProDepart) {
|
||||||
|
startPage();
|
||||||
|
List<TbProDepart> list = tbProDepartService.queryByPage(tbProDepart);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 单条数据
|
||||||
|
*/
|
||||||
|
@GetMapping("{id}")
|
||||||
|
public AjaxResult queryById(@PathVariable("id") Long id) {
|
||||||
|
return AjaxResult.success(tbProDepartService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实体
|
||||||
|
* @return 新增结果
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody TbProDepart tbProDepart) {
|
||||||
|
return AjaxResult.success(tbProDepartService.insert(tbProDepart));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实体
|
||||||
|
* @return 编辑结果
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public ResponseEntity<TbProDepart> edit(TbProDepart tbProDepart) {
|
||||||
|
return ResponseEntity.ok(this.tbProDepartService.update(tbProDepart));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 删除是否成功
|
||||||
|
*/
|
||||||
|
@DeleteMapping
|
||||||
|
public ResponseEntity<Boolean> deleteById(Long id) {
|
||||||
|
return ResponseEntity.ok(this.tbProDepartService.deleteById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.bonus.base.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目部(TbProDepart)实体类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-09 11:09:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TbProDepart implements Serializable {
|
||||||
|
private static final long serialVersionUID = -99327586927571942L;
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 项目部名称
|
||||||
|
*/
|
||||||
|
private String departName;
|
||||||
|
/**
|
||||||
|
* 项目部类型(字典表)
|
||||||
|
*/
|
||||||
|
private String departType;
|
||||||
|
/**
|
||||||
|
* 地区(区域表 type==0)
|
||||||
|
*/
|
||||||
|
private Long areaId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地区名称
|
||||||
|
*/
|
||||||
|
private String areaName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 负责人
|
||||||
|
*/
|
||||||
|
private String headUser;
|
||||||
|
/**
|
||||||
|
* 负责人联系电话(sm4)加密(查询展示脱敏)
|
||||||
|
*/
|
||||||
|
private String headUserPhone;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remarks;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private Long createUser;
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 修改人
|
||||||
|
*/
|
||||||
|
private Long updateUser;
|
||||||
|
/**
|
||||||
|
* 是否删除(0, 正常 1删除)
|
||||||
|
*/
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.bonus.base.mapper;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.TbProDepart;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目部(TbProDepart)表数据库访问层
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-09 11:09:31
|
||||||
|
*/
|
||||||
|
public interface TbProDepartMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
TbProDepart queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定行数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 查询条件
|
||||||
|
* @param pageable 分页对象
|
||||||
|
* @return 对象列表
|
||||||
|
*/
|
||||||
|
List<TbProDepart> queryAllByLimit(TbProDepart tbProDepart, @Param("pageable") Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计总行数
|
||||||
|
*
|
||||||
|
* @param tbProDepart 查询条件
|
||||||
|
* @return 总行数
|
||||||
|
*/
|
||||||
|
long count(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insert(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增数据(MyBatis原生foreach方法)
|
||||||
|
*
|
||||||
|
* @param entities List<TbProDepart> 实例对象列表
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int insertBatch(@Param("entities") List<TbProDepart> entities);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||||
|
*
|
||||||
|
* @param entities List<TbProDepart> 实例对象列表
|
||||||
|
* @return 影响行数
|
||||||
|
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||||
|
*/
|
||||||
|
int insertOrUpdateBatch(@Param("entities") List<TbProDepart> entities);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int update(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 影响行数
|
||||||
|
*/
|
||||||
|
int deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param tbProDepart
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TbProDepart> queryByPage(TbProDepart tbProDepart);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.bonus.base.service;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.TbProDepart;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目部(TbProDepart)表服务接口
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-09 11:09:35
|
||||||
|
*/
|
||||||
|
public interface TbProDepartService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
TbProDepart queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param tbProDepart 筛选条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
List<TbProDepart> queryByPage(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
int insert(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
TbProDepart update(TbProDepart tbProDepart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean deleteById(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.bonus.base.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.TbProDepart;
|
||||||
|
import com.bonus.base.mapper.TbProDepartMapper;
|
||||||
|
import com.bonus.base.service.TbProDepartService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目部(TbProDepart)表服务实现类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-09 11:09:37
|
||||||
|
*/
|
||||||
|
@Service("tbProDepartService")
|
||||||
|
public class TbProDepartServiceImpl implements TbProDepartService {
|
||||||
|
@Resource
|
||||||
|
private TbProDepartMapper tbProDepartDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ID查询单条数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TbProDepart queryById(Long id) {
|
||||||
|
return tbProDepartDao.queryById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param tbProDepart 筛选条件
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TbProDepart> queryByPage(TbProDepart tbProDepart) {
|
||||||
|
return tbProDepartDao.queryByPage(tbProDepart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insert(TbProDepart tbProDepart) {
|
||||||
|
return tbProDepartDao.insert(tbProDepart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*
|
||||||
|
* @param tbProDepart 实例对象
|
||||||
|
* @return 实例对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TbProDepart update(TbProDepart tbProDepart) {
|
||||||
|
this.tbProDepartDao.update(tbProDepart);
|
||||||
|
return this.queryById(tbProDepart.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean deleteById(Long id) {
|
||||||
|
return this.tbProDepartDao.deleteById(id) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,12 +3,15 @@ server:
|
||||||
port: 18083
|
port: 18083
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
servlet:
|
datasource:
|
||||||
multipart:
|
dynamic:
|
||||||
# 文件最大
|
primary: master
|
||||||
max-file-size: 20MB
|
datasource:
|
||||||
# 设置总上传数据总大小
|
master:
|
||||||
max-request-size: 20MB
|
url: jdbc:mysql://192.168.0.56:3306/safety_warn_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
|
username: Bonus@git
|
||||||
|
password: Passw0rd!
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: bonus-base
|
name: bonus-base
|
||||||
|
|
@ -17,16 +20,14 @@ spring:
|
||||||
active: dev
|
active: dev
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
username: nacos
|
|
||||||
password: nacos
|
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 192.168.0.14:8848
|
server-addr: 127.0.0.1:8848
|
||||||
namespace: 0cc70924-d088-4723-84c7-3d9a464e1bc3
|
namespace: 693e01a9-1dc4-4858-b1ae-439da3d35f66
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 192.168.0.14:8848
|
server-addr: 127.0.0.1:8848
|
||||||
namespace: 0cc70924-d088-4723-84c7-3d9a464e1bc3
|
namespace: 693e01a9-1dc4-4858-b1ae-439da3d35f66
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,247 @@
|
||||||
|
<?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.bonus.base.mapper.TbProDepartMapper">
|
||||||
|
|
||||||
|
<!--查询指定行数据-->
|
||||||
|
<select id="queryAllByLimit" resultMap="TbProDepartMap">
|
||||||
|
select
|
||||||
|
id, depart_name, depart_type, area_id, head_user, head_user_phone, remarks, create_time, create_user,
|
||||||
|
update_time, update_user, del_flag
|
||||||
|
from tb_pro_depart
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="departName != null and departName != ''">
|
||||||
|
and depart_name = #{departName}
|
||||||
|
</if>
|
||||||
|
<if test="departType != null and departType != ''">
|
||||||
|
and depart_type = #{departType}
|
||||||
|
</if>
|
||||||
|
<if test="areaId != null">
|
||||||
|
and area_id = #{areaId}
|
||||||
|
</if>
|
||||||
|
<if test="headUser != null and headUser != ''">
|
||||||
|
and head_user = #{headUser}
|
||||||
|
</if>
|
||||||
|
<if test="headUserPhone != null and headUserPhone != ''">
|
||||||
|
and head_user_phone = #{headUserPhone}
|
||||||
|
</if>
|
||||||
|
<if test="remarks != null and remarks != ''">
|
||||||
|
and remarks = #{remarks}
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
and create_time = #{createTime}
|
||||||
|
</if>
|
||||||
|
<if test="createUser != null">
|
||||||
|
and create_user = #{createUser}
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
and update_time = #{updateTime}
|
||||||
|
</if>
|
||||||
|
<if test="updateUser != null">
|
||||||
|
and update_user = #{updateUser}
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
and del_flag = #{delFlag}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
limit #{pageable.offset}, #{pageable.pageSize}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--统计总行数-->
|
||||||
|
<select id="count" resultType="java.lang.Long">
|
||||||
|
select count(1)
|
||||||
|
from tb_pro_depart
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="departName != null and departName != ''">
|
||||||
|
and depart_name = #{departName}
|
||||||
|
</if>
|
||||||
|
<if test="departType != null and departType != ''">
|
||||||
|
and depart_type = #{departType}
|
||||||
|
</if>
|
||||||
|
<if test="areaId != null">
|
||||||
|
and area_id = #{areaId}
|
||||||
|
</if>
|
||||||
|
<if test="headUser != null and headUser != ''">
|
||||||
|
and head_user = #{headUser}
|
||||||
|
</if>
|
||||||
|
<if test="headUserPhone != null and headUserPhone != ''">
|
||||||
|
and head_user_phone = #{headUserPhone}
|
||||||
|
</if>
|
||||||
|
<if test="remarks != null and remarks != ''">
|
||||||
|
and remarks = #{remarks}
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
and create_time = #{createTime}
|
||||||
|
</if>
|
||||||
|
<if test="createUser != null">
|
||||||
|
and create_user = #{createUser}
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
and update_time = #{updateTime}
|
||||||
|
</if>
|
||||||
|
<if test="updateUser != null">
|
||||||
|
and update_user = #{updateUser}
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
and del_flag = #{delFlag}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryByPage" resultType="com.bonus.base.domain.TbProDepart">
|
||||||
|
select
|
||||||
|
tpd.id as id,
|
||||||
|
depart_name as departName, depart_type as departType, area_id as areaId, ta.area_name as areaName,head_user as
|
||||||
|
headUser,
|
||||||
|
head_user_phone as headUserPhone, remarks as remarks, create_time as createTime, create_user as createUser,
|
||||||
|
update_time as updateTime,
|
||||||
|
update_user as updateUser, del_flag as delFlag
|
||||||
|
from tb_pro_depart tpd
|
||||||
|
left join tb_area ta on tpd.area_id = ta.id
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
tpd.id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="areaName != null and areaName != ''">
|
||||||
|
and ta.area_name like concat('%',#{areaName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="departName != null and departName != ''">
|
||||||
|
and depart_name like concat('%',#{departName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="headUser != null and headUser != ''">
|
||||||
|
and head_user like concat('%',#{headUser},'%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--查询单个-->
|
||||||
|
<select id="queryById" resultType="com.bonus.base.domain.TbProDepart">
|
||||||
|
select tpd.id as id,
|
||||||
|
depart_name as departName,
|
||||||
|
depart_type as departType,
|
||||||
|
area_id as areaId,
|
||||||
|
ta.area_name as areaName,
|
||||||
|
head_user as
|
||||||
|
headUser,
|
||||||
|
head_user_phone as headUserPhone,
|
||||||
|
remarks as remarks,
|
||||||
|
create_time as createTime,
|
||||||
|
create_user as createUser,
|
||||||
|
update_time as updateTime,
|
||||||
|
update_user as updateUser,
|
||||||
|
del_flag as delFlag
|
||||||
|
from tb_pro_depart tpd
|
||||||
|
left join tb_areata on tpd.area_id = ta.id
|
||||||
|
where tpd.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!--新增所有列-->
|
||||||
|
<insert id="insert">
|
||||||
|
INSERT INTO tb_pro_depart
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="departName != null">depart_name,</if>
|
||||||
|
<if test="departType != null">depart_type,</if>
|
||||||
|
<if test="areaId != null">area_id,</if>
|
||||||
|
<if test="headUser != null">head_user,</if>
|
||||||
|
<if test="headUserPhone != null">head_user_phone,</if>
|
||||||
|
<if test="remarks != null">remarks,</if>
|
||||||
|
create_time,
|
||||||
|
<if test="createUser != null">create_user,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="updateUser != null">update_user,</if>
|
||||||
|
del_flag
|
||||||
|
</trim>
|
||||||
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="departName != null">#{departName},</if>
|
||||||
|
<if test="departType != null">#{departType},</if>
|
||||||
|
<if test="areaId != null">#{areaId},</if>
|
||||||
|
<if test="headUser != null">#{headUser},</if>
|
||||||
|
<if test="headUserPhone != null">#{headUserPhone},</if>
|
||||||
|
<if test="remarks != null">#{remarks},</if>
|
||||||
|
NOW(),
|
||||||
|
<if test="createUser != null">#{createUser},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="updateUser != null">#{updateUser},</if>
|
||||||
|
0
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
insert into tb_pro_depart(depart_name, depart_type, area_id, head_user, head_user_phone, remarks, create_time,
|
||||||
|
create_user, update_time, update_user, del_flag)
|
||||||
|
values
|
||||||
|
<foreach collection="entities" item="entity" separator=",">
|
||||||
|
(#{entity.departName}, #{entity.departType}, #{entity.areaId}, #{entity.headUser}, #{entity.headUserPhone},
|
||||||
|
#{entity.remarks}, #{entity.createTime}, #{entity.createUser}, #{entity.updateTime}, #{entity.updateUser},
|
||||||
|
#{entity.delFlag})
|
||||||
|
</foreach>
|
||||||
|
on duplicate key update
|
||||||
|
depart_name = values(depart_name),
|
||||||
|
depart_type = values(depart_type),
|
||||||
|
area_id = values(area_id),
|
||||||
|
head_user = values(head_user),
|
||||||
|
head_user_phone = values(head_user_phone),
|
||||||
|
remarks = values(remarks),
|
||||||
|
create_time = values(create_time),
|
||||||
|
create_user = values(create_user),
|
||||||
|
update_time = values(update_time),
|
||||||
|
update_user = values(update_user),
|
||||||
|
del_flag = values(del_flag)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--通过主键修改数据-->
|
||||||
|
<update id="update">
|
||||||
|
update tb_pro_depart
|
||||||
|
<set>
|
||||||
|
<if test="departName != null and departName != ''">
|
||||||
|
depart_name = #{departName},
|
||||||
|
</if>
|
||||||
|
<if test="departType != null and departType != ''">
|
||||||
|
depart_type = #{departType},
|
||||||
|
</if>
|
||||||
|
<if test="areaId != null">
|
||||||
|
area_id = #{areaId},
|
||||||
|
</if>
|
||||||
|
<if test="headUser != null and headUser != ''">
|
||||||
|
head_user = #{headUser},
|
||||||
|
</if>
|
||||||
|
<if test="headUserPhone != null and headUserPhone != ''">
|
||||||
|
head_user_phone = #{headUserPhone},
|
||||||
|
</if>
|
||||||
|
<if test="remarks != null and remarks != ''">
|
||||||
|
remarks = #{remarks},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time = #{createTime},
|
||||||
|
</if>
|
||||||
|
<if test="createUser != null">
|
||||||
|
create_user = #{createUser},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime},
|
||||||
|
</if>
|
||||||
|
<if test="updateUser != null">
|
||||||
|
update_user = #{updateUser},
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
del_flag = #{delFlag},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键删除-->
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete
|
||||||
|
from tb_pro_depart
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
Loading…
Reference in New Issue