diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BmCustomerController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BmCustomerController.java new file mode 100644 index 0000000..e5b1087 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/BmCustomerController.java @@ -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 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("系统异常"); + + } +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/BmCustomer.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/BmCustomer.java index 911d555..16fc935 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/BmCustomer.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/BmCustomer.java @@ -8,6 +8,9 @@ import java.io.Serializable; import lombok.Data; +/** + * @author bonus + */ @Data public class BmCustomer implements Serializable { /** @@ -89,4 +92,4 @@ public class BmCustomer implements Serializable { private String company; private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/BmCustomerMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/BmCustomerMapper.java new file mode 100644 index 0000000..5d07002 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/BmCustomerMapper.java @@ -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 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); +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/IBmCustomerService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/IBmCustomerService.java new file mode 100644 index 0000000..8d8c01e --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/IBmCustomerService.java @@ -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 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); +} diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/BmCustomerServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/BmCustomerServiceImpl.java new file mode 100644 index 0000000..19dd724 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/BmCustomerServiceImpl.java @@ -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 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); + } +} diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/BmCustomerMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/BmCustomerMapper.xml new file mode 100644 index 0000000..6b1b3b2 --- /dev/null +++ b/bonus-modules/bonus-base/src/main/resources/mapper/BmCustomerMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + id, type_id, company_id, `name`, material_clerk, manager, phone, is_active, `time`, + legal_representative, legal_phone, sort_num, company + + + + + + + + + delete from bm_customer + where id = #{id,jdbcType=INTEGER} + + + + 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} + ) + + + + 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} + + + + + delete from bm_customer where ID in + + #{customerId} + + + +