| | |
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | @Controller
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | |
|
| | | @RequestMapping(value = "getConfigList", method = RequestMethod.POST)
|
| | | public void getConfigList(PrintWriter out){
|
| | |
| | | out.print(JsonUtil.loadTrueResult("修改成功"));
|
| | | return;
|
| | | }
|
| | | |
| | | /**
|
| | | * 查询列表 - 新后台
|
| | | * @param callback
|
| | | * @param key 查询词 名称
|
| | | * @param pageIndex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNewConfigList")
|
| | | public void getNewConfigList(String callback, String key, Integer pageIndex, PrintWriter out){
|
| | | |
| | | try {
|
| | | |
| | | if (pageIndex == null || pageIndex < 0){
|
| | | pageIndex = 1;
|
| | | }
|
| | | |
| | | List<Config> list = configService.listObjects(key, pageIndex);
|
| | | |
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | int count = configService.getCount(key, pageIndex);
|
| | | PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", list);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 参数修改 - 新后台
|
| | | * @param callback
|
| | | * @param config
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, Config config, Long uid, HttpServletResponse response, PrintWriter out) {
|
| | | |
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | |
|
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("当前账户验证失败"));
|
| | | return;
|
| | | }
|
| | | |
| | | Long id = config.getId();
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | Config crentconfig = configService.getConfig(id);
|
| | | if (crentconfig == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | | // key 不可修改
|
| | | config.setKey(crentconfig.getKey());
|
| | | configService.update(config);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | | |
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("修改失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | }
|