-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
306 additions
and
2 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/main/java/com/topie/zhongkexie/core/api/ScoreIndexCollectionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.topie.zhongkexie.core.api; | ||
|
||
import java.util.Set; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import com.github.pagehelper.PageInfo; | ||
import com.topie.zhongkexie.common.utils.PageConvertUtil; | ||
import com.topie.zhongkexie.common.utils.ResponseUtil; | ||
import com.topie.zhongkexie.common.utils.Result; | ||
import com.topie.zhongkexie.core.service.IScoreIndexCollectionService; | ||
import com.topie.zhongkexie.core.service.IScorePaperService; | ||
import com.topie.zhongkexie.database.core.model.ScoreIndexCollection; | ||
|
||
/** | ||
* Created by wangJL on 2018/3/30. | ||
*/ | ||
@Controller | ||
@RequestMapping("/api/core/scoreIndexCollection") | ||
public class ScoreIndexCollectionController { | ||
|
||
@Autowired | ||
private IScoreIndexCollectionService iScoreIndexCollectionService; | ||
@Autowired | ||
private IScorePaperService paperService; | ||
|
||
@RequestMapping(value = "/list", method = RequestMethod.GET) | ||
@ResponseBody | ||
public Result list(ScoreIndexCollection scoreIndexCollection, | ||
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum, | ||
@RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize) { | ||
PageInfo<ScoreIndexCollection> pageInfo = iScoreIndexCollectionService.selectByFilterAndPage(scoreIndexCollection, pageNum, pageSize); | ||
return ResponseUtil.success(PageConvertUtil.grid(pageInfo)); | ||
} | ||
|
||
@RequestMapping(value = "/insert", method = RequestMethod.POST) | ||
@ResponseBody | ||
public Result insert(ScoreIndexCollection scoreIndexCollection) { | ||
scoreIndexCollection.setContentJson(paperService.getContentJson(scoreIndexCollection.getPaperId(), scoreIndexCollection.getIndexCollection(), null).toJSONString()); | ||
int result = iScoreIndexCollectionService.saveNotNull(scoreIndexCollection); | ||
return result > 0 ? ResponseUtil.success() : ResponseUtil.error(); | ||
} | ||
|
||
@RequestMapping(value = "/update", method = RequestMethod.POST) | ||
@ResponseBody | ||
public Result update(ScoreIndexCollection scoreIndexCollection) { | ||
scoreIndexCollection.setContentJson(paperService.getContentJson(scoreIndexCollection.getPaperId(), scoreIndexCollection.getIndexCollection(), null).toJSONString()); | ||
iScoreIndexCollectionService.updateNotNull(scoreIndexCollection); | ||
return ResponseUtil.success(); | ||
} | ||
|
||
@RequestMapping(value = "/load/{id}", method = RequestMethod.GET) | ||
@ResponseBody | ||
public Result load(@PathVariable(value = "id") Integer id) { | ||
ScoreIndexCollection scoreIndexCollection = iScoreIndexCollectionService.selectByKey(id); | ||
return ResponseUtil.success(scoreIndexCollection); | ||
} | ||
|
||
@RequestMapping(value = "/delete", method = RequestMethod.GET) | ||
@ResponseBody | ||
public Result delete(@RequestParam(value = "id") Integer id) { | ||
iScoreIndexCollectionService.delete(id); | ||
return ResponseUtil.success(); | ||
} | ||
|
||
@RequestMapping("getSelectedNodesId") | ||
@ResponseBody | ||
public Result getSelectedNodesId(Integer paperId,@RequestParam(required=false,value="id") Integer id){ | ||
Set set = this.iScoreIndexCollectionService.getSelectedNodesId(paperId,id); | ||
return ResponseUtil.success(set); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/topie/zhongkexie/core/service/IScoreIndexCollectionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.topie.zhongkexie.core.service; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import com.github.pagehelper.PageInfo; | ||
import com.topie.zhongkexie.common.baseservice.IService; | ||
import com.topie.zhongkexie.database.core.model.ScoreIndexCollection; | ||
|
||
public interface IScoreIndexCollectionService extends IService<ScoreIndexCollection>{ | ||
|
||
PageInfo<ScoreIndexCollection> selectByFilterAndPage( | ||
ScoreIndexCollection scoreIndexCollection, int pageNum, int pageSize); | ||
|
||
List selectByFilter(ScoreIndexCollection scoreIndexCollection); | ||
|
||
Set getSelectedNodesId(Integer paperId, Integer id); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/topie/zhongkexie/core/service/impl/ScoreIndexCollectionServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.topie.zhongkexie.core.service.impl; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.springframework.stereotype.Service; | ||
|
||
import tk.mybatis.mapper.entity.Example; | ||
import tk.mybatis.mapper.entity.Example.Criteria; | ||
import tk.mybatis.mapper.util.StringUtil; | ||
|
||
import com.github.pagehelper.PageHelper; | ||
import com.github.pagehelper.PageInfo; | ||
import com.topie.zhongkexie.common.baseservice.impl.BaseService; | ||
import com.topie.zhongkexie.core.service.IScoreIndexCollectionService; | ||
import com.topie.zhongkexie.database.core.model.ScoreIndexCollection; | ||
|
||
@Service | ||
public class ScoreIndexCollectionServiceImpl extends BaseService<ScoreIndexCollection> implements IScoreIndexCollectionService { | ||
|
||
@Override | ||
public List<ScoreIndexCollection> selectByFilter(ScoreIndexCollection dict) { | ||
Example ex = new Example(ScoreIndexCollection.class); | ||
Criteria c = ex.createCriteria(); | ||
if(StringUtils.isNotEmpty(dict.getName()))c.andLike("name", "%"+dict.getName()+"%"); | ||
if(dict.getPaperId()!=null)c.andEqualTo("paperId", dict.getPaperId()); | ||
return getMapper().selectByExample(ex); | ||
} | ||
|
||
@Override | ||
public PageInfo<ScoreIndexCollection> selectByFilterAndPage(ScoreIndexCollection dict, int pageNum, | ||
int pageSize) { | ||
PageHelper.startPage(pageNum, pageSize); | ||
List<ScoreIndexCollection> list = selectByFilter(dict); | ||
return new PageInfo<ScoreIndexCollection>(list); | ||
} | ||
|
||
@Override | ||
public Set getSelectedNodesId(Integer paperId, Integer id) { | ||
Example ex = new Example(ScoreIndexCollection.class); | ||
Criteria c = ex.createCriteria(); | ||
c.andEqualTo("paperId", paperId); | ||
if(id!=null){ | ||
c.andNotEqualTo("id", id); | ||
} | ||
List<ScoreIndexCollection> list = getMapper().selectByExample(ex); | ||
Set set = new HashSet(); | ||
for(ScoreIndexCollection s:list){ | ||
String indexs = s.getIndexCollection(); | ||
if(StringUtil.isNotEmpty(indexs)) | ||
for(String indexid:indexs.split(",")) | ||
set.add(indexid); | ||
} | ||
return set; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/topie/zhongkexie/database/core/dao/ScoreIndexCollectionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.topie.zhongkexie.database.core.dao; | ||
|
||
import com.topie.zhongkexie.database.core.model.ScoreIndexCollection; | ||
import tk.mybatis.mapper.common.Mapper; | ||
|
||
public interface ScoreIndexCollectionMapper extends Mapper<ScoreIndexCollection> { | ||
} |
124 changes: 124 additions & 0 deletions
124
src/main/java/com/topie/zhongkexie/database/core/model/ScoreIndexCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package com.topie.zhongkexie.database.core.model; | ||
|
||
import javax.persistence.*; | ||
|
||
@Table(name = "d_score_index_collection") | ||
public class ScoreIndexCollection { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
private String name; | ||
|
||
@Column(name = "paper_id") | ||
private Integer paperId; | ||
|
||
private String description; | ||
|
||
@Column(name = "item_collection") | ||
private String itemCollection; | ||
|
||
@Column(name = "index_collection") | ||
private String indexCollection; | ||
|
||
@Column(name = "content_json") | ||
private String contentJson; | ||
|
||
/** | ||
* @return id | ||
*/ | ||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* @param id | ||
*/ | ||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* @return name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* @param name | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* @return paper_id | ||
*/ | ||
public Integer getPaperId() { | ||
return paperId; | ||
} | ||
|
||
/** | ||
* @param paperId | ||
*/ | ||
public void setPaperId(Integer paperId) { | ||
this.paperId = paperId; | ||
} | ||
|
||
/** | ||
* @return description | ||
*/ | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
/** | ||
* @param description | ||
*/ | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* @return item_collection | ||
*/ | ||
public String getItemCollection() { | ||
return itemCollection; | ||
} | ||
|
||
/** | ||
* @param itemCollection | ||
*/ | ||
public void setItemCollection(String itemCollection) { | ||
this.itemCollection = itemCollection; | ||
} | ||
|
||
/** | ||
* @return index_collection | ||
*/ | ||
public String getIndexCollection() { | ||
return indexCollection; | ||
} | ||
|
||
/** | ||
* @param indexCollection | ||
*/ | ||
public void setIndexCollection(String indexCollection) { | ||
this.indexCollection = indexCollection; | ||
} | ||
|
||
/** | ||
* @return content_json | ||
*/ | ||
public String getContentJson() { | ||
return contentJson; | ||
} | ||
|
||
/** | ||
* @param contentJson | ||
*/ | ||
public void setContentJson(String contentJson) { | ||
this.contentJson = contentJson; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/resources/mapper/core/ScoreIndexCollectionMapper.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?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="com.topie.zhongkexie.database.core.dao.ScoreIndexCollectionMapper" > | ||
<resultMap id="BaseResultMap" type="com.topie.zhongkexie.database.core.model.ScoreIndexCollection" > | ||
<!-- | ||
WARNING - @mbggenerated | ||
--> | ||
<id column="id" property="id" jdbcType="INTEGER" /> | ||
<result column="name" property="name" jdbcType="VARCHAR" /> | ||
<result column="paper_id" property="paperId" jdbcType="INTEGER" /> | ||
<result column="description" property="description" jdbcType="VARCHAR" /> | ||
<result column="item_collection" property="itemCollection" jdbcType="VARCHAR" /> | ||
<result column="index_collection" property="indexCollection" jdbcType="VARCHAR" /> | ||
<result column="content_json" property="contentJson" jdbcType="VARCHAR" /> | ||
</resultMap> | ||
</mapper> |