饮食知识库对象
This commit is contained in:
parent
516277aa80
commit
702b1f0bd4
@ -0,0 +1,91 @@
|
||||
package com.xinelu.manage.controller.basedietinfo;
|
||||
|
||||
import com.xinelu.common.annotation.Log;
|
||||
import com.xinelu.common.core.controller.BaseController;
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.core.page.TableDataInfo;
|
||||
import com.xinelu.common.enums.BusinessType;
|
||||
import com.xinelu.common.utils.poi.ExcelUtil;
|
||||
import com.xinelu.manage.domain.basedietinfo.BaseDietInfo;
|
||||
import com.xinelu.manage.service.basedietinfo.IBaseDietInfoService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饮食知识库Controller
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/baseDiet")
|
||||
public class BaseDietInfoController extends BaseController {
|
||||
@Resource
|
||||
private IBaseDietInfoService baseDietInfoService;
|
||||
|
||||
/**
|
||||
* 查询饮食知识库列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BaseDietInfo baseDietInfo) {
|
||||
startPage();
|
||||
List<BaseDietInfo> list = baseDietInfoService.selectBaseDietInfoList(baseDietInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出饮食知识库列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:export')")
|
||||
@Log(title = "饮食知识库", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BaseDietInfo baseDietInfo) {
|
||||
List<BaseDietInfo> list = baseDietInfoService.selectBaseDietInfoList(baseDietInfo);
|
||||
ExcelUtil<BaseDietInfo> util = new ExcelUtil<>(BaseDietInfo.class);
|
||||
util.exportExcel(response, list, "饮食知识库数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取饮食知识库详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(baseDietInfoService.selectBaseDietInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增饮食知识库
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:add')")
|
||||
@Log(title = "饮食知识库", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody BaseDietInfo baseDietInfo) {
|
||||
return toAjax(baseDietInfoService.insertBaseDietInfo(baseDietInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改饮食知识库
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:edit')")
|
||||
@Log(title = "饮食知识库", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody BaseDietInfo baseDietInfo) {
|
||||
return toAjax(baseDietInfoService.updateBaseDietInfo(baseDietInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除饮食知识库
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:baseDiet:remove')")
|
||||
@Log(title = "饮食知识库", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(baseDietInfoService.deleteBaseDietInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package com.xinelu.manage.domain.basedietinfo;
|
||||
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import com.xinelu.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 饮食知识库对象 base_diet_info
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "饮食知识库对象", description = "base_diet_info")
|
||||
public class BaseDietInfo extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 饮食建议名称
|
||||
*/
|
||||
@ApiModelProperty(value = "饮食建议名称")
|
||||
@Excel(name = "饮食建议名称")
|
||||
private String dietName;
|
||||
|
||||
/**
|
||||
* 饮食原则
|
||||
*/
|
||||
@ApiModelProperty(value = "饮食原则")
|
||||
@Excel(name = "饮食原则")
|
||||
private String dietPrinciple;
|
||||
|
||||
/**
|
||||
* 主食推荐
|
||||
*/
|
||||
@ApiModelProperty(value = "主食推荐")
|
||||
@Excel(name = "主食推荐")
|
||||
private String mainFood;
|
||||
|
||||
/**
|
||||
* 蔬菜推荐
|
||||
*/
|
||||
@ApiModelProperty(value = "蔬菜推荐")
|
||||
@Excel(name = "蔬菜推荐")
|
||||
private String vegetable;
|
||||
|
||||
/**
|
||||
* 水果推荐
|
||||
*/
|
||||
@ApiModelProperty(value = "水果推荐")
|
||||
@Excel(name = "水果推荐")
|
||||
private String fruit;
|
||||
|
||||
/**
|
||||
* 肉类推荐
|
||||
*/
|
||||
@ApiModelProperty(value = "肉类推荐")
|
||||
@Excel(name = "肉类推荐")
|
||||
private String meat;
|
||||
|
||||
/**
|
||||
* 饮食说明
|
||||
*/
|
||||
@ApiModelProperty(value = "饮食说明")
|
||||
@Excel(name = "饮食说明")
|
||||
private String dietRemark;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("dietName", getDietName())
|
||||
.append("dietPrinciple", getDietPrinciple())
|
||||
.append("mainFood", getMainFood())
|
||||
.append("vegetable", getVegetable())
|
||||
.append("fruit", getFruit())
|
||||
.append("meat", getMeat())
|
||||
.append("dietRemark", getDietRemark())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xinelu.manage.mapper.basedietinfo;
|
||||
|
||||
import com.xinelu.manage.domain.basedietinfo.BaseDietInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饮食知识库Mapper接口
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
public interface BaseDietInfoMapper {
|
||||
/**
|
||||
* 查询饮食知识库
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 饮食知识库
|
||||
*/
|
||||
BaseDietInfo selectBaseDietInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询饮食知识库列表
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 饮食知识库集合
|
||||
*/
|
||||
List<BaseDietInfo> selectBaseDietInfoList(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 新增饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
int insertBaseDietInfo(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 修改饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
int updateBaseDietInfo(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 删除饮食知识库
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBaseDietInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除饮食知识库
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBaseDietInfoByIds(Long[] ids);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xinelu.manage.service.basedietinfo;
|
||||
|
||||
import com.xinelu.manage.domain.basedietinfo.BaseDietInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饮食知识库Service接口
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
public interface IBaseDietInfoService {
|
||||
/**
|
||||
* 查询饮食知识库
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 饮食知识库
|
||||
*/
|
||||
BaseDietInfo selectBaseDietInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询饮食知识库列表
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 饮食知识库集合
|
||||
*/
|
||||
List<BaseDietInfo> selectBaseDietInfoList(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 新增饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
int insertBaseDietInfo(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 修改饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
int updateBaseDietInfo(BaseDietInfo baseDietInfo);
|
||||
|
||||
/**
|
||||
* 批量删除饮食知识库
|
||||
*
|
||||
* @param ids 需要删除的饮食知识库主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBaseDietInfoByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除饮食知识库信息
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteBaseDietInfoById(Long id);
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.xinelu.manage.service.basedietinfo.impl;
|
||||
|
||||
import com.xinelu.manage.domain.basedietinfo.BaseDietInfo;
|
||||
import com.xinelu.manage.mapper.basedietinfo.BaseDietInfoMapper;
|
||||
import com.xinelu.manage.service.basedietinfo.IBaseDietInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 饮食知识库Service业务层处理
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-05-17
|
||||
*/
|
||||
@Service
|
||||
public class BaseDietInfoServiceImpl implements IBaseDietInfoService {
|
||||
@Resource
|
||||
private BaseDietInfoMapper baseDietInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询饮食知识库
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 饮食知识库
|
||||
*/
|
||||
@Override
|
||||
public BaseDietInfo selectBaseDietInfoById(Long id) {
|
||||
return baseDietInfoMapper.selectBaseDietInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询饮食知识库列表
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 饮食知识库
|
||||
*/
|
||||
@Override
|
||||
public List<BaseDietInfo> selectBaseDietInfoList(BaseDietInfo baseDietInfo) {
|
||||
return baseDietInfoMapper.selectBaseDietInfoList(baseDietInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertBaseDietInfo(BaseDietInfo baseDietInfo) {
|
||||
baseDietInfo.setCreateTime(LocalDateTime.now());
|
||||
return baseDietInfoMapper.insertBaseDietInfo(baseDietInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改饮食知识库
|
||||
*
|
||||
* @param baseDietInfo 饮食知识库
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateBaseDietInfo(BaseDietInfo baseDietInfo) {
|
||||
baseDietInfo.setUpdateTime(LocalDateTime.now());
|
||||
return baseDietInfoMapper.updateBaseDietInfo(baseDietInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除饮食知识库
|
||||
*
|
||||
* @param ids 需要删除的饮食知识库主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBaseDietInfoByIds(Long[] ids) {
|
||||
return baseDietInfoMapper.deleteBaseDietInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除饮食知识库信息
|
||||
*
|
||||
* @param id 饮食知识库主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBaseDietInfoById(Long id) {
|
||||
return baseDietInfoMapper.deleteBaseDietInfoById(id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,162 @@
|
||||
<?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.xinelu.manage.mapper.basedietinfo.BaseDietInfoMapper">
|
||||
|
||||
<resultMap type="BaseDietInfo" id="BaseDietInfoResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="dietName" column="diet_name"/>
|
||||
<result property="dietPrinciple" column="diet_principle"/>
|
||||
<result property="mainFood" column="main_food"/>
|
||||
<result property="vegetable" column="vegetable"/>
|
||||
<result property="fruit" column="fruit"/>
|
||||
<result property="meat" column="meat"/>
|
||||
<result property="dietRemark" column="diet_remark"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBaseDietInfoVo">
|
||||
select id, diet_name, diet_principle, main_food, vegetable, fruit, meat, diet_remark, create_time, create_by, update_by, update_time from base_diet_info
|
||||
</sql>
|
||||
|
||||
<select id="selectBaseDietInfoList" parameterType="BaseDietInfo" resultMap="BaseDietInfoResult">
|
||||
<include refid="selectBaseDietInfoVo"/>
|
||||
<where>
|
||||
<if test="dietName != null and dietName != ''">
|
||||
and diet_name like concat('%', #{dietName}, '%')
|
||||
</if>
|
||||
<if test="dietPrinciple != null and dietPrinciple != ''">
|
||||
and diet_principle = #{dietPrinciple}
|
||||
</if>
|
||||
<if test="mainFood != null and mainFood != ''">
|
||||
and main_food = #{mainFood}
|
||||
</if>
|
||||
<if test="vegetable != null and vegetable != ''">
|
||||
and vegetable = #{vegetable}
|
||||
</if>
|
||||
<if test="fruit != null and fruit != ''">
|
||||
and fruit = #{fruit}
|
||||
</if>
|
||||
<if test="meat != null and meat != ''">
|
||||
and meat = #{meat}
|
||||
</if>
|
||||
<if test="dietRemark != null and dietRemark != ''">
|
||||
and diet_remark = #{dietRemark}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBaseDietInfoById" parameterType="Long"
|
||||
resultMap="BaseDietInfoResult">
|
||||
<include refid="selectBaseDietInfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertBaseDietInfo" parameterType="BaseDietInfo" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into base_diet_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="dietName != null">diet_name,
|
||||
</if>
|
||||
<if test="dietPrinciple != null">diet_principle,
|
||||
</if>
|
||||
<if test="mainFood != null">main_food,
|
||||
</if>
|
||||
<if test="vegetable != null">vegetable,
|
||||
</if>
|
||||
<if test="fruit != null">fruit,
|
||||
</if>
|
||||
<if test="meat != null">meat,
|
||||
</if>
|
||||
<if test="dietRemark != null">diet_remark,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="updateBy != null">update_by,
|
||||
</if>
|
||||
<if test="updateTime != null">update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="dietName != null">#{dietName},
|
||||
</if>
|
||||
<if test="dietPrinciple != null">#{dietPrinciple},
|
||||
</if>
|
||||
<if test="mainFood != null">#{mainFood},
|
||||
</if>
|
||||
<if test="vegetable != null">#{vegetable},
|
||||
</if>
|
||||
<if test="fruit != null">#{fruit},
|
||||
</if>
|
||||
<if test="meat != null">#{meat},
|
||||
</if>
|
||||
<if test="dietRemark != null">#{dietRemark},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="updateBy != null">#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBaseDietInfo" parameterType="BaseDietInfo">
|
||||
update base_diet_info
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="dietName != null">diet_name =
|
||||
#{dietName},
|
||||
</if>
|
||||
<if test="dietPrinciple != null">diet_principle =
|
||||
#{dietPrinciple},
|
||||
</if>
|
||||
<if test="mainFood != null">main_food =
|
||||
#{mainFood},
|
||||
</if>
|
||||
<if test="vegetable != null">vegetable =
|
||||
#{vegetable},
|
||||
</if>
|
||||
<if test="fruit != null">fruit =
|
||||
#{fruit},
|
||||
</if>
|
||||
<if test="meat != null">meat =
|
||||
#{meat},
|
||||
</if>
|
||||
<if test="dietRemark != null">diet_remark =
|
||||
#{dietRemark},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBaseDietInfoById" parameterType="Long">
|
||||
delete from base_diet_info where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBaseDietInfoByIds" parameterType="String">
|
||||
delete from base_diet_info where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user