机具供应商

This commit is contained in:
mashuai 2024-08-09 18:00:53 +08:00
parent 7e12da4b6d
commit 05643ca2a0
6 changed files with 603 additions and 0 deletions

View File

@ -0,0 +1,111 @@
package com.bonus.base.controller;
import com.bonus.base.domain.BmSupplier;
import com.bonus.base.service.BmSupplierService;
import com.bonus.base.utils.ResultBean;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 机具供应商管理(BmSupplier)表控制层
*
* @author mashuai
* @since 2024-08-09 13:07:22
*/
@RestController
@Api(tags = "供应商管理")
@RequestMapping("/bmSupplier")
public class BmSupplierController extends BaseController {
/**
* 服务对象
*/
@Resource
private BmSupplierService bmSupplierService;
/**
* 分页查询供应商列表
*
* @param bmSupplier 筛选条件
* @return 查询结果
*/
@ApiOperation(value = "分页查询供应商列表")
@GetMapping("/list")
public TableDataInfo queryByPage(BmSupplier bmSupplier) {
startPage();
List<BmSupplier> list = bmSupplierService.queryByPage(bmSupplier);
return getDataTable(list);
}
/**
* 通过主键查询单条数据,供修改回显数据使用
*
* @param id 主键
* @return 单条数据详情
*/
@ApiOperation(value = "查询供应商单条数据详情")
@GetMapping("/{id}")
public ResultBean<BmSupplier> queryById(@PathVariable("id") Integer id) {
return ResultBean.success(bmSupplierService.queryById(id));
}
/**
* 新增数据
*
* @param bmSupplier 实体
* @return 新增结果
*/
@ApiOperation(value = "新增供应商管理数据")
@PostMapping("/add")
public ResultBean<Boolean> add(@RequestBody BmSupplier bmSupplier) {
int result = bmSupplierService.insert(bmSupplier);
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "新增失败");
}
/**
* 编辑数据
*
* @param bmSupplier 实体
* @return 编辑结果
*/
@ApiOperation(value = "编辑供应商管理数据")
@PutMapping("/update")
public ResultBean<Boolean> edit(@RequestBody BmSupplier bmSupplier) {
int result = bmSupplierService.update(bmSupplier);
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "修改失败");
}
/**
* 单个或批量删除数据
*
* @param ids 主键
* @return 删除是否成功
*/
@ApiOperation(value = "删除供应商管理数据")
@PostMapping(value = "/delete/{ids}")
public ResultBean<Boolean> deleteById(@PathVariable("ids") Long[] ids) {
int result = bmSupplierService.deleteById(ids);
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "删除失败");
}
/**
* 导出供应商管理列表
*/
@ApiOperation(value = "导出查询机具供应商列表")
@PostMapping("/export")
public void export(HttpServletResponse response, BmSupplier bmSupplier)
{
List<BmSupplier> list = bmSupplierService.queryByPage(bmSupplier);
ExcelUtil<BmSupplier> util = new ExcelUtil<>(BmSupplier.class);
util.exportExcel(response, list, "机具供应商数据");
}
}

View File

