去冲冗余参数,修改对应mapper
This commit is contained in:
parent
d6c8a97237
commit
1de0d396b1
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.bonus.material.supplier.controller;
|
||||||
|
|
||||||
|
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.material.supplier.domain.MaSupplier;
|
||||||
|
import com.bonus.material.supplier.service.MaSupplierService;
|
||||||
|
import com.bonus.material.ma.vo.TreeSelect;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Api(value = "厂家管理", tags = "厂家管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ma_supplier_info")
|
||||||
|
public class MaSupplierController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaSupplierService maSupplierService;
|
||||||
|
|
||||||
|
@ApiOperation("分页列表")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult list(MaSupplier query) {
|
||||||
|
startPage();
|
||||||
|
List<MaSupplier> list = maSupplierService.list(query);
|
||||||
|
TableDataInfo dataTable = getDataTable(list);
|
||||||
|
return AjaxResult.success(dataTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("详情")
|
||||||
|
@GetMapping("/{supplierId}")
|
||||||
|
public AjaxResult detail(@PathVariable Long supplierId) {
|
||||||
|
return AjaxResult.success(maSupplierService.getById(supplierId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("新增")
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody MaSupplier bean) {
|
||||||
|
int i = maSupplierService.add(bean);
|
||||||
|
return i > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("修改")
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody MaSupplier bean) {
|
||||||
|
int i = maSupplierService.edit(bean);
|
||||||
|
return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除")
|
||||||
|
@DeleteMapping("/{supplierId}")
|
||||||
|
public AjaxResult del(@PathVariable Long supplierId) {
|
||||||
|
int i = maSupplierService.remove(supplierId);
|
||||||
|
return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("厂家下拉框")
|
||||||
|
@GetMapping("/select")
|
||||||
|
public AjaxResult options(){
|
||||||
|
List<TreeSelect> options = maSupplierService.listEnabled().stream().map(s -> {
|
||||||
|
TreeSelect t = new TreeSelect();
|
||||||
|
t.setId(s.getSupplierId());
|
||||||
|
t.setLabel(s.getSupplierName());
|
||||||
|
return t;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return AjaxResult.success(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.bonus.material.supplier.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物资厂家表实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MaSupplier extends BaseEntity {
|
||||||
|
|
||||||
|
@ApiModelProperty("厂家主键ID")
|
||||||
|
private Long supplierId;
|
||||||
|
|
||||||
|
@ApiModelProperty("厂家编号(如:SUP202510001)")
|
||||||
|
private String supplierCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("厂家名称")
|
||||||
|
private String supplierName;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系人")
|
||||||
|
private String contactPerson;
|
||||||
|
|
||||||
|
@ApiModelProperty("联系电话")
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("厂家地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@ApiModelProperty("资质信息或营业执照编号")
|
||||||
|
private String qualification;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1启用,0停用)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.bonus.material.supplier.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.supplier.domain.MaSupplier;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface MaSupplierMapper {
|
||||||
|
|
||||||
|
MaSupplier selectById(@Param("supplierId") Long supplierId);
|
||||||
|
|
||||||
|
List<MaSupplier> list(@Param("supplierCode") String supplierCode,
|
||||||
|
@Param("supplierName") String supplierName,
|
||||||
|
@Param("status") Integer status);
|
||||||
|
|
||||||
|
int insert(MaSupplier supplier);
|
||||||
|
|
||||||
|
int update(MaSupplier supplier);
|
||||||
|
|
||||||
|
int deleteById(@Param("supplierId") Long supplierId);
|
||||||
|
|
||||||
|
List<MaSupplier> listEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.bonus.material.supplier.service;
|
||||||
|
|
||||||
|
import com.bonus.material.supplier.domain.MaSupplier;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface MaSupplierService {
|
||||||
|
MaSupplier getById(Long supplierId);
|
||||||
|
|
||||||
|
List<MaSupplier> list(MaSupplier query);
|
||||||
|
|
||||||
|
int add(MaSupplier supplier);
|
||||||
|
|
||||||
|
int edit(MaSupplier supplier);
|
||||||
|
|
||||||
|
int remove(Long supplierId);
|
||||||
|
|
||||||
|
List<MaSupplier> listEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.bonus.material.supplier.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.material.supplier.domain.MaSupplier;
|
||||||
|
import com.bonus.material.supplier.mapper.MaSupplierMapper;
|
||||||
|
import com.bonus.material.supplier.service.MaSupplierService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MaSupplierServiceImpl implements MaSupplierService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaSupplierMapper maSupplierMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaSupplier getById(Long supplierId) {
|
||||||
|
return maSupplierMapper.selectById(supplierId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MaSupplier> list(MaSupplier query) {
|
||||||
|
return maSupplierMapper.list(query.getSupplierCode(), query.getSupplierName(), query.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int add(MaSupplier supplier) {
|
||||||
|
return maSupplierMapper.insert(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int edit(MaSupplier supplier) {
|
||||||
|
return maSupplierMapper.update(supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int remove(Long supplierId) {
|
||||||
|
return maSupplierMapper.deleteById(supplierId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MaSupplier> listEnabled() {
|
||||||
|
return maSupplierMapper.listEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?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.material.supplier.mapper.MaSupplierMapper">
|
||||||
|
|
||||||
|
<resultMap id="MaSupplierResult" type="com.bonus.material.supplier.domain.MaSupplier">
|
||||||
|
<id property="supplierId" column="supplier_id"/>
|
||||||
|
<result property="supplierCode" column="supplier_code"/>
|
||||||
|
<result property="supplierName" column="supplier_name"/>
|
||||||
|
<result property="contactPerson" column="contact_person"/>
|
||||||
|
<result property="contactPhone" column="contact_phone"/>
|
||||||
|
<result property="address" column="address"/>
|
||||||
|
<result property="qualification" column="qualification"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
supplier_id, supplier_code, supplier_name, contact_person, contact_phone,
|
||||||
|
address, qualification, `status`, remark, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectById" resultMap="MaSupplierResult">
|
||||||
|
select <include refid="Base_Column_List"/>
|
||||||
|
from ma_supplier
|
||||||
|
where supplier_id = #{supplierId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="listEnabled" resultMap="MaSupplierResult">
|
||||||
|
select <include refid="Base_Column_List"/>
|
||||||
|
from ma_supplier
|
||||||
|
where `status` = 1
|
||||||
|
order by supplier_name asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultMap="MaSupplierResult">
|
||||||
|
select <include refid="Base_Column_List"/>
|
||||||
|
from ma_supplier
|
||||||
|
<where>
|
||||||
|
<if test="supplierCode != null and supplierCode != ''">
|
||||||
|
and supplier_code like concat('%', #{supplierCode}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="supplierName != null and supplierName != ''">
|
||||||
|
and supplier_name like concat('%', #{supplierName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by update_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insert" useGeneratedKeys="true" keyProperty="supplierId">
|
||||||
|
insert into ma_supplier (
|
||||||
|
supplier_code, supplier_name, contact_person, contact_phone,
|
||||||
|
address, qualification, status, remark, create_time, update_time
|
||||||
|
) values (
|
||||||
|
#{supplierCode}, #{supplierName}, #{contactPerson}, #{contactPhone},
|
||||||
|
#{address}, #{qualification}, #{status}, #{remark}, now(), now()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="update">
|
||||||
|
update ma_supplier
|
||||||
|
<set>
|
||||||
|
<if test="supplierCode != null">supplier_code = #{supplierCode},</if>
|
||||||
|
<if test="supplierName != null">supplier_name = #{supplierName},</if>
|
||||||
|
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
|
||||||
|
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
|
||||||
|
<if test="address != null">address = #{address},</if>
|
||||||
|
<if test="qualification != null">qualification = #{qualification},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
update_time = now()
|
||||||
|
</set>
|
||||||
|
where supplier_id = #{supplierId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteById">
|
||||||
|
delete from ma_supplier where supplier_id = #{supplierId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue