diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/DingdanController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DingdanController.java new file mode 100644 index 0000000..aa45fda --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/DingdanController.java @@ -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 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 list = dingdanService.selectDingdanList(dingdan); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyorderController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyorderController.java index d8da151..2a710d6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyorderController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyorderController.java @@ -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; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PersonController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PersonController.java index 155c481..a2d8588 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/PersonController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/PersonController.java @@ -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 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模块列表 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/RestTemplateConfiguration.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/RestTemplateConfiguration.java new file mode 100644 index 0000000..7daa646 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/RestTemplateConfiguration.java @@ -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; + } + + } + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dingdan.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dingdan.java new file mode 100644 index 0000000..c3fc90e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Dingdan.java @@ -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(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DingdanMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DingdanMapper.java new file mode 100644 index 0000000..76c640d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/DingdanMapper.java @@ -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 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IDingdanService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDingdanService.java new file mode 100644 index 0000000..f8d6f8b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IDingdanService.java @@ -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 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); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DingdanServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DingdanServiceImpl.java new file mode 100644 index 0000000..d53ed03 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DingdanServiceImpl.java @@ -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 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); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/DingdanMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DingdanMapper.xml new file mode 100644 index 0000000..957e4fe --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/DingdanMapper.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + select id, bianhao, biaoti, price, name1, name2, name3, image from dingdan + + + + + + + + insert into dingdan + + bianhao, + biaoti, + price, + name1, + name2, + name3, + image, + + + #{bianhao}, + #{biaoti}, + #{price}, + #{name1}, + #{name2}, + #{name3}, + #{image}, + + + + + update dingdan + + bianhao = #{bianhao}, + biaoti = #{biaoti}, + price = #{price}, + name1 = #{name1}, + name2 = #{name2}, + name3 = #{name3}, + image = #{image}, + + where id = #{id} + + + + delete from dingdan where id = #{id} + + + + delete from dingdan where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/PersonMapper.xml b/ruoyi-system/src/main/resources/mapper/system/PersonMapper.xml similarity index 100% rename from ruoyi-system/src/main/resources/PersonMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/PersonMapper.xml