物资厂家;新增修改接口名称唯一性判断
This commit is contained in:
parent
e53e7e09d0
commit
f079c81cd8
|
|
@ -49,6 +49,9 @@ public class BmAgreement extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value="工程id")
|
||||
private Integer project;
|
||||
|
||||
@ApiModelProperty(value="往来单位id")
|
||||
private Integer customer;
|
||||
|
||||
@ApiModelProperty(value="开始时间")
|
||||
@Excel(name = "开始日期")
|
||||
private String startTime;
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ public class BmAgreementController extends BaseController {
|
|||
@PostMapping(value = "/add")
|
||||
@RequiresPermissions("base:agreement:add")
|
||||
public ResultBean<Boolean> add(@RequestBody BmAgreement bmAgreement) {
|
||||
int result = this.bmAgreementService.insertSelective(bmAgreement);
|
||||
return result > 0 ? ResultBean.success(true) : ResultBean.error("新增失败");
|
||||
this.bmAgreementService.insertSelective(bmAgreement);
|
||||
return ResultBean.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class BmCustomerController extends BaseController {
|
|||
public AjaxResult add(@Validated @RequestBody BmCustomer customer) {
|
||||
try {
|
||||
// customer.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(customerService.insertCustomer(customer));
|
||||
return customerService.insertCustomer(customer);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ public class BmCustomerController extends BaseController {
|
|||
public AjaxResult edit(@Validated @RequestBody BmCustomer customer) {
|
||||
try {
|
||||
// customer.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(customerService.updateCustomer(customer));
|
||||
return customerService.updateCustomer(customer);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,6 @@ public class BmSupplierController extends BaseController {
|
|||
@RequiresPermissions("base:supplier:add")
|
||||
@PostMapping("/add")
|
||||
public ResultBean add(@RequestBody BmSupplier bmSupplier) {
|
||||
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
|
||||
bmSupplier.setCompanyId(Integer.parseInt(companyId.toString()));
|
||||
return bmSupplierService.insert(bmSupplier);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +81,7 @@ public class BmSupplierController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "编辑供应商管理数据")
|
||||
@RequiresPermissions("base:supplier:edit")
|
||||
@PutMapping("/update")
|
||||
@PostMapping("/update")
|
||||
public ResultBean edit(@RequestBody BmSupplier bmSupplier) {
|
||||
return bmSupplierService.update(bmSupplier);
|
||||
}
|
||||
|
|
@ -91,14 +89,14 @@ public class BmSupplierController extends BaseController {
|
|||
/**
|
||||
* 单个或批量删除数据
|
||||
*
|
||||
* @param ids 主键
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@ApiOperation(value = "删除供应商管理数据")
|
||||
@RequiresPermissions("base:supplier:remove")
|
||||
@PostMapping(value = "/{ids}")
|
||||
public ResultBean<Boolean> deleteById(@PathVariable("ids") Long[] ids) {
|
||||
int result = bmSupplierService.deleteById(ids);
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public ResultBean<Boolean> deleteById(@PathVariable("id") Integer id) {
|
||||
int result = bmSupplierService.deleteById(id);
|
||||
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "删除失败");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.base.mapper;
|
|||
|
||||
import com.bonus.base.api.domain.BmAgreement;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -62,4 +63,11 @@ public interface BmAgreementMapper {
|
|||
*/
|
||||
int updateByPrimaryKey(BmAgreement record);
|
||||
|
||||
/**
|
||||
* 根据客户id和项目id查询协议
|
||||
* @param customer
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
BmAgreement select(@Param(value ="customer") Integer customer, @Param(value ="project") Integer project);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,10 @@ public interface BmCustomerMapper {
|
|||
*/
|
||||
List<SysDeptTree> selectDeptTree(SysDeptTree sysDept);
|
||||
|
||||
/**
|
||||
* 根据名称查询
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
BmCustomer selectCustomerByName(String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,4 +63,11 @@ public interface BmCustomerTypeMapper {
|
|||
List<BmCustomerType> selectAll(BmCustomerType bmCustomerType);
|
||||
|
||||
int updateById(@Param("updated") BmCustomerType updated, @Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 根据名称查询
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
BmCustomerType selectCustomerByName(String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ public interface BmSupplierMapper {
|
|||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param ids 主键
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(@Param("array") Long[] ids);
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 通过名称查询单条数据
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.base.service;
|
||||
|
||||
import com.bonus.common.core.domain.ResultBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.bonus.base.api.domain.BmAgreement;
|
||||
|
|
@ -44,8 +45,14 @@ public class BmAgreementService{
|
|||
}
|
||||
|
||||
|
||||
public int insertSelective(BmAgreement record) {
|
||||
return bmAgreementMapper.insertSelective(record);
|
||||
public ResultBean insertSelective(BmAgreement record) {
|
||||
//根据单位和工程id去表中判断,去重
|
||||
BmAgreement bmAgreement = bmAgreementMapper.select(record.getCustomer(), record.getProject());
|
||||
if (bmAgreement != null) {
|
||||
return ResultBean.error("该租赁单位已关联该租赁工程,请修改后重新提交!");
|
||||
}
|
||||
int result = bmAgreementMapper.insertSelective(record);
|
||||
return result > 0 ? ResultBean.success("新建成功") : ResultBean.error("新建失败");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -54,8 +61,14 @@ public class BmAgreementService{
|
|||
}
|
||||
|
||||
|
||||
public int updateByPrimaryKeySelective(BmAgreement record) {
|
||||
return bmAgreementMapper.updateByPrimaryKeySelective(record);
|
||||
public ResultBean updateByPrimaryKeySelective(BmAgreement record) {
|
||||
//根据单位和工程id去表中判断,去重
|
||||
BmAgreement bmAgreement = bmAgreementMapper.select(record.getCustomer(), record.getProject());
|
||||
if (bmAgreement != null && !bmAgreement.getId().equals(record.getId())) {
|
||||
return ResultBean.error("该租赁单位已关联该租赁工程,请修改后重新提交!");
|
||||
}
|
||||
int result = bmAgreementMapper.updateByPrimaryKeySelective(record);
|
||||
return result > 0 ? ResultBean.success("修改成功") : ResultBean.error("修改失败");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.base.service;
|
||||
|
||||
import com.bonus.common.core.domain.ResultBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -40,8 +41,14 @@ public class BmCustomerTypeService{
|
|||
}
|
||||
|
||||
|
||||
public int insertSelective(BmCustomerType record) {
|
||||
return bmCustomerTypeMapper.insertSelective(record);
|
||||
public ResultBean insertSelective(BmCustomerType record) {
|
||||
//根据名称查询,去重
|
||||
BmCustomerType bmCustomerType = bmCustomerTypeMapper.selectCustomerByName(record.getName());
|
||||
if (bmCustomerType != null) {
|
||||
return ResultBean.error("单位类型名称重复");
|
||||
}
|
||||
int result = bmCustomerTypeMapper.insertSelective(record);
|
||||
return result > 0 ? ResultBean.success("添加成功") : ResultBean.error("添加失败");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -50,8 +57,14 @@ public class BmCustomerTypeService{
|
|||
}
|
||||
|
||||
|
||||
public int updateByPrimaryKeySelective(BmCustomerType record) {
|
||||
return bmCustomerTypeMapper.updateByPrimaryKeySelective(record);
|
||||
public ResultBean updateByPrimaryKeySelective(BmCustomerType record) {
|
||||
//根据名称查询,去重
|
||||
BmCustomerType bmCustomerType = bmCustomerTypeMapper.selectCustomerByName(record.getName());
|
||||
if (bmCustomerType != null && !bmCustomerType.getId().equals(record.getId())) {
|
||||
return ResultBean.error("单位类型名称重复");
|
||||
}
|
||||
int result = bmCustomerTypeMapper.updateByPrimaryKeySelective(record);
|
||||
return result > 0 ? ResultBean.success("添加成功") : ResultBean.error("添加失败");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ public interface BmSupplierService {
|
|||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param ids 主键
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
int deleteById(Long[] ids);
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.base.service;
|
|||
import com.bonus.base.api.domain.BmCustomer;
|
||||
import com.bonus.base.api.domain.SysDeptTree;
|
||||
import com.bonus.base.api.domain.TreeSelect;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ public interface IBmCustomerService
|
|||
* @param customer 往来单位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCustomer(BmCustomer customer);
|
||||
public AjaxResult insertCustomer(BmCustomer customer);
|
||||
|
||||
/**
|
||||
* 修改往来单位
|
||||
|
|
@ -43,7 +44,7 @@ public interface IBmCustomerService
|
|||
* @param customer 往来单位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCustomer(BmCustomer customer);
|
||||
public AjaxResult updateCustomer(BmCustomer customer);
|
||||
|
||||
/**
|
||||
* 删除往来单位信息
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.bonus.base.api.domain.TreeSelect;
|
|||
import com.bonus.base.mapper.BmCustomerMapper;
|
||||
import com.bonus.base.service.IBmCustomerService;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -37,13 +38,25 @@ public class BmCustomerServiceImpl implements IBmCustomerService
|
|||
}
|
||||
|
||||
@Override
|
||||
public int insertCustomer(BmCustomer customer) {
|
||||
return bmCustomerMapper.insertCustomer(customer);
|
||||
public AjaxResult insertCustomer(BmCustomer customer) {
|
||||
//根据单位名称查询,去重
|
||||
BmCustomer bmCustomer = bmCustomerMapper.selectCustomerByName(customer.getName());
|
||||
if (bmCustomer != null) {
|
||||
return AjaxResult.warn("单位名称已存在");
|
||||
}
|
||||
int result = bmCustomerMapper.insertCustomer(customer);
|
||||
return result > 0 ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCustomer(BmCustomer customer) {
|
||||
return bmCustomerMapper.updateCustomer(customer);
|
||||
public AjaxResult updateCustomer(BmCustomer customer) {
|
||||
//根据单位名称查询,去重
|
||||
BmCustomer bmCustomer = bmCustomerMapper.selectCustomerByName(customer.getName());
|
||||
if (bmCustomer != null && !bmCustomer.getId().equals(customer.getId())) {
|
||||
return AjaxResult.warn("单位名称已存在");
|
||||
}
|
||||
int result = bmCustomerMapper.updateCustomer(customer);
|
||||
return result > 0 ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ public class BmSupplierServiceImpl implements BmSupplierService {
|
|||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param ids 主键
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public int deleteById(Long[] ids) {
|
||||
return bmSupplierDao.deleteById(ids);
|
||||
public int deleteById(Integer id) {
|
||||
return bmSupplierDao.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,8 +75,17 @@
|
|||
</if>
|
||||
order by ba.sign_date desc
|
||||
</select>
|
||||
<select id="select" resultType="com.bonus.base.api.domain.BmAgreement">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from bm_agreement ba
|
||||
left join bm_project bp on ba.project = bp.id
|
||||
left join bm_customer bc on ba.customer = bc.id
|
||||
where ba.customer = #{customer}
|
||||
and ba.project = #{project}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
<!--@mbg.generated-->
|
||||
update bm_agreement set is_active = 0
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,14 @@
|
|||
from sys_dept d
|
||||
where d.del_flag = '0' and d.status = '0'
|
||||
</select>
|
||||
<select id="selectCustomerByName" resultType="com.bonus.base.api.domain.BmCustomer">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from bm_customer
|
||||
left join bm_customer_type bct on bct.id = bc.type_id
|
||||
left join sys_dept sd on sd.dept_id = bc.company_id
|
||||
where bc.is_active = '1' and bc.name = #{name}
|
||||
</select>
|
||||
|
||||
<delete id="deleteCustomerById" parameterType="java.lang.Integer">
|
||||
delete from bm_customer
|
||||
|
|
|
|||
|
|
@ -103,8 +103,15 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectCustomerByName" resultType="com.bonus.base.api.domain.BmCustomerType">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from bm_customer_type
|
||||
where IS_ACTIVE = '1'
|
||||
and `NAME` = #{name}
|
||||
</select>
|
||||
|
||||
<update id="updateById">
|
||||
<update id="updateById">
|
||||
<!--@mbg.generated-->
|
||||
update bm_customer_type
|
||||
<set>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<select id="queryAllByLimit" resultMap="BmSupplierMap">
|
||||
<include refid="selectMaSupplierInfoVo"/>
|
||||
where
|
||||
1 = 1 and is_active = 1
|
||||
is_active = '1'
|
||||
<if test="companyId != null">
|
||||
AND company_id = #{companyId}
|
||||
</if>
|
||||
|
|
@ -130,10 +130,7 @@
|
|||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
update bm_supplier set is_active = 0 where id in
|
||||
<foreach item="supplierId" collection="array" open="(" separator="," close=")">
|
||||
#{supplierId}
|
||||
</foreach>
|
||||
update bm_supplier set is_active = 0 where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue