Просмотр исходного кода

新增标签弹窗接口

release_toaliyun_real
jinguo24@163.com 7 лет назад
Родитель
Сommit
e601e7e0eb
6 измененных файлов: 152 добавлений и 52 удалений
  1. +83
    -45
      mallinkAdmin/src/main/java/com/simple/controller/WxTagsController.java
  2. +34
    -0
      mallinkService/src/main/java/com/simple/domain/vo/WxTagsVo.java
  3. +6
    -2
      mallinkService/src/main/java/com/simple/mapper/WxTagsMapper.java
  4. +11
    -1
      mallinkService/src/main/java/com/simple/service/WxTagsService.java
  5. +11
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxTagsServiceImpl.java
  6. +7
    -4
      mallinkService/src/main/resources/mapper/WxTagsMapper.xml

+ 83
- 45
mallinkAdmin/src/main/java/com/simple/controller/WxTagsController.java Просмотреть файл

@@ -1,70 +1,108 @@
package com.simple.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;

import com.simple.domain.po.WxTags;
import com.simple.domain.vo.WxTagsVo;
import com.simple.service.WxTagsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("wxTags")
@Api(description="标签弹窗接口")
public class WxTagsController extends BaseController
{
@Autowired
private WxTagsService wxTagsService;

private Logger logger = Logger.getLogger(WxTagsController.class);
@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxTags wxTags,Integer pageNum, Integer pageSize) {
if (null == wxTags) wxTags = new WxTags();
final PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, pageNum, pageSize);
return new ResultData(page);
}

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxTags wxTags) {
//Assert.notNull(wxTags.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxTagsService.saveOrUpdate(wxTags);
return new ResultData();
}

@ApiOperation("根据id更新接口")
@PostMapping("update")
public ResultData update(@RequestBody WxTags wxTags) {
wxTagsService.saveOrUpdate(wxTags);
return new ResultData();
}

@ApiOperation("根据id删除接口")
@GetMapping("/del")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData delete(Long id) {
wxTagsService.deleteById(id);
return new ResultData(Result.SUCCESS, "删除成功", null);
}
@ApiOperation("根据id查询接口")
@GetMapping("/findById")
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS,"查询成功",wxTagsService.getById(id));
@GetMapping("getAllList")
@ApiOperation("标签弹窗接口")
public ResultData getAllList() {
List<WxTagsVo> type1List = new ArrayList<>();
List<WxTags> tags = wxTagsService.findType1Value();
for(WxTags t:tags) {
WxTagsVo vo =new WxTagsVo();
vo.setValue(t.getType1());
List<WxTagsVo> type2List =new ArrayList<>();
List<WxTags> type2s = wxTagsService.findType2Value(t.getType1());
for(WxTags wt:type2s) {
WxTagsVo v = new WxTagsVo();
v.setValue(wt.getType2());
List<WxTagsVo> list = new ArrayList<>();
WxTags tag = new WxTags();
tag.setType2(wt.getType2());
PageInfo<WxTags> page = wxTagsService.listAsPage(tag, 1, 1000);
for(WxTags wxT : page.getList()) {
WxTagsVo wxVo = new WxTagsVo();
wxVo.setValue(wxT.getName());
list.add(wxVo);
}
v.setSubTags(list);
type2List.add(v);
vo.setSubTags(type2List);
}
type1List.add(vo);
}
return new ResultData(Result.SUCCESS,"ok",type1List);
}
// @ApiOperation("分页列表接口")
// @GetMapping("list")
// @ApiImplicitParams({
// @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
// @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
// public ResultData list(@ModelAttribute WxTags wxTags,Integer pageNum, Integer pageSize) {
// if (null == wxTags) wxTags = new WxTags();
// final PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, pageNum, pageSize);
// return new ResultData(page);
// }
//
// @ApiOperation("新增接口")
// @PostMapping("add")
// public ResultData add(@RequestBody WxTags wxTags) {
// //Assert.notNull(wxTags.getName(), "角色名不能为空");
// //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
// wxTagsService.saveOrUpdate(wxTags);
// return new ResultData();
// }
//
// @ApiOperation("根据id更新接口")
// @PostMapping("update")
// public ResultData update(@RequestBody WxTags wxTags) {
// wxTagsService.saveOrUpdate(wxTags);
// return new ResultData();
// }
//
// @ApiOperation("根据id删除接口")
// @GetMapping("/del")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData delete(Long id) {
// wxTagsService.deleteById(id);
// return new ResultData(Result.SUCCESS, "删除成功", null);
// }
//
// @ApiOperation("根据id查询接口")
// @GetMapping("/findById")
// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
// public ResultData findById(Long id) {
// return new ResultData(Result.SUCCESS,"查询成功",wxTagsService.getById(id));
// }


+ 34
- 0
mallinkService/src/main/java/com/simple/domain/vo/WxTagsVo.java Просмотреть файл

@@ -0,0 +1,34 @@
package com.simple.domain.vo;
import java.io.Serializable;
import java.util.List;
public class WxTagsVo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1786459967532225067L;
private String value;
private List<WxTagsVo> subTags;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<WxTagsVo> getSubTags() {
return subTags;
}
public void setSubTags(List<WxTagsVo> subTags) {
this.subTags = subTags;
}
}

+ 6
- 2
mallinkService/src/main/java/com/simple/mapper/WxTagsMapper.java Просмотреть файл

@@ -1,14 +1,18 @@
package com.simple.mapper;

import java.util.*;
import java.util.List;

import com.simple.common.CommonMapper;
import org.apache.ibatis.annotations.Param;
import com.simple.domain.po.WxTags;

public interface WxTagsMapper extends CommonMapper<WxTags, String> {

List<WxTags> findList(WxTags wxTags);
List<WxTags> findType1Value();
List<WxTags> findType2Value(String type1);



+ 11
- 1
mallinkService/src/main/java/com/simple/service/WxTagsService.java Просмотреть файл

@@ -38,8 +38,18 @@ public interface WxTagsService {
*/
void deleteById(Long id);
/**
* 查询第一个属性
* @return
*/
List<WxTags> findType1Value();
/**
* 根据第一个属性获取第二个属性
* @param type1
* @return
*/
List<WxTags> findType2Value(String type1);



+ 11
- 0
mallinkService/src/main/java/com/simple/service/impl/WxTagsServiceImpl.java Просмотреть файл

@@ -43,6 +43,17 @@ public class WxTagsServiceImpl implements WxTagsService {
public void deleteById(Long id) {
wxTagsMapper.deleteByPrimaryKey(id);
}

@Override
public List<WxTags> findType1Value() {
return wxTagsMapper.findType1Value();
}

@Override
public List<WxTags> findType2Value(String type1) {
return wxTagsMapper.findType2Value(type1);
}


+ 7
- 4
mallinkService/src/main/resources/mapper/WxTagsMapper.xml Просмотреть файл

@@ -66,9 +66,12 @@
<include refid="dynamicWhereConditions" />
</select>
<select id="findType1Value" resultMap="BaseResultMap">
select DISTINCT type1 from wx_tags
</select>
<select id="findType2Value" parameterType="String" resultMap="BaseResultMap">
select DISTINCT type2 from wx_tags where type1=#{type1}
</select>
</mapper>

Загрузка…
Отмена
Сохранить