7 changed files with 312 additions and 0 deletions
@ -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; |
||||
|
} |
||||
|
} |
||||
@ -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<String,Object> map = new HashMap<>(); |
||||
|
List<Classify> classifyList = classifyService.getClassifyList(map,ipage); |
||||
|
jsonObject.put("code",200); |
||||
|
jsonObject.put("msg","请求成功"); |
||||
|
jsonObject.put("data",classifyList); |
||||
|
return jsonObject; |
||||
|
} |
||||
|
} |
||||
@ -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<Classify> getClassifyList(@Param("map") Map<String,Object> qmap, |
||||
|
@Param("startRs") Integer startRs, |
||||
|
@Param("pageSize") int pageSize); |
||||
|
} |
||||
@ -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<Classify> getClassifyList(Map<String,Object> qmap,Integer page); |
||||
|
} |
||||
@ -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<Classify> getClassifyList(Map<String, Object> qmap, Integer page) { |
||||
|
int start=page>0?(page-1)* ChConstant.PAGESIZE:0; |
||||
|
return classifyMapper.getClassifyList(qmap,start,ChConstant.PAGESIZE); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper |
||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="cn.chjyj.szwh.mapper.ClassifyMapper"> |
||||
|
|
||||
|
<sql id="column"> |
||||
|
id,top_class as topClass,son_class as sonClass,user_id as userId,`status`,createtime,is_deleted as isDeleted |
||||
|
</sql> |
||||
|
<sql id="tbName">classify</sql> |
||||
|
|
||||
|
<!--订单条件查询--> |
||||
|
<select id="getClassifyList" parameterType="java.util.Map" resultType="cn.chjyj.szwh.bean.Classify"> |
||||
|
select |
||||
|
<include refid="column"/> |
||||
|
from |
||||
|
<include refid="tbName"/> |
||||
|
<where> |
||||
|
<!-- 查询条件封装在map中,以k-v形式进行查询--> |
||||
|
<foreach collection="map" item="v" index="k" separator="and"> |
||||
|
<if test="v != null and v != ''"> |
||||
|
${k} = #{v} |
||||
|
</if> |
||||
|
</foreach> |
||||
|
<if test="startRs!=null"> |
||||
|
and id>#{startRs} |
||||
|
</if> |
||||
|
</where> |
||||
|
limit #{pageSize} |
||||
|
</select> |
||||
|
|
||||
|
<!--新增用户--> |
||||
|
<insert id="addUser" parameterType="cn.chjyj.szwh.bean.Goods" useGeneratedKeys="true" keyColumn="uid"> |
||||
|
insert into |
||||
|
<include refid="tbName"/> |
||||
|
(uname,password,gender,urealname,ubirth,nickname,avatarurl,platfrom,sessionkey,openid) |
||||
|
values ( |
||||
|
#{uname}, |
||||
|
#{password}, |
||||
|
#{gender}, |
||||
|
#{urealname}, |
||||
|
#{ubirth}, |
||||
|
#{nickname}, |
||||
|
#{avatarurl}, |
||||
|
#{platfrom}, |
||||
|
#{sessionkey}, |
||||
|
#{openid} |
||||
|
) |
||||
|
</insert> |
||||
|
|
||||
|
<!--更新--> |
||||
|
<update id="updateOrderStatus"> |
||||
|
update |
||||
|
<include refid="tbName"/> |
||||
|
<set> |
||||
|
<foreach collection="map" item="v" index="k" separator="and"> |
||||
|
<if test="v != null and v != ''"> |
||||
|
${k} = #{v} |
||||
|
</if> |
||||
|
</foreach> |
||||
|
</set> |
||||
|
where id=#{id} |
||||
|
</update> |
||||
|
|
||||
|
</mapper> |
||||
@ -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<String,Object> map =new HashMap<>(); |
||||
|
// map.put("status",1);
|
||||
|
map.put("user_id",2); |
||||
|
List<Classify> cllist = classifyMapper.getClassifyList(map,startrs,pagesize); |
||||
|
for(Classify c: cllist){ |
||||
|
System.out.println(c.getSonClass()); |
||||
|
} |
||||
|
// System.out.println(cllist.size());
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue