Compare commits
1
Commits
b0efd05062
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e84ca04e86 |
@@ -1,137 +0,0 @@
|
|||||||
package com.cym.controller.page;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.lang.UUID;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.cym.bean.Page;
|
|
||||||
import com.cym.ext.AdminExt;
|
|
||||||
import com.cym.ext.ExampleExt;
|
|
||||||
import com.cym.model.Admin;
|
|
||||||
import com.cym.model.Example;
|
|
||||||
import com.cym.model.Goods;
|
|
||||||
import com.cym.service.AdminExampleService;
|
|
||||||
import com.cym.utils.BaseController;
|
|
||||||
import com.cym.utils.ConditionAndWrapper;
|
|
||||||
import com.cym.utils.JsonResult;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.transaction.Transactional;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Tag(name = "测试", description = "测试相关接口")
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/test")
|
|
||||||
public class Test extends BaseController {
|
|
||||||
// @Autowired
|
|
||||||
// AdminExampleService adminExampleService;
|
|
||||||
// @GetMapping("/test")
|
|
||||||
// @Operation(summary = "测试")
|
|
||||||
// public String test(){
|
|
||||||
// log.error("==============error");
|
|
||||||
// List<User> all = jpaHelper.findAll(User.class);
|
|
||||||
// return "";
|
|
||||||
// }
|
|
||||||
|
|
||||||
@RequestMapping("")
|
|
||||||
public ModelAndView page(ModelAndView mv, Page page,String keyword){
|
|
||||||
ConditionAndWrapper wrapper = new ConditionAndWrapper();
|
|
||||||
if (StrUtil.isNotBlank(keyword))
|
|
||||||
wrapper.like(Goods::getName, keyword);
|
|
||||||
|
|
||||||
page = jpaHelper.findPageByQuery(wrapper, page, Goods.class);
|
|
||||||
|
|
||||||
|
|
||||||
mv.addObject("page", page);
|
|
||||||
mv.setViewName("/test/index");
|
|
||||||
return mv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @RequestMapping("/page")
|
|
||||||
// public ModelAndView page(Page page,String keyword){
|
|
||||||
// ModelAndView mv = new ModelAndView();
|
|
||||||
// ConditionAndWrapper wrapper = new ConditionAndWrapper();
|
|
||||||
// if (StrUtil.isNotBlank(keyword))
|
|
||||||
// wrapper.like(Goods::getName, keyword);
|
|
||||||
//
|
|
||||||
// Page<Goods> pageByQuery = jpaHelper.findPageByQuery(wrapper, page, Goods.class);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// mv.addObject("page", pageByQuery);
|
|
||||||
// mv.setViewName("/test/index");
|
|
||||||
// return mv;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@RequestMapping("add")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResult add(Goods example) {
|
|
||||||
|
|
||||||
jpaHelper.insertOrUpdate(example);
|
|
||||||
|
|
||||||
return renderSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("detail")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResult detail(String id) {
|
|
||||||
Goods example = jpaHelper.findById(id, Goods.class);
|
|
||||||
// ExampleExt exampleExt = new ExampleExt();
|
|
||||||
// BeanUtil.copyProperties(example, exampleExt);
|
|
||||||
//
|
|
||||||
// exampleExt.setAdmin(jpaHelper.findById(example.getAdminId(), Admin.class));
|
|
||||||
|
|
||||||
return renderSuccess(example);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping("delete")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResult delete(String id) {
|
|
||||||
jpaHelper.deleteById(id, Goods.class);
|
|
||||||
|
|
||||||
return renderSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @RequestMapping("index")
|
|
||||||
// public ModelAndView admin(ModelAndView modelAndView, HttpServletRequest request, String adminId) {
|
|
||||||
//
|
|
||||||
// modelAndView.setViewName("/loginExample/index");
|
|
||||||
// return modelAndView;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @RequestMapping("login")
|
|
||||||
// @ResponseBody
|
|
||||||
// public JsonResult submitLogin(String name, String pass, HttpServletRequest request) {
|
|
||||||
//
|
|
||||||
// getHttpSession().removeAttribute("adminLogin");
|
|
||||||
//
|
|
||||||
// // 用户名密码
|
|
||||||
// Admin admin = adminExampleService.login(name, pass);
|
|
||||||
// if (admin == null) {
|
|
||||||
// return renderError("用户名密码错误"); // 用户名密码错误
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 登录成功
|
|
||||||
// admin.setAutoKey(UUID.randomUUID().toString()); // 生成自动登录code
|
|
||||||
// jpaHelper.updateById(admin);
|
|
||||||
//
|
|
||||||
// // 读取菜单
|
|
||||||
// AdminExt adminExt = new AdminExt();
|
|
||||||
//
|
|
||||||
// getHttpSession().setAttribute("adminLogin", adminExt);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return renderSuccess(admin);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.cym.controller.page;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.cym.bean.Page;
|
||||||
|
import com.cym.model.Goods;
|
||||||
|
import com.cym.utils.BaseController;
|
||||||
|
import com.cym.utils.ConditionAndWrapper;
|
||||||
|
import com.cym.utils.JsonResult;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Tag(name = "测试", description = "测试相关接口")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/test")
|
||||||
|
public class TestController extends BaseController {
|
||||||
|
|
||||||
|
@RequestMapping("")
|
||||||
|
public ModelAndView page(ModelAndView modelAndView, Page page,String keyword){
|
||||||
|
ConditionAndWrapper wrapper = new ConditionAndWrapper();
|
||||||
|
if (StrUtil.isNotBlank(keyword))
|
||||||
|
wrapper.like(Goods::getName, keyword);
|
||||||
|
page = jpaHelper.findPageByQuery(wrapper, page, Goods.class);
|
||||||
|
|
||||||
|
modelAndView.addObject("page", page);
|
||||||
|
modelAndView.setViewName("/test/index");
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("add")
|
||||||
|
@ResponseBody
|
||||||
|
public JsonResult add(Goods goods) {
|
||||||
|
jpaHelper.insertOrUpdate(goods);
|
||||||
|
return renderSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("detail")
|
||||||
|
@ResponseBody
|
||||||
|
public JsonResult detail(String id) {
|
||||||
|
Goods goods = jpaHelper.findById(id, Goods.class);
|
||||||
|
return renderSuccess(goods);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping("delete")
|
||||||
|
@ResponseBody
|
||||||
|
public JsonResult delete(String id) {
|
||||||
|
jpaHelper.deleteById(id, Goods.class);
|
||||||
|
|
||||||
|
return renderSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -69,13 +69,13 @@ function edit(id) {
|
|||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
var example = data.obj;
|
var goods = data.obj;
|
||||||
$("#id").val(example.id);
|
$("#id").val(goods.id);
|
||||||
$("#name").val(example.name);
|
$("#name").val(goods.name);
|
||||||
$("#title").val(example.title);
|
$("#title").val(goods.title);
|
||||||
$("#image").val(example.image);
|
$("#image").val(goods.image);
|
||||||
$("#price").val(example.price);
|
$("#price").val(goods.price);
|
||||||
$("#description").val(example.description);
|
$("#description").val(goods.description);
|
||||||
|
|
||||||
form.render();
|
form.render();
|
||||||
showWindow("编辑");
|
showWindow("编辑");
|
||||||
|
|||||||
@@ -60,17 +60,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<#list page.list as example>
|
<#list page.list as goods>
|
||||||
<tr>
|
<tr>
|
||||||
<td>${example.image}</td>
|
|
||||||
<td>
|
<td>
|
||||||
${example.name}
|
${goods.image}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${example.title}
|
${goods.name}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${example.price}
|
${goods.title}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
${goods.price}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user