往来单位管理增删改查
This commit is contained in:
parent
c589a94b7a
commit
b371749792
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.bonus.base.controller;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.BmCustomer;
|
||||||
|
import com.bonus.base.service.IBmCustomerService;
|
||||||
|
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 com.bonus.common.log.annotation.SysLog;
|
||||||
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往来单位 信息操作处理
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/customer")
|
||||||
|
@Slf4j
|
||||||
|
public class BmCustomerController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IBmCustomerService customerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取往来单位列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("bm:customer:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@SysLog(title = "往来单位", businessType = OperaType.QUERY,logType = 0,module = "基础管理->往来单位")
|
||||||
|
public TableDataInfo list(BmCustomer bmCustomer) {
|
||||||
|
try{
|
||||||
|
startPage();
|
||||||
|
List<BmCustomer> list = customerService.selectCustomerList(bmCustomer);
|
||||||
|
return getDataTable(list);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return getDataTableError(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据往来单位编号获取详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("bm:customer:query")
|
||||||
|
@GetMapping(value = "/{customerId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long customerId) {
|
||||||
|
try{
|
||||||
|
return success(customerService.selectCustomerById(customerId));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return error("系统异常");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增往来单位
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("bm:customer:add")
|
||||||
|
@PostMapping
|
||||||
|
@SysLog(title = "往来单位", businessType = OperaType.INSERT,logType = 0,module = "基础管理->往来单位")
|
||||||
|
public AjaxResult add(@Validated @RequestBody BmCustomer customer) {
|
||||||
|
try{
|
||||||
|
// customer.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(customerService.insertCustomer(customer));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return error("系统异常");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改往来单位
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("bm:customer:edit")
|
||||||
|
@PutMapping
|
||||||
|
@SysLog(title = "往来单位", businessType = OperaType.UPDATE,logType = 0,module = "基础管理->往来单位")
|
||||||
|
public AjaxResult edit(@Validated @RequestBody BmCustomer customer) {
|
||||||
|
try{
|
||||||
|
// customer.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(customerService.updateCustomer(customer));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return error("系统异常");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除往来单位
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("bm:customer:remove")
|
||||||
|
@DeleteMapping("/{customerIds}")
|
||||||
|
@SysLog(title = "往来单位", businessType = OperaType.DELETE,logType = 0,module = "基础管理->往来单位")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] customerIds) {
|
||||||
|
try{
|
||||||
|
return toAjax(customerService.deleteCustomerByIds(customerIds));
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.toString(),e);
|
||||||
|
}
|
||||||
|
return error("系统异常");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,9 @@ import java.io.Serializable;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class BmCustomer implements Serializable {
|
public class BmCustomer implements Serializable {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.bonus.base.mapper;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.BmCustomer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
public interface BmCustomerMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询往来单位信息
|
||||||
|
*
|
||||||
|
* @param customerId 往来单位ID
|
||||||
|
* @return 往来单位信息
|
||||||
|
*/
|
||||||
|
BmCustomer selectCustomerById(Long customerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询往来单位列表
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 往来单位集合
|
||||||
|
*/
|
||||||
|
List<BmCustomer> selectCustomerList(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增往来单位
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertCustomer(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改往来单位
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateCustomer(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除往来单位
|
||||||
|
*
|
||||||
|
* @param customerId 往来单位ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteCustomerById(Long customerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除往来单位信息
|
||||||
|
*
|
||||||
|
* @param customerIds 需要删除的往来单位ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteCustomerByIds(Long[] customerIds);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.bonus.base.service;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.BmCustomer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往来单位 服务层
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
public interface IBmCustomerService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询往来单位信息
|
||||||
|
*
|
||||||
|
* @param customerId 往来单位ID
|
||||||
|
* @return 往来单位信息
|
||||||
|
*/
|
||||||
|
public BmCustomer selectCustomerById(Long customerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询往来单位列表
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 往来单位集合
|
||||||
|
*/
|
||||||
|
public List<BmCustomer> selectCustomerList(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增往来单位
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertCustomer(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改往来单位
|
||||||
|
*
|
||||||
|
* @param customer 往来单位信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateCustomer(BmCustomer customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除往来单位信息
|
||||||
|
*
|
||||||
|
* @param customerId 往来单位ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteCustomerById(Long customerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除往来单位信息
|
||||||
|
*
|
||||||
|
* @param customerIds 需要删除的往来单位ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteCustomerByIds(Long[] customerIds);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.bonus.base.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.base.domain.BmCustomer;
|
||||||
|
import com.bonus.base.mapper.BmAgreementMapper;
|
||||||
|
import com.bonus.base.mapper.BmCustomerMapper;
|
||||||
|
import com.bonus.base.service.IBmCustomerService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往来单位 服务层实现
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BmCustomerServiceImpl implements IBmCustomerService
|
||||||
|
{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BmCustomerMapper bmCustomerMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BmCustomer selectCustomerById(Long customerId) {
|
||||||
|
return bmCustomerMapper.selectCustomerById(customerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BmCustomer> selectCustomerList(BmCustomer customer) {
|
||||||
|
return bmCustomerMapper.selectCustomerList(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertCustomer(BmCustomer customer) {
|
||||||
|
return bmCustomerMapper.insertCustomer(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateCustomer(BmCustomer customer) {
|
||||||
|
return bmCustomerMapper.updateCustomer(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteCustomerById(Long customerId) {
|
||||||
|
return bmCustomerMapper.deleteCustomerById(customerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteCustomerByIds(Long[] customerIds) {
|
||||||
|
return bmCustomerMapper.deleteCustomerByIds(customerIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
<?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.BmCustomerMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.bonus.base.domain.BmCustomer">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table bm_customer-->
|
||||||
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
|
<result column="type_id" jdbcType="INTEGER" property="typeId" />
|
||||||
|
<result column="company_id" jdbcType="INTEGER" property="companyId" />
|
||||||
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||||
|
<result column="material_clerk" jdbcType="VARCHAR" property="materialClerk" />
|
||||||
|
<result column="manager" jdbcType="VARCHAR" property="manager" />
|
||||||
|
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
||||||
|
<result column="is_active" jdbcType="CHAR" property="isActive" />
|
||||||
|
<result column="time" jdbcType="VARCHAR" property="time" />
|
||||||
|
<result column="legal_representative" jdbcType="VARCHAR" property="legalRepresentative" />
|
||||||
|
<result column="legal_phone" jdbcType="VARCHAR" property="legalPhone" />
|
||||||
|
<result column="sort_num" jdbcType="INTEGER" property="sortNum" />
|
||||||
|
<result column="company" jdbcType="VARCHAR" property="company" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, type_id, company_id, `name`, material_clerk, manager, phone, is_active, `time`,
|
||||||
|
legal_representative, legal_phone, sort_num, company
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectCustomerList" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from bm_customer
|
||||||
|
<where>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
AND name like concat('%', #{name}, '%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectCustomerById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from bm_customer
|
||||||
|
where id = #{id,jdbcType=INTEGER}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteCustomerById" parameterType="java.lang.Integer">
|
||||||
|
delete from bm_customer
|
||||||
|
where id = #{id,jdbcType=INTEGER}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="insertCustomer" keyColumn="id" keyProperty="id" parameterType="com.bonus.base.BmCustomer" useGeneratedKeys="true">
|
||||||
|
insert into bm_customer (type_id, company_id, `name`,
|
||||||
|
material_clerk, manager, phone,
|
||||||
|
is_active, `time`, legal_representative,
|
||||||
|
legal_phone, sort_num, company
|
||||||
|
)
|
||||||
|
values (#{typeId,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
|
||||||
|
#{materialClerk,jdbcType=VARCHAR}, #{manager,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
|
||||||
|
#{isActive,jdbcType=CHAR}, #{time,jdbcType=VARCHAR}, #{legalRepresentative,jdbcType=VARCHAR},
|
||||||
|
#{legalPhone,jdbcType=VARCHAR}, #{sortNum,jdbcType=INTEGER}, #{company,jdbcType=VARCHAR}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateCustomer" parameterType="com.bonus.base.domain.BmCustomer">
|
||||||
|
update bm_customer
|
||||||
|
set type_id = #{typeId,jdbcType=INTEGER},
|
||||||
|
company_id = #{companyId,jdbcType=INTEGER},
|
||||||
|
`name` = #{name,jdbcType=VARCHAR},
|
||||||
|
material_clerk = #{materialClerk,jdbcType=VARCHAR},
|
||||||
|
manager = #{manager,jdbcType=VARCHAR},
|
||||||
|
phone = #{phone,jdbcType=VARCHAR},
|
||||||
|
is_active = #{isActive,jdbcType=CHAR},
|
||||||
|
`time` = #{time,jdbcType=VARCHAR},
|
||||||
|
legal_representative = #{legalRepresentative,jdbcType=VARCHAR},
|
||||||
|
legal_phone = #{legalPhone,jdbcType=VARCHAR},
|
||||||
|
sort_num = #{sortNum,jdbcType=INTEGER},
|
||||||
|
company = #{company,jdbcType=VARCHAR}
|
||||||
|
where id = #{id,jdbcType=INTEGER}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteCustomerByIds">
|
||||||
|
|
||||||
|
delete from bm_customer where ID in
|
||||||
|
<foreach item="customerId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{customerId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue