This commit is contained in:
yj 2024-12-06 21:19:58 +08:00
parent 485a01da48
commit 343283424a
10 changed files with 586 additions and 2 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.system.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;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Dingdan;
import com.ruoyi.system.service.IDingdanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 订单Controller
*
* @author 殷剑
* @date 2024-11-26
*/
@RestController
@RequestMapping("/system/dingdan")
public class DingdanController extends BaseController
{
@Autowired
private IDingdanService dingdanService;
/**
* 查询订单列表
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:list')")
@GetMapping("/list")
public TableDataInfo list(Dingdan dingdan)
{
startPage();
List<Dingdan> list = dingdanService.selectDingdanList(dingdan);
return getDataTable(list);
}
/**
* 导出订单列表
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:export')")
@Log(title = "订单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Dingdan dingdan)
{
List<Dingdan> list = dingdanService.selectDingdanList(dingdan);
ExcelUtil<Dingdan> util = new ExcelUtil<Dingdan>(Dingdan.class);
util.exportExcel(response, list, "订单数据");
}
/**
* 获取订单详细信息
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(dingdanService.selectDingdanById(id));
}
/**
* 新增订单
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:add')")
@Log(title = "订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Dingdan dingdan)
{
return toAjax(dingdanService.insertDingdan(dingdan));
}
/**
* 修改订单
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:edit')")
@Log(title = "订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Dingdan dingdan)
{
return toAjax(dingdanService.updateDingdan(dingdan));
}
/**
* 删除订单
*/
@PreAuthorize("@ss.hasPermi('system:dingdan:remove')")
@Log(title = "订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(dingdanService.deleteDingdanByIds(ids));
}
}

View File

@ -20,6 +20,7 @@ import com.ruoyi.system.domain.Myorder;
import com.ruoyi.system.service.IMyorderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.client.RestTemplate;
/**
* 订单Controller
@ -31,6 +32,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
@RequestMapping("/system/myorder")
public class MyorderController extends BaseController
{
// RestTemplate
// http://106.53.194.250:5001/newslist?page1
// python flask
@Autowired
private IMyorderService myorderService;

View File

@ -2,6 +2,8 @@ package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -20,6 +22,7 @@ import com.ruoyi.system.domain.Person;
import com.ruoyi.system.service.IPersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.client.RestTemplate;
/**
* person模块Controller
@ -33,11 +36,14 @@ public class PersonController extends BaseController
{
@Autowired
private IPersonService personService;
@Autowired
private RestTemplate restTemplate;
/**
* 查询person模块列表
*/
@PreAuthorize("@ss.hasPermi('system:person:list')")
// @PreAuthorize("@ss.hasPermi('system:person:list')")
@Anonymous
@GetMapping("/list")
public TableDataInfo list(Person person)
{
@ -45,7 +51,15 @@ public class PersonController extends BaseController
List<Person> list = personService.selectPersonList(person);
return getDataTable(list);
}
//@Autowired
//
// @Anonymous
// @GetMapping("/newslist")
// public String newslist(int page)
// {
// String url ="http://106.53.194.250:5001/newslist?page=" +page;
// return restTemplate.getForEntity(url, String.class).getBody();
// }
/**
* 导出person模块列表
*/

View File

@ -0,0 +1,24 @@
package com.ruoyi.system.controller;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
@Configuration
public class RestTemplateConfiguration {
@Bean
public RestTemplate restTemplate(){
RestTemplate restTemplate = new RestTemplate();
// 设置中文乱码问题方式一
restTemplate.getMessageConverters().add(1,new StringHttpMessageConverter(Charset.forName("UTF-8")));
// 设置中文乱码问题方式二
// restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8)); // 支持中文编码
// return new RestTemplate();
return restTemplate;
}
}

View File

