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;
|
||||
@@ -24,17 +25,14 @@ 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, "原料数据");
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* 原料Mapper接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
@Mapper
|
||||
public interface SgMaterialMapper
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.zhyc.module.feed.domain.SgMaterial;
|
||||
* 原料Service接口
|
||||
*
|
||||
* @author HashMap
|
||||
* @date 2025-08-11
|
||||
* @date 2026-01-16
|
||||
*/
|
||||
public interface ISgMaterialService
|
||||
{
|
||||
@@ -17,7 +17,7 @@ public interface ISgMaterialService
|
||||
* @param materialId 原料主键
|
||||
* @return 原料
|
||||
*/
|
||||
SgMaterial selectSgMaterialByMaterialId(String materialId);
|
||||
public SgMaterial selectSgMaterialByMaterialId(String materialId);
|
||||
|
||||
/**
|
||||
* 查询原料列表
|
||||
@@ -25,7 +25,7 @@ public interface ISgMaterialService
|
||||
* @param sgMaterial 原料
|
||||
* @return 原料集合
|
||||
*/
|
||||
List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial);
|
||||
public List<SgMaterial> selectSgMaterialList(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 新增原料
|
||||
@@ -33,7 +33,7 @@ public interface ISgMaterialService
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSgMaterial(SgMaterial sgMaterial);
|
||||
public int insertSgMaterial(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 修改原料
|
||||
@@ -41,7 +41,7 @@ public interface ISgMaterialService
|
||||
* @param sgMaterial 原料
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSgMaterial(SgMaterial sgMaterial);
|
||||
public int updateSgMaterial(SgMaterial sgMaterial);
|
||||
|
||||
/**
|
||||
* 批量删除原料
|
||||
@@ -49,7 +49,7 @@ public interface ISgMaterialService
|
||||
* @param materialIds 需要删除的原料主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSgMaterialByMaterialIds(String[] materialIds);
|
||||
public int deleteSgMaterialByMaterialIds(String[] materialIds);
|
||||
|
||||
/**
|
||||
* 删除原料信息
|
||||
@@ -57,5 +57,5 @@ public interface ISgMaterialService
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@
|
||||
<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 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>
|
||||
|
||||
Reference in New Issue
Block a user