feat(module/feed): 支持前端原料管理面板
添加对前端原料管理页面的支持
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.zhyc.module.feed.controller.Exception;
|
||||
|
||||
import com.zhyc.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@ControllerAdvice
|
||||
public class MaterialExceptionHandler {
|
||||
|
||||
@ExceptionHandler({Exception.class, RuntimeException.class})
|
||||
public AjaxResult handleException(HttpServletRequest request, Exception ex) {
|
||||
AjaxResult ajaxResult = new AjaxResult();
|
||||
ajaxResult.put("message", ex.getMessage());
|
||||
ajaxResult.put("url", request.getRequestURL().toString());
|
||||
ajaxResult.put("status", 500);
|
||||
ajaxResult.put("error", "出现了一些错误");
|
||||
return ajaxResult;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zhyc.module.feed.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -22,19 +23,16 @@ import com.zhyc.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 原料Controller
|
||||
*
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feed/material")
|
||||
public class SgMaterialController extends BaseController
|
||||
{
|
||||
private final ISgMaterialService sgMaterialService;
|
||||
|
||||
public SgMaterialController(ISgMaterialService sgMaterialService) {
|
||||
this.sgMaterialService = sgMaterialService;
|
||||
}
|
||||
@Autowired
|
||||
private ISgMaterialService sgMaterialService;
|
||||
|
||||
/**
|
||||
* 查询原料列表
|
||||
@@ -57,7 +55,7 @@ public class SgMaterialController extends BaseController
|
||||
public void export(HttpServletResponse response, SgMaterial sgMaterial)
|
||||
{
|
||||
List<SgMaterial> list = sgMaterialService.selectSgMaterialList(sgMaterial);
|
||||
ExcelUtil<SgMaterial> util = new ExcelUtil<>(SgMaterial.class);
|
||||
ExcelUtil<SgMaterial> util = new ExcelUtil<SgMaterial>(SgMaterial.class);
|
||||
util.exportExcel(response, list, "原料数据");
|
||||
}
|
||||
|
||||
@@ -98,7 +96,7 @@ public class SgMaterialController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('feed:material:remove')")
|
||||
@Log(title = "原料", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{materialIds}")
|
||||
@DeleteMapping("/{materialIds}")
|
||||
public AjaxResult remove(@PathVariable String[] materialIds)
|
||||
{
|
||||
return toAjax(sgMaterialService.deleteSgMaterialByMaterialIds(materialIds));
|
||||
|
||||
@@ -1,15 +1,68 @@
|
||||
package com.zhyc.module.feed.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.zhyc.common.annotation.Excel;
|
||||
import com.zhyc.common.core.domain.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SgMaterial extends BaseEntity {
|
||||
/**
|
||||
* 原料对象 sg_material
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
public class SgMaterial extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 原料编码 */
|
||||
@Excel(name = "原料编码")
|
||||
private String materialId;
|
||||
|
||||
/** 原料名称 */
|
||||
@Excel(name = "原料名称")
|
||||
private String materialName;
|
||||
private String isGranular;
|
||||
|
||||
/** 颗粒料 */
|
||||
@Excel(name = "颗粒料")
|
||||
private Integer isGranular;
|
||||
|
||||
public void setMaterialId(String materialId)
|
||||
{
|
||||
this.materialId = materialId;
|
||||
}
|
||||
|
||||
public String getMaterialId()
|
||||
{
|
||||
return materialId;
|
||||
}
|
||||
|
||||
public void setMaterialName(String materialName)
|
||||
{
|
||||
this.materialName = materialName;
|
||||
}
|
||||
|
||||
public String getMaterialName()
|
||||
{
|
||||
return materialName;
|
||||
}
|
||||
|
||||
public void setIsGranular(Integer isGranular)
|
||||
{
|
||||
this.isGranular = isGranular;
|
||||
}
|
||||
|
||||
public Integer getIsGranular()
|
||||
{
|
||||
return isGranular;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("materialId", getMaterialId())
|
||||
.append("materialName", getMaterialName())
|
||||
.append("isGranular", getIsGranular())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 原料Mapper接口
|
||||
*
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
@Mapper
|
||||
public interface SgMaterialMapper
|
||||
public interface SgMaterialMapper
|
||||
{
|
||||
/**
|
||||
* 查询原料
|
||||
*
|
||||
*
|
||||
* @param materialId 原料主键
|
||||
* @return 原料
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ public interface SgMaterialMapper
|
||||
|
||||
/**
|
||||
* 查询原料列表
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 原料集合
|
||||
*/
|
||||
@@ -31,7 +31,7 @@ public interface SgMaterialMapper
|
||||
|
||||
/**
|
||||
* 新增原料
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ public interface SgMaterialMapper
|
||||
|
||||
/**
|
||||
* 修改原料
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ public interface SgMaterialMapper
|
||||
|
||||
/**
|
||||
* 删除原料
|
||||
*
|
||||
*
|
||||
* @param materialId 原料主键
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -55,7 +55,7 @@ public interface SgMaterialMapper
|
||||
|
||||
/**
|
||||
* 批量删除原料
|
||||
*
|
||||
*
|
||||
* @param materialIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@@ -5,57 +5,57 @@ import com.zhyc.module.feed.domain.SgMaterial;
|
||||
|
||||
/**
|
||||
* 原料Service接口
|
||||
*
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
public interface ISgMaterialService
|
||||
public interface ISgMaterialService
|
||||
{
|
||||
/**
|
||||
* 查询原料
|
||||
*
|
||||
*
|
||||
* @param materialId 原料主键
|
||||
* @return 原料
|
||||
*/
|
||||
SgMaterial selectSgMaterialByMaterialId(String materialId);
|
||||
public SgMaterial selectSgMaterialByMaterialId(String materialId);
|
||||
|
||||
/**
|
||||
* 查询原料列表
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 原料集合
|
||||
*/
|
||||
List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial);
|
||||
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 新增原料
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgMaterial(SgMaterial sgMaterial);
|
||||
public int insertSgMaterial(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 修改原料
|
||||
*
|
||||
*
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgMaterial(SgMaterial sgMaterial);
|
||||
public int updateSgMaterial(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 批量删除原料
|
||||
*
|
||||
*
|
||||
* @param materialIds 需要删除的原料主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgMaterialByMaterialIds(String[] materialIds);
|
||||
public int deleteSgMaterialByMaterialIds(String[] materialIds);
|
||||
|
||||
/**
|
||||
* 删除原料信息
|
||||
*
|
||||
*
|
||||
* @param materialId 原料主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgMaterialByMaterialId(String materialId);
|
||||
public int deleteSgMaterialByMaterialId(String materialId);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhyc.module.feed.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.zhyc.module.feed.mapper.SgMaterialMapper;
|
||||
import com.zhyc.module.feed.domain.SgMaterial;
|
||||
@@ -11,16 +12,12 @@ import com.zhyc.module.feed.service.ISgMaterialService;
|
||||
* 原料Service业务层处理
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
@Service
|
||||
public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
{
|
||||
private final SgMaterialMapper sgMaterialMapper;
|
||||
|
||||
public SgMaterialServiceImpl(SgMaterialMapper sgMaterialMapper) {
|
||||
this.sgMaterialMapper = sgMaterialMapper;
|
||||
}
|
||||
public class SgMaterialServiceImpl implements ISgMaterialService {
|
||||
@Autowired
|
||||
private SgMaterialMapper sgMaterialMapper;
|
||||
|
||||
/**
|
||||
* 查询原料
|
||||
@@ -29,8 +26,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 原料
|
||||
*/
|
||||
@Override
|
||||
public SgMaterial selectSgMaterialByMaterialId(String materialId)
|
||||
{
|
||||
public SgMaterial selectSgMaterialByMaterialId(String materialId) {
|
||||
return sgMaterialMapper.selectSgMaterialByMaterialId(materialId);
|
||||
}
|
||||
|
||||
@@ -41,8 +37,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 原料
|
||||
*/
|
||||
@Override
|
||||
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial)
|
||||
{
|
||||
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial) {
|
||||
return sgMaterialMapper.selectSgMaterialList(sgMaterial);
|
||||
}
|
||||
|
||||
@@ -53,8 +48,10 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSgMaterial(SgMaterial sgMaterial)
|
||||
{
|
||||
public int insertSgMaterial(SgMaterial sgMaterial) {
|
||||
if (sgMaterialMapper.selectSgMaterialByMaterialId(sgMaterial.getMaterialId()) != null) {
|
||||
throw new RuntimeException("重复的编码或名称");
|
||||
}
|
||||
return sgMaterialMapper.insertSgMaterial(sgMaterial);
|
||||
}
|
||||
|
||||
@@ -65,8 +62,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSgMaterial(SgMaterial sgMaterial)
|
||||
{
|
||||
public int updateSgMaterial(SgMaterial sgMaterial) {
|
||||
return sgMaterialMapper.updateSgMaterial(sgMaterial);
|
||||
}
|
||||
|
||||
@@ -77,8 +73,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgMaterialByMaterialIds(String[] materialIds)
|
||||
{
|
||||
public int deleteSgMaterialByMaterialIds(String[] materialIds) {
|
||||
return sgMaterialMapper.deleteSgMaterialByMaterialIds(materialIds);
|
||||
}
|
||||
|
||||
@@ -89,8 +84,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSgMaterialByMaterialId(String materialId)
|
||||
{
|
||||
public int deleteSgMaterialByMaterialId(String materialId) {
|
||||
return sgMaterialMapper.deleteSgMaterialByMaterialId(materialId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhyc.module.feed.mapper.SgMaterialMapper">
|
||||
|
||||
|
||||
<resultMap type="SgMaterial" id="SgMaterialResult">
|
||||
<result property="materialId" column="material_id" />
|
||||
<result property="materialName" column="material_name" />
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
<select id="selectSgMaterialList" parameterType="SgMaterial" resultMap="SgMaterialResult">
|
||||
<include refid="selectSgMaterialVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
|
||||
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
|
||||
<if test="isGranular != null "> and is_granular = #{isGranular}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectSgMaterialByMaterialId" parameterType="String" resultMap="SgMaterialResult">
|
||||
<include refid="selectSgMaterialVo"/>
|
||||
where material_id = #{materialId}
|
||||
@@ -31,15 +31,15 @@
|
||||
<insert id="insertSgMaterial" parameterType="SgMaterial">
|
||||
insert into sg_material
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="materialId != null">material_id,</if>
|
||||
<if test="materialId != null and materialId != ''">material_id,</if>
|
||||
<if test="materialName != null and materialName != ''">material_name,</if>
|
||||
<if test="isGranular != null">is_granular,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="materialId != null">#{materialId},</if>
|
||||
<if test="materialId != null and materialId != ''">#{materialId},</if>
|
||||
<if test="materialName != null and materialName != ''">#{materialName},</if>
|
||||
<if test="isGranular != null">#{isGranular},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSgMaterial" parameterType="SgMaterial">
|
||||
@@ -56,7 +56,7 @@
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSgMaterialByMaterialIds" parameterType="String">
|
||||
delete from sg_material where material_id in
|
||||
delete from sg_material where material_id in
|
||||
<foreach item="materialId" collection="array" open="(" separator="," close=")">
|
||||
#{materialId}
|
||||
</foreach>
|
||||
|
||||
Reference in New Issue
Block a user