@ -0,0 +1,136 @@
package com.ruoyi.system.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 订单对象 dingdan
*
* @author 殷剑
* @date 2024-11-26
*/
public class Dingdan extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 编号 */
@Excel(name = "编号")
private String bianhao;
/** 标题 */
@Excel(name = "标题")
private String biaoti;
/** 价格 */
@Excel(name = "价格")
private BigDecimal price;
/** 名称1 */
@Excel(name = "名称1")
private String name1;
/** 名称2 */
@Excel(name = "名称2")
private String name2;
/** 名称3 */
@Excel(name = "名称3")
private String name3;
/** 图片 */
@Excel(name = "图片")
private String image;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setBianhao(String bianhao)
{
this.bianhao = bianhao;
}
public String getBianhao()
{
return bianhao;
}
public void setBiaoti(String biaoti)
{
this.biaoti = biaoti;
}
public String getBiaoti()
{
return biaoti;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
public void setName1(String name1)
{
this.name1 = name1;
}
public String getName1()
{
return name1;
}
public void setName2(String name2)
{
this.name2 = name2;
}
public String getName2()
{
return name2;
}
public void setName3(String name3)
{
this.name3 = name3;
}
public String getName3()
{
return name3;
}
public void setImage(String image)
{
this.image = image;
}
public String getImage()
{
return image;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("bianhao", getBianhao())
.append("biaoti", getBiaoti())
.append("price", getPrice())
.append("name1", getName1())
.append("name2", getName2())
.append("name3", getName3())
.append("image", getImage())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Dingdan;
/**
* 订单Mapper接口
*
* @author 殷剑
* @date 2024-11-26
*/
public interface DingdanMapper
{
/**
* 查询订单
*
* @param id 订单主键
* @return 订单
*/
public Dingdan selectDingdanById(Long id);
/**
* 查询订单列表
*
* @param dingdan 订单
* @return 订单集合
*/
public List<Dingdan> selectDingdanList(Dingdan dingdan);
/**
* 新增订单
*
* @param dingdan 订单
* @return 结果
*/
public int insertDingdan(Dingdan dingdan);
/**
* 修改订单
*
* @param dingdan 订单
* @return 结果
*/
public int updateDingdan(Dingdan dingdan);
/**
* 删除订单
*
* @param id 订单主键
* @return 结果
*/
public int deleteDingdanById(Long id);
/**
* 批量删除订单
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDingdanByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Dingdan;
/**
* 订单Service接口
*
* @author 殷剑
* @date 2024-11-26
*/
public interface IDingdanService
{
/**
* 查询订单
*
* @param id 订单主键
* @return 订单
*/
public Dingdan selectDingdanById(Long id);
/**
* 查询订单列表
*
* @param dingdan 订单
* @return 订单集合
*/
public List<Dingdan> selectDingdanList(Dingdan dingdan);
/**
* 新增订单
*
* @param dingdan 订单
* @return 结果
*/
public int insertDingdan(Dingdan dingdan);
/**
* 修改订单
*
* @param dingdan 订单
* @return 结果
*/
public int updateDingdan(Dingdan dingdan);
/**
* 批量删除订单
*
* @param ids 需要删除的订单主键集合
* @return 结果
*/
public int deleteDingdanByIds(Long[] ids);
/**
* 删除订单信息
*
* @param id 订单主键
* @return 结果
*/
public int deleteDingdanById(Long id);
}

View File

@ -0,0 +1,93 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DingdanMapper;
import com.ruoyi.system.domain.Dingdan;
import com.ruoyi.system.service.IDingdanService;
/**
* 订单Service业务层处理
*
* @author 殷剑
* @date 2024-11-26
*/
@Service
public class DingdanServiceImpl implements IDingdanService
{
@Autowired
private DingdanMapper dingdanMapper;
/**
* 查询订单
*
* @param id 订单主键
* @return 订单
*/
@Override
public Dingdan selectDingdanById(Long id)
{
return dingdanMapper.selectDingdanById(id);
}
/**
* 查询订单列表
*
* @param dingdan 订单
* @return 订单
*/
@Override
public List<Dingdan> selectDingdanList(Dingdan dingdan)
{
return dingdanMapper.selectDingdanList(dingdan);
}
/**
* 新增订单
*
* @param dingdan 订单
* @return 结果
*/
@Override
public int insertDingdan(Dingdan dingdan)
{
return dingdanMapper.insertDingdan(dingdan);
}
/**
* 修改订单
*
* @param dingdan 订单
* @return 结果
*/
@Override
public int updateDingdan(Dingdan dingdan)
{
return dingdanMapper.updateDingdan(dingdan);
}
/**
* 批量删除订单
*
* @param ids 需要删除的订单主键
* @return 结果
*/
@Override
public int deleteDingdanByIds(Long[] ids)
{
return dingdanMapper.deleteDingdanByIds(ids);
}
/**
* 删除订单信息
*
* @param id 订单主键
* @return 结果
*/
@Override
public int deleteDingdanById(Long id)
{
return dingdanMapper.deleteDingdanById(id);
}
}

View File

@ -0,0 +1,86 @@
<?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.ruoyi.system.mapper.DingdanMapper">
<resultMap type="Dingdan" id="DingdanResult">
<result property="id" column="id" />
<result property="bianhao" column="bianhao" />
<result property="biaoti" column="biaoti" />
<result property="price" column="price" />
<result property="name1" column="name1" />
<result property="name2" column="name2" />
<result property="name3" column="name3" />
<result property="image" column="image" />
</resultMap>
<sql id="selectDingdanVo">
select id, bianhao, biaoti, price, name1, name2, name3, image from dingdan
</sql>
<select id="selectDingdanList" parameterType="Dingdan" resultMap="DingdanResult">
<include refid="selectDingdanVo"/>
<where>
<if test="bianhao != null and bianhao != ''"> and bianhao = #{bianhao}</if>
<if test="biaoti != null and biaoti != ''"> and biaoti = #{biaoti}</if>
<if test="price != null "> and price = #{price}</if>
<if test="name1 != null and name1 != ''"> and name1 = #{name1}</if>
<if test="name2 != null and name2 != ''"> and name2 = #{name2}</if>
<if test="name3 != null and name3 != ''"> and name3 = #{name3}</if>
<if test="image != null and image != ''"> and image = #{image}</if>
</where>
</select>
<select id="selectDingdanById" parameterType="Long" resultMap="DingdanResult">
<include refid="selectDingdanVo"/>
where id = #{id}
</select>
<insert id="insertDingdan" parameterType="Dingdan" useGeneratedKeys="true" keyProperty="id">
insert into dingdan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bianhao != null">bianhao,</if>
<if test="biaoti != null">biaoti,</if>
<if test="price != null">price,</if>
<if test="name1 != null">name1,</if>
<if test="name2 != null">name2,</if>
<if test="name3 != null">name3,</if>
<if test="image != null">image,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bianhao != null">#{bianhao},</if>
<if test="biaoti != null">#{biaoti},</if>
<if test="price != null">#{price},</if>
<if test="name1 != null">#{name1},</if>
<if test="name2 != null">#{name2},</if>
<if test="name3 != null">#{name3},</if>
<if test="image != null">#{image},</if>
</trim>
</insert>
<update id="updateDingdan" parameterType="Dingdan">
update dingdan
<trim prefix="SET" suffixOverrides=",">
<if test="bianhao != null">bianhao = #{bianhao},</if>
<if test="biaoti != null">biaoti = #{biaoti},</if>
<if test="price != null">price = #{price},</if>
<if test="name1 != null">name1 = #{name1},</if>
<if test="name2 != null">name2 = #{name2},</if>
<if test="name3 != null">name3 = #{name3},</if>
<if test="image != null">image = #{image},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDingdanById" parameterType="Long">
delete from dingdan where id = #{id}
</delete>
<delete id="deleteDingdanByIds" parameterType="String">
delete from dingdan where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>