feat(module/feed): 支持前端原料管理面板

添加对前端原料管理页面的支持
This commit is contained in:
2026-01-18 14:57:59 +08:00
parent d3f4b6a700
commit 3ea03e3c19
7 changed files with 135 additions and 69 deletions

View File

@@ -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;
}
}

View File

@@ -3,6 +3,7 @@ package com.zhyc.module.feed.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize; 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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@@ -24,17 +25,14 @@ import com.zhyc.common.core.page.TableDataInfo;
* 原料Controller * 原料Controller
* *
* @author HashMap * @author HashMap
* @date 2025-08-11 * @date 2026-01-16
*/ */
@RestController @RestController
@RequestMapping("/feed/material") @RequestMapping("/feed/material")
public class SgMaterialController extends BaseController public class SgMaterialController extends BaseController
{ {
private final ISgMaterialService sgMaterialService; @Autowired
private ISgMaterialService sgMaterialService;
public SgMaterialController(ISgMaterialService sgMaterialService) {
this.sgMaterialService = sgMaterialService;
}
/** /**
* 查询原料列表 * 查询原料列表
@@ -57,7 +55,7 @@ public class SgMaterialController extends BaseController
public void export(HttpServletResponse response, SgMaterial sgMaterial) public void export(HttpServletResponse response, SgMaterial sgMaterial)
{ {
List<SgMaterial> list = sgMaterialService.selectSgMaterialList(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, "原料数据"); util.exportExcel(response, list, "原料数据");
} }
@@ -98,7 +96,7 @@ public class SgMaterialController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('feed:material:remove')") @PreAuthorize("@ss.hasPermi('feed:material:remove')")
@Log(title = "原料", businessType = BusinessType.DELETE) @Log(title = "原料", businessType = BusinessType.DELETE)
@DeleteMapping("/{materialIds}") @DeleteMapping("/{materialIds}")
public AjaxResult remove(@PathVariable String[] materialIds) public AjaxResult remove(@PathVariable String[] materialIds)
{ {
return toAjax(sgMaterialService.deleteSgMaterialByMaterialIds(materialIds)); return toAjax(sgMaterialService.deleteSgMaterialByMaterialIds(materialIds));

View File

@@ -1,15 +1,68 @@
package com.zhyc.module.feed.domain; 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 com.zhyc.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
@Setter /**
@Getter * 原料对象 sg_material
public class SgMaterial extends BaseEntity { *
* @author HashMap
* @date 2026-01-16
*/
public class SgMaterial extends BaseEntity
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 原料编码 */
@Excel(name = "原料编码")
private String materialId; private String materialId;
/** 原料名称 */
@Excel(name = "原料名称")
private String materialName; 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();
}
} }

View File

@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
* 原料Mapper接口 * 原料Mapper接口
* *
* @author HashMap * @author HashMap
* @date 2025-08-11 * @date 2026-01-16
*/ */
@Mapper @Mapper
public interface SgMaterialMapper public interface SgMaterialMapper

View File

@@ -7,7 +7,7 @@ import com.zhyc.module.feed.domain.SgMaterial;
* 原料Service接口 * 原料Service接口
* *
* @author HashMap * @author HashMap
* @date 2025-08-11 * @date 2026-01-16
*/ */
public interface ISgMaterialService public interface ISgMaterialService
{ {
@@ -17,7 +17,7 @@ public interface ISgMaterialService
* @param materialId 原料主键 * @param materialId 原料主键
* @return 原料 * @return 原料
*/ */
SgMaterial selectSgMaterialByMaterialId(String materialId); public SgMaterial selectSgMaterialByMaterialId(String materialId);
/** /**
* 查询原料列表 * 查询原料列表
@@ -25,7 +25,7 @@ public interface ISgMaterialService
* @param sgMaterial 原料 * @param sgMaterial 原料
* @return 原料集合 * @return 原料集合
*/ */
List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial); public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial);
/** /**
* 新增原料 * 新增原料
@@ -33,7 +33,7 @@ public interface ISgMaterialService
* @param sgMaterial 原料 * @param sgMaterial 原料
* @return 结果 * @return 结果
*/ */
int insertSgMaterial(SgMaterial sgMaterial); public int insertSgMaterial(SgMaterial sgMaterial);
/** /**
* 修改原料 * 修改原料
@@ -41,7 +41,7 @@ public interface ISgMaterialService
* @param sgMaterial 原料 * @param sgMaterial 原料
* @return 结果 * @return 结果
*/ */
int updateSgMaterial(SgMaterial sgMaterial); public int updateSgMaterial(SgMaterial sgMaterial);
/** /**
* 批量删除原料 * 批量删除原料
@@ -49,7 +49,7 @@ public interface ISgMaterialService
* @param materialIds 需要删除的原料主键集合 * @param materialIds 需要删除的原料主键集合
* @return 结果 * @return 结果
*/ */
int deleteSgMaterialByMaterialIds(String[] materialIds); public int deleteSgMaterialByMaterialIds(String[] materialIds);
/** /**
* 删除原料信息 * 删除原料信息
@@ -57,5 +57,5 @@ public interface ISgMaterialService
* @param materialId 原料主键 * @param materialId 原料主键
* @return 结果 * @return 结果
*/ */
int deleteSgMaterialByMaterialId(String materialId); public int deleteSgMaterialByMaterialId(String materialId);
} }

