new QueryWrapper<Gonggao>().orderByDesc("sendtime")
时间: 2024-02-06 19:09:57 浏览: 33
这段代码是使用 MyBatis-Plus 框架的 QueryWrapper 类来构建查询条件,查询 Gonggao 表中的数据并以 sendtime 字段为降序排列。其中,Gonggao 是表对应的实体类,"sendtime" 是表中的字段名。该查询语句会生成类似于以下 SQL 语句:
```
SELECT * FROM Gonggao ORDER BY sendtime DESC;
```
相关问题
AttributeError: module 'gonggao.views' has no attribute 'notice_list_view'
这个错误是由于在模块`gonggao.views`中没有名为`notice_list_view`的导致的。这可能是因为你在代码中引用了一个不存在的属性或者方法。要解决这个问题,你可以检查以下几点:
1. 确保你正确导入了`gonggao.views`模块。你可以使用`import`语句来导入模块,例如:
```python
import gonggao.views
```
2. 确保`notice_list_view`是`gonggao.views`模块中的一个有效属性。你可以查看`gonggao.views`模块的代码,确认是否存在`notice_list_view`属性或方法。
3. 如果你在代码中使用了`gonggao.views.notice_list_view`,请确保你正确地调用了该属性或方法。你可以检查代码中是否有拼写错误或者其他语法错误。
如果你仍然无法解决问题,请提供更多的代码和错误信息,以便我能够更好地帮助你。
翻译代码:package com.action; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; import org.apache.struts2.ServletActionContext; import com.dao.TGonggaoDAO; import com.model.TAdmin; import com.model.TGonggao; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class gonggaoAction extends ActionSupport { private Integer id; private String biaoti; private String neirong; private String shijian; private String message; private String path; private TGonggaoDAO gonggaoDAO; public String gonggaoAdd() { TGonggao gonggao=new TGonggao(); gonggao.setBiaoti(biaoti); gonggao.setNeirong(neirong); gonggao.setShijian(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())); gonggaoDAO.save(gonggao); this.setMessage("公告添加完毕"); this.setPath("gonggaoMana.action"); return "succeed"; } public String gonggaoMana() { List gonggaoList =gonggaoDAO.findAll(); Map request=(Map)ServletActionContext.getContext().get("request"); request.put("gonggaoList", gonggaoList); return ActionSupport.SUCCESS; } public String gonggaoDel() { TGonggao gonggao=gonggaoDAO.findById(id); gonggaoDAO.delete(gonggao); this.setMessage("公告删除完毕"); this.setPath("gonggaoMana.action"); return "succeed"; } public String gonggaoDetailHou() { TGonggao gonggao=gonggaoDAO.findById(id); Map request=(Map)ServletActionContext.getContext().get("request"); request.put("gonggao", gonggao); return ActionSupport.SUCCESS; } public String gonggaoAll() { List gonggaoList =gonggaoDAO.findAll(); Map request=(Map)ServletActionContext.getContext().get("request"); request.put("gonggaoList", gonggaoList); return ActionSupport.SUCCESS; } public String gonggaoDetailQian() { TGonggao gonggao=gonggaoDAO.findById(id); Map request=(Map)ServletActionContext.getContext().get("request"); request.put("gonggao", gonggao); return ActionSupport.SUCCESS; } public String getBiaoti() { return biaoti; } public void setBiaoti(String biaoti) { this.biaoti = biaoti; } public TGonggaoDAO getGonggaoDAO() { return gonggaoDAO; } public void setGonggaoDAO(TGonggaoDAO gonggaoDAO) { this.gonggaoDAO = gonggaoDAO; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getNeirong() { return neirong; } public void setNeirong(String neirong) { this.neirong = neirong; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getShijian() { return shijian; } public void setShijian(String shijian) { this.shijian = shijian; } }
这是一个 Java 的 Struts2 框架的 Action 类,包含了公告的增删改查等方法。具体代码如下:
```
package com.action;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.struts2.ServletActionContext;
import com.dao.TGonggaoDAO;
import com.model.TAdmin;
import com.model.TGonggao;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class gonggaoAction extends ActionSupport {
private Integer id;
private String biaoti;
private String neirong;
private String shijian;
private String message;
private String path;
private TGonggaoDAO gonggaoDAO;
public String gonggaoAdd() {
TGonggao gonggao=new TGonggao();
gonggao.setBiaoti(biaoti);
gonggao.setNeirong(neirong);
gonggao.setShijian(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
gonggaoDAO.save(gonggao);
this.setMessage("公告添加完毕");
this.setPath("gonggaoMana.action");
return "succeed";
}
public String gonggaoMana() {
List gonggaoList =gonggaoDAO.findAll();
Map request=(Map)ServletActionContext.getContext().get("request");
request.put("gonggaoList", gonggaoList);
return ActionSupport.SUCCESS;
}
public String gonggaoDel() {
TGonggao gonggao=gonggaoDAO.findById(id);
gonggaoDAO.delete(gonggao);
this.setMessage("公告删除完毕");
this.setPath("gonggaoMana.action");
return "succeed";
}
public String gonggaoDetailHou() {
TGonggao gonggao=gonggaoDAO.findById(id);
Map request=(Map)ServletActionContext.getContext().get("request");
request.put("gonggao", gonggao);
return ActionSupport.SUCCESS;
}
public String gonggaoAll() {
List gonggaoList =gonggaoDAO.findAll();
Map request=(Map)ServletActionContext.getContext().get("request");
request.put("gonggaoList", gonggaoList);
return ActionSupport.SUCCESS;
}
public String gonggaoDetailQian() {
TGonggao gonggao=gonggaoDAO.findById(id);
Map request=(Map)ServletActionContext.getContext().get("request");
request.put("gonggao", gonggao);
return ActionSupport.SUCCESS;
}
public String getBiaoti() {
return biaoti;
}
public void setBiaoti(String biaoti) {
this.biaoti = biaoti;
}
public TGonggaoDAO getGonggaoDAO() {
return gonggaoDAO;
}
public void setGonggaoDAO(TGonggaoDAO gonggaoDAO) {
this.gonggaoDAO = gonggaoDAO;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getNeirong() {
return neirong;
}
public void setNeirong(String neirong) {
this.neirong = neirong;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getShijian() {
return shijian;
}
public void setShijian(String shijian) {
this.shijian = shijian;
}
}
```