@ -0,0 +1,173 @@
package com.bonus.base.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* 机具供应商管理(BmSupplier)实体类
*
* @author mashuai
* @since 2024-08-09 13:09:16
*/
@ApiModel("机具供应商管理(BmSupplier)实体类")
public class BmSupplier implements Serializable {
private static final long serialVersionUID = -22518958223068479L;
/** 主键id */
@ApiModelProperty(value = "主键id")
private Integer id;
/** 厂家名称 */
@ApiModelProperty(value = "厂家名称")
@Excel(name = "厂家名称")
private String name;
/** 厂家地址 */
@ApiModelProperty(value = "厂家地址")
@Excel(name = "厂家地址")
private String address;
/** 法人代表 */
@ApiModelProperty(value = "法人代表")
@Excel(name = "法人代表")
private String companyMan;
/** 主要联系人 */
@ApiModelProperty(value = "主要联系人")
@Excel(name = "主要联系人")
private String mainPerson;
/** 联系电话 */
@ApiModelProperty(value = "联系电话")
@Excel(name = "联系电话")
private String phone;
/** 主要经营范围 */
@ApiModelProperty(value = "主要经营范围")
@Excel(name = "主要经营范围")
private String scopeBusiness;
/** 营业执照 */
@ApiModelProperty(value = "营业执照")
@Excel(name = "营业执照")
private String picUrl;
/** 备注 */
@ApiModelProperty(value = "备注")
@Excel(name = "备注")
private String notes;
/** 是否启用 0不启用 1启用 */
@ApiModelProperty(value = "是否启用 0不启用 1启用")
private String isActive;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
/** 模糊查询关键字 */
@ApiModelProperty(value = "模糊查询关键字")
private String keyWord;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCompanyMan() {
return companyMan;
}
public void setCompanyMan(String companyMan) {
this.companyMan = companyMan;
}
public String getMainPerson() {
return mainPerson;
}
public void setMainPerson(String mainPerson) {
this.mainPerson = mainPerson;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getScopeBusiness() {
return scopeBusiness;
}
public void setScopeBusiness(String scopeBusiness) {
this.scopeBusiness = scopeBusiness;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getIsActive() {
return isActive;
}
public void setIsActive(String isActive) {
this.isActive = isActive;
}
public Integer getCompanyId() {
return companyId;
}
public void setCompanyId(Integer companyId) {
this.companyId = companyId;
}
public String getKeyWord() {
return keyWord;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}
}

View File

@ -0,0 +1,59 @@
package com.bonus.base.mapper;
import com.bonus.base.domain.BmSupplier;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 机具供应商管理(BmSupplier)表数据库访问层
*
* @author mashuai
* @since 2024-08-09 13:26:39
*/
@Mapper
public interface BmSupplierMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
BmSupplier queryById(Integer id);
/**
* 查询指定行数据
*
* @param bmSupplier 查询条件
* @return 对象列表
*/
List<BmSupplier> queryAllByLimit(BmSupplier bmSupplier);
/**
* 新增数据
*
* @param bmSupplier 实例对象
* @return 影响行数
*/
int insert(BmSupplier bmSupplier);
/**
* 修改数据
*
* @param bmSupplier 实例对象
* @return 影响行数
*/
int update(BmSupplier bmSupplier);
/**
* 通过主键删除数据
*
* @param ids 主键
* @return 影响行数
*/
int deleteById(@Param("array") Long[] ids);
}

View File

@ -0,0 +1,55 @@
package com.bonus.base.service;
import com.bonus.base.domain.BmSupplier;
import java.util.List;
/**
* 机具供应商管理(BmSupplier)表服务接口
*
* @author mashuai
* @since 2024-08-09 13:07:35
*/
public interface BmSupplierService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
BmSupplier queryById(Integer id);
/**
* 分页查询
*
* @param bmSupplier 筛选条件
* @return 查询结果
*/
List<BmSupplier> queryByPage(BmSupplier bmSupplier);
/**
* 新增数据
*
* @param bmSupplier 实例对象
* @return 实例对象
*/
int insert(BmSupplier bmSupplier);
/**
* 修改数据
*
* @param bmSupplier 实例对象
* @return 实例对象
*/
int update(BmSupplier bmSupplier);
/**
* 通过主键删除数据
*
* @param ids 主键
* @return 是否成功
*/
int deleteById(Long[] ids);
}

View File

@ -0,0 +1,76 @@
package com.bonus.base.service.impl;
import com.bonus.base.domain.BmSupplier;
import com.bonus.base.mapper.BmSupplierMapper;
import com.bonus.base.service.BmSupplierService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 机具供应商管理(BmSupplier)表服务实现类
*
* @author mashuai
* @since 2024-08-09 13:07:35
*/
@Service("bmSupplierService")
public class BmSupplierServiceImpl implements BmSupplierService {
@Resource
private BmSupplierMapper bmSupplierDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public BmSupplier queryById(Integer id) {
return bmSupplierDao.queryById(id);
}
/**
* 分页查询
*
* @param bmSupplier 筛选条件
* @return 查询结果
*/
@Override
public List<BmSupplier> queryByPage(BmSupplier bmSupplier) {
return bmSupplierDao.queryAllByLimit(bmSupplier);
}
/**
* 新增数据
*
* @param bmSupplier 实例对象
* @return 实例对象
*/
@Override
public int insert(BmSupplier bmSupplier) {
return bmSupplierDao.insert(bmSupplier);
}
/**
* 修改数据
*
* @param bmSupplier 实例对象
* @return 实例对象
*/
@Override
public int update(BmSupplier bmSupplier) {
return bmSupplierDao.update(bmSupplier);
}
/**
* 通过主键删除数据
*
* @param ids 主键
* @return 是否成功
*/
@Override
public int deleteById(Long[] ids) {
return bmSupplierDao.deleteById(ids);
}
}

