首页>代码>基于ssh(spring+struts+hibernate)+bootstrap+jquery开发的java web图书馆图书借阅后台管理系统>/src/com/xznu/edu/leave/action/ItemTypeAction.java
001 | package com.xznu.edu.leave.action; |
002 |
003 | /** |
004 | * 用户新增 |
005 | */ |
006 |
007 | import com.opensymphony.xwork2.ActionContext; |
008 | import com.opensymphony.xwork2.ActionSupport; |
009 | import com.opensymphony.xwork2.ModelDriven; |
010 | import com.xznu.edu.leave.model.ItemType; |
011 | import com.xznu.edu.leave.model.Role; |
012 | import com.xznu.edu.leave.model.User; |
013 | import com.xznu.edu.leave.service.ItemTypeService; |
014 | import com.xznu.edu.leave.service.RoleService; |
015 | import com.xznu.edu.leave.service.UserService; |
016 | import com.xznu.edu.leave.utils.JsonUtils; |
017 | import com.xznu.edu.leave.utils.Pager; |
018 | import com.xznu.edu.leave.utils.UserUtils; |
019 | import net.sf.json.JSONObject; |
020 | import org.springframework.beans.factory.annotation.Autowired; |
021 | import org.springframework.context.annotation.Scope; |
022 | import org.springframework.stereotype.Controller; |
023 |
024 | import java.io.IOException; |
025 | import java.util.Date; |
026 | import java.util.HashMap; |
027 | import java.util.Map; |
028 |
029 | @Controller ( "itemtypeAction" ) |
030 | @Scope ( "prototype" ) |
031 | public class ItemTypeAction extends ActionSupport implements ModelDriven<ItemType> { |
032 |
033 | @Autowired |
034 | private ItemTypeService service; |
035 | private ItemType itemType; |
036 |
037 |
038 | /** |
039 | * list |
040 | * |
041 | * @return |
042 | */ |
043 | public String list() throws IOException { |
044 | User user1 = UserUtils.getUser(); |
045 | if (user1 == null || user1.getId() == null ){ |
046 | ActionContext.getContext().put( "login" , 1 ); |
047 | return SUCCESS; |
048 | } |
049 | Pager<ItemType> pagers = null ; |
050 | if (user1.getRole().getEnName().equals( "admin" )) { |
051 | pagers = service.getList(itemType); |
052 | ActionContext.getContext().put( "pagers" , pagers); |
053 | ActionContext.getContext().put( "user" , user1); |
054 | ActionContext.getContext().put( "bean" , itemType); |
055 | return SUCCESS; |
056 | } else if (user1.getRole().getEnName().equals( "system" )) { |
057 | pagers = service.getList(itemType); |
058 | ActionContext.getContext().put( "pagers" , pagers); |
059 | ActionContext.getContext().put( "bean" , itemType); |
060 | return SUCCESS; |
061 | } |
062 | return null ; |
063 | } |
064 |
065 |
066 | /** |
067 | * 跳转add |
068 | * |
069 | * @return |
070 | */ |
071 | public String add() { |
072 | return SUCCESS; |
073 | } |
074 |
075 | /** |
076 | * 查询修改 |
077 | * |
078 | * @return |
079 | */ |
080 | public String edit() { |
081 | ItemType bean = service.findById(itemType.getId()); |
082 | ActionContext.getContext().put( "bean" , bean); |
083 | return SUCCESS; |
084 | } |
085 |
086 | /** |
087 | * 更新 |
088 | * |
089 | * @return |
090 | */ |
091 | public void update() throws IOException { |
092 | service.updates(itemType); |
093 | JSONObject jsonObject = new JSONObject(); |
094 | jsonObject.put( "flag" , true ); |
095 | jsonObject.put( "message" , "更新成功" ); |
096 | JsonUtils.jsonObject(jsonObject); |
097 | } |
098 |
099 | /** |
100 | * 保存 |
101 | * |
102 | * @return |
103 | */ |
104 | public void save() throws IOException { |
105 | service.save(itemType); |
106 | JSONObject jsonObject = new JSONObject(); |
107 | jsonObject.put( "flag" , true ); |
108 | JsonUtils.jsonObject(jsonObject); |
109 | } |
110 |
111 | public void delete() throws IOException { |
112 | itemType.setIsDelete( 1 ); |
113 | service.updates(itemType); |
114 | JSONObject jsonObject = new JSONObject(); |
115 | jsonObject.put( "flag" , true ); |
116 | jsonObject.put( "url" , "itemtype_list.do" ); |
117 | JsonUtils.jsonObject(jsonObject); |
118 | } |
119 |
120 | @Override |
121 | public ItemType getModel() { |
122 | if (itemType == null ) { |
123 | itemType = new ItemType(); |
124 | } |
125 | return itemType; |
126 | } |
127 |
128 | public ItemType getItemType() { |
129 | return itemType; |
130 | } |
131 |
132 | public void setItemType(ItemType itemType) { |
133 | this .itemType = itemType; |
134 | } |
135 | } |

zolscy LV24
2024年11月29日
599142776 LV2
2023年12月7日
DarcyLi LV3
2023年10月9日
18584457462 LV5
2023年9月27日
2131234536546 LV7
2023年9月14日
qfch120 LV8
2023年4月16日
11sdvszb LV2
2023年4月1日
北方菜 LV11
2023年3月2日
zhaoxiang123456 LV4
2023年2月12日
齐吊大神 LV6
2022年12月20日

无异偶 LV3
2024年12月30日
MQ-EQW
2024年12月18日
暂无贡献等级
zolscy LV24
2024年11月29日
LoveSummer LV6
2024年10月31日
krispeng LV14
2024年10月2日
6664146541684 LV7
2024年9月5日
wanxiaoqiao52866414 LV1
2024年7月1日
刘昊然 LV1
2024年7月1日
326402 LV1
2024年6月17日
2267068802 LV1
2024年6月11日