| | |
| | | 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 org.yeshi.utils.JsonUtil;
|
| | |
|
| | | 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;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/config")
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | | |
| | | int count = configService.getCount(key, pageIndex);
|
| | | PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count);
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | |
| | | * @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", "*");
|
| | | public void saveModify(String callback, Config config, PrintWriter out) {
|
| | |
|
| | | 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不能为空"));
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | | // key 不可修改
|
| | | config.setKey(crentconfig.getKey());
|
| | | configService.update(config);
|
| | | |
| | | if (StringUtil.isNullOrEmpty(config.getName()) || StringUtil.isNullOrEmpty(config.getValue())) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("说明、有效值不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | crentconfig.setName(config.getName());
|
| | | crentconfig.setValue(config.getValue());
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(config.getBeizhu())) {
|
| | | crentconfig.setBeizhu(config.getBeizhu());
|
| | | }
|
| | | |
| | | configService.update(crentconfig);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | |
|
| | | } catch (Exception e) {
|