View File

@ -0,0 +1,129 @@
<?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.BmSupplierMapper">
<resultMap type="com.bonus.base.domain.BmSupplier" id="BmSupplierMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="address" column="address" jdbcType="VARCHAR"/>
<result property="companyMan" column="company_man" jdbcType="VARCHAR"/>
<result property="mainPerson" column="main_person" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="scopeBusiness" column="scope_business" jdbcType="VARCHAR"/>
<result property="notes" column="notes" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="isActive" column="is_active" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="INTEGER"/>
</resultMap>
<sql id="selectMaSupplierInfoVo">
select id, name, address, company_man, main_person, phone, scope_business, notes, pic_url, is_active, company_id
from bm_supplier
</sql>
<!--查询单个-->
<select id="queryById" resultMap="BmSupplierMap">
<include refid="selectMaSupplierInfoVo"/>
where id = #{id} and is_active = 1
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BmSupplierMap">
<include refid="selectMaSupplierInfoVo"/>
where
1 = 1 and is_active = 1
<if test="companyId != null">
AND company_id = #{companyId}
</if>
<if test="keyWord!= null">
AND (
`name` LIKE CONCAT('%',#{keyWord},'%')
OR address LIKE CONCAT('%',#{keyWord},'%')
OR company_man LIKE CONCAT('%',#{keyWord},'%')
OR main_person LIKE CONCAT('%',#{keyWord},'%')
OR phone LIKE CONCAT('%',#{keyWord},'%')
OR scope_business LIKE CONCAT('%',#{keyWord},'%')
OR notes LIKE CONCAT('%',#{keyWord},'%')
OR pic_url LIKE CONCAT('%',#{keyWord},'%')
)
</if>
ORDER BY id DESC
</select>
<insert id="insert">
insert into bm_supplier(
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="address != null">address,</if>
<if test="companyMan != null">company_man,</if>
<if test="mainPerson != null">main_person,</if>
<if test="phone != null">phone,</if>
<if test="scopeBusiness != null">scope_business,</if>
<if test="notes != null">notes,</if>
<if test="picUrl != null">pic_url,</if>
<if test="isActive != null">is_active,</if>
<if test="companyId != null">company_id</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="address != null">#{address},</if>
<if test="companyMan != null">#{companyMan},</if>
<if test="mainPerson != null">#{mainPerson},</if>
<if test="phone != null">#{phone},</if>
<if test="scopeBusiness != null">#{scopeBusiness},</if>
<if test="notes != null">#{notes},</if>
<if test="picUrl != null">#{picUrl},</if>
"1",
<if test="companyId != null">#{companyId}</if>
</trim>
</insert>
<!--通过主键修改数据-->
<update id="update">
update bm_supplier
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="companyMan != null">
company_man = #{companyMan},
</if>
<if test="mainPerson != null">
main_person = #{mainPerson},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="scopeBusiness != null">
scope_business = #{scopeBusiness},
</if>
<if test="notes != null">
notes = #{notes},
</if>
<if test="picUrl != null">
pic_url = #{picUrl},
</if>
<if test="isActive != null">
is_active = #{isActive},
</if>
<if test="companyId != null">
company_id = #{companyId},
</if>
</trim>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
update bm_supplier set is_active = 0 where id in
<foreach item="supplierId" collection="array" open="(" separator="," close=")">
#{supplierId}
</foreach>
</delete>
</mapper>