package com.yeshi.fanli.controller.admin; import java.io.PrintWriter; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; 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.bus.recommend.Honest; import com.yeshi.fanli.service.inter.goods.HonestService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.GsonUtil; import org.yeshi.utils.JsonUtil; @Controller @RequestMapping("admin/new/api/v1/honest") public class HonestAdminController { @Resource private HonestService honestService; /** * * 方法说明: 分页获取圆形图标列表 * @author mawurui * createTime 2018年5月18日 下午4:42:26 * @param pageIndex * @param key * @param out */ @RequestMapping(value="/getHonestList",method=RequestMethod.POST) public void getHonestList(int pageIndex, String key,PrintWriter out){ //查询总数 Integer totalCount = honestService.getCount(); int totalPage = totalCount % Constant.PAGE_SIZE == 0 ? totalCount / Constant.PAGE_SIZE : totalCount / Constant.PAGE_SIZE + 1; PageEntity pageEntity = new PageEntity(pageIndex, Constant.PAGE_SIZE, totalCount, totalPage); Map map = new HashMap(); map.put("key", key); pageEntity.setParams(map); //分页查询所有榜单用户 List honestList = honestService.getHonestList(pageIndex-1, key); JSONObject data=new JSONObject(); data.put("pageEntity", JsonUtil.getSimpleGsonWithDate().toJson(pageEntity)); data.put("honestList", JsonUtil.getSimpleGsonWithDate().toJson(honestList)); out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功")); } /** * * 方法说明: 删除 * @author mawurui * createTime 2018年5月18日 下午5:19:28 * @param ids * @param out */ @RequestMapping(value="/deleteHonest", method=RequestMethod.POST) public void deleteHonest(long[] ids, PrintWriter out){ for (long id : ids) { honestService.deleteHonest(id); } out.print(JsonUtil.loadTrueResult("删除成功")); } /** * * 方法说明: 修改 * @author mawurui * createTime 2018年5月22日 下午4:27:28 * @param honest * @param out */ @RequestMapping(value="/updateHonest", method=RequestMethod.POST) public void updateHonest(Honest honest , PrintWriter out) { honestService.updateHonest(honest); out.print(JsonUtil.loadTrueResult("修改成功啦!")); } /** * * 方法说明: 页面反显编辑数据 * @author mawurui * createTime 2018年3月30日 上午9:32:52 * @param id * @return */ @RequestMapping(value="/getHonest", method=RequestMethod.POST) public void getHonest(long id, PrintWriter out) { Honest honest = honestService.getHonest(id); JSONObject data = new JSONObject(); data.put("honest", GsonUtil.toDFJson(honest)); out.print(JsonUtil.loadTrueResult(0, data)); } /** * * 方法说明: 添加 * @author mawurui * createTime 2018年5月18日 下午5:32:46 * @param spreadImg * @param url * @param out */ @RequestMapping(value="/addHonest", method=RequestMethod.POST) public void addHonest(Honest honest, PrintWriter out) { honestService.addHonest(honest); out.print(JsonUtil.loadTrueResult("添加成功")); } }