View File

@@ -2,6 +2,7 @@ package com.zhyc.module.feed.service.impl;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgMaterialMapper; import com.zhyc.module.feed.mapper.SgMaterialMapper;
import com.zhyc.module.feed.domain.SgMaterial; import com.zhyc.module.feed.domain.SgMaterial;
@@ -11,16 +12,12 @@ import com.zhyc.module.feed.service.ISgMaterialService;
* 原料Service业务层处理 * 原料Service业务层处理
* *
* @author HashMap * @author HashMap
* @date 2025-08-11 * @date 2026-01-16
*/ */
@Service @Service
public class SgMaterialServiceImpl implements ISgMaterialService public class SgMaterialServiceImpl implements ISgMaterialService {
{ @Autowired
private final SgMaterialMapper sgMaterialMapper; private SgMaterialMapper sgMaterialMapper;
public SgMaterialServiceImpl(SgMaterialMapper sgMaterialMapper) {
this.sgMaterialMapper = sgMaterialMapper;
}
/** /**
* 查询原料 * 查询原料
@@ -29,8 +26,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 原料 * @return 原料
*/ */
@Override @Override
public SgMaterial selectSgMaterialByMaterialId(String materialId) public SgMaterial selectSgMaterialByMaterialId(String materialId) {
{
return sgMaterialMapper.selectSgMaterialByMaterialId(materialId); return sgMaterialMapper.selectSgMaterialByMaterialId(materialId);
} }
@@ -41,8 +37,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 原料 * @return 原料
*/ */
@Override @Override
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial) public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial) {
{
return sgMaterialMapper.selectSgMaterialList(sgMaterial); return sgMaterialMapper.selectSgMaterialList(sgMaterial);
} }
@@ -53,8 +48,10 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertSgMaterial(SgMaterial sgMaterial) public int insertSgMaterial(SgMaterial sgMaterial) {
{ if (sgMaterialMapper.selectSgMaterialByMaterialId(sgMaterial.getMaterialId()) != null) {
throw new RuntimeException("重复的编码或名称");
}
return sgMaterialMapper.insertSgMaterial(sgMaterial); return sgMaterialMapper.insertSgMaterial(sgMaterial);
} }
@@ -65,8 +62,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateSgMaterial(SgMaterial sgMaterial) public int updateSgMaterial(SgMaterial sgMaterial) {
{
return sgMaterialMapper.updateSgMaterial(sgMaterial); return sgMaterialMapper.updateSgMaterial(sgMaterial);
} }
@@ -77,8 +73,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSgMaterialByMaterialIds(String[] materialIds) public int deleteSgMaterialByMaterialIds(String[] materialIds) {
{
return sgMaterialMapper.deleteSgMaterialByMaterialIds(materialIds); return sgMaterialMapper.deleteSgMaterialByMaterialIds(materialIds);
} }
@@ -89,8 +84,7 @@ public class SgMaterialServiceImpl implements ISgMaterialService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteSgMaterialByMaterialId(String materialId) public int deleteSgMaterialByMaterialId(String materialId) {
{
return sgMaterialMapper.deleteSgMaterialByMaterialId(materialId); return sgMaterialMapper.deleteSgMaterialByMaterialId(materialId);
} }
} }

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhyc.module.feed.mapper.SgMaterialMapper"> <mapper namespace="com.zhyc.module.feed.mapper.SgMaterialMapper">
<resultMap type="SgMaterial" id="SgMaterialResult"> <resultMap type="SgMaterial" id="SgMaterialResult">
@@ -31,15 +31,15 @@
<insert id="insertSgMaterial" parameterType="SgMaterial"> <insert id="insertSgMaterial" parameterType="SgMaterial">
insert into sg_material insert into sg_material
<trim prefix="(" suffix=")" suffixOverrides=","> <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="materialName != null and materialName != ''">material_name,</if>
<if test="isGranular != null">is_granular,</if> <if test="isGranular != null">is_granular,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <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="materialName != null and materialName != ''">#{materialName},</if>
<if test="isGranular != null">#{isGranular},</if> <if test="isGranular != null">#{isGranular},</if>
</trim> </trim>
</insert> </insert>
<update id="updateSgMaterial" parameterType="SgMaterial"> <update id="updateSgMaterial" parameterType="SgMaterial">