diff --git a/src/main/java/cn/chjyj/szwh/bean/Classify.java b/src/main/java/cn/chjyj/szwh/bean/Classify.java new file mode 100644 index 0000000..0c19996 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/bean/Classify.java @@ -0,0 +1,103 @@ +package cn.chjyj.szwh.bean; + +import java.io.Serializable; +import java.util.Date; + +/** + * 文化数据 + */ +public class Classify implements Serializable { + /** + * classify + * id,top_class as topClass,son_class as sonClass,user_id as userId,`status`,createtime,is_deleted as isDeleted + */ + private Integer id; + + /** + * 一级分类 + */ + private String topClass; + + /** + * 二级分类 + */ + private String sonClass; + + /** + * 创建用户 + */ + private Integer userId; + + /** + * 状态;0:启用;1:启用 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createtime; + + /** + * 删除;0:未删除;1:删除 + */ + private Integer isDeleted; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTopClass() { + return topClass; + } + + public void setTopClass(String topClass) { + this.topClass = topClass; + } + + public String getSonClass() { + return sonClass; + } + + public void setSonClass(String sonClass) { + this.sonClass = sonClass; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreatetime() { + return createtime; + } + + public void setCreatetime(Date createtime) { + this.createtime = createtime; + } + + public Integer getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Integer isDeleted) { + this.isDeleted = isDeleted; + } +} \ No newline at end of file diff --git a/src/main/java/cn/chjyj/szwh/controller/admin/AdminClassifyController.java b/src/main/java/cn/chjyj/szwh/controller/admin/AdminClassifyController.java new file mode 100644 index 0000000..ffa694c --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/controller/admin/AdminClassifyController.java @@ -0,0 +1,41 @@ +package cn.chjyj.szwh.controller.admin; + +import cn.chjyj.szwh.bean.Classify; +import cn.chjyj.szwh.controller.BaseController; +import cn.chjyj.szwh.service.ClassifyService; +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 文化分类控制器 + */ +@RestController +@RequestMapping("/admin/culture.Classify") +public class AdminClassifyController extends BaseController { + @Autowired + private ClassifyService classifyService; + + /** + * 分类列表 + * @param marking + * @param page + * @return + */ + @RequestMapping("/infoList") + public JSONObject infolist(String marking,@RequestParam(value = "page",defaultValue = "1") String page){ + int ipage=Integer.valueOf(page); + Map map = new HashMap<>(); + List classifyList = classifyService.getClassifyList(map,ipage); + jsonObject.put("code",200); + jsonObject.put("msg","请求成功"); + jsonObject.put("data",classifyList); + return jsonObject; + } +} diff --git a/src/main/java/cn/chjyj/szwh/mapper/ClassifyMapper.java b/src/main/java/cn/chjyj/szwh/mapper/ClassifyMapper.java new file mode 100644 index 0000000..a48b450 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/mapper/ClassifyMapper.java @@ -0,0 +1,25 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.Classify; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +/** + * 文化分类 + */ +@Component +public interface ClassifyMapper { + /** + * 多条件分页查询 + * @param qmap + * @param startRs + * @param pageSize + * @return + */ + List getClassifyList(@Param("map") Map qmap, + @Param("startRs") Integer startRs, + @Param("pageSize") int pageSize); +} diff --git a/src/main/java/cn/chjyj/szwh/service/ClassifyService.java b/src/main/java/cn/chjyj/szwh/service/ClassifyService.java new file mode 100644 index 0000000..0998f1e --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/ClassifyService.java @@ -0,0 +1,19 @@ +package cn.chjyj.szwh.service; + +import cn.chjyj.szwh.bean.Classify; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 文化分类服务接口 + */ +public interface ClassifyService { + /** + * 多条件分页查询 + * @param qmap + * @return + */ + List getClassifyList(Map qmap,Integer page); +} diff --git a/src/main/java/cn/chjyj/szwh/service/impl/ClassifyServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/ClassifyServiceImpl.java new file mode 100644 index 0000000..ad124ee --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/impl/ClassifyServiceImpl.java @@ -0,0 +1,23 @@ +package cn.chjyj.szwh.service.impl; + +import cn.chjyj.szwh.bean.Classify; +import cn.chjyj.szwh.constant.ChConstant; +import cn.chjyj.szwh.mapper.ClassifyMapper; +import cn.chjyj.szwh.service.ClassifyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +public class ClassifyServiceImpl implements ClassifyService { + @Autowired + private ClassifyMapper classifyMapper; + + @Override + public List getClassifyList(Map qmap, Integer page) { + int start=page>0?(page-1)* ChConstant.PAGESIZE:0; + return classifyMapper.getClassifyList(qmap,start,ChConstant.PAGESIZE); + } +} diff --git a/src/main/resources/mapper/szwh/ClassifyMapper.xml b/src/main/resources/mapper/szwh/ClassifyMapper.xml new file mode 100644 index 0000000..c2dc6ac --- /dev/null +++ b/src/main/resources/mapper/szwh/ClassifyMapper.xml @@ -0,0 +1,65 @@ + + + + + +id,top_class as topClass,son_class as sonClass,user_id as userId,`status`,createtime,is_deleted as isDeleted + + classify + + + + + + + insert into + + (uname,password,gender,urealname,ubirth,nickname,avatarurl,platfrom,sessionkey,openid) + values ( + #{uname}, + #{password}, + #{gender}, + #{urealname}, + #{ubirth}, + #{nickname}, + #{avatarurl}, + #{platfrom}, + #{sessionkey}, + #{openid} + ) + + + + + update + + + + + ${k} = #{v} + + + + where id=#{id} + + + \ No newline at end of file diff --git a/src/test/java/cn/chjyj/szwh/mapper/ClassifyMapperTest.java b/src/test/java/cn/chjyj/szwh/mapper/ClassifyMapperTest.java new file mode 100644 index 0000000..80a9db5 --- /dev/null +++ b/src/test/java/cn/chjyj/szwh/mapper/ClassifyMapperTest.java @@ -0,0 +1,36 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.Classify; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.*; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class ClassifyMapperTest { + @Autowired + private ClassifyMapper classifyMapper; + + @Test + public void getClassifyList() { + int startrs=0; + int pagesize=10; + // 组装查询条件 + Map map =new HashMap<>(); +// map.put("status",1); + map.put("user_id",2); + List cllist = classifyMapper.getClassifyList(map,startrs,pagesize); + for(Classify c: cllist){ + System.out.println(c.getSonClass()); + } +// System.out.println(cllist.size()); + } +} \ No newline at end of file