Commit a0cc495d by wangming

Merge branch 'wangming' into '105'

banner

See merge request !9
2 parents 39cb43a7 e8aaf31b
...@@ -46,7 +46,7 @@ public class CourseServiceImpl implements CourseService { ...@@ -46,7 +46,7 @@ public class CourseServiceImpl implements CourseService {
@Override @Override
public void updateCourse(TKzyCourse course, String classIds) { public void updateCourse(TKzyCourse course, String classIds) {
courseMapper.updateByPrimaryKeyWithBLOBs(course); courseMapper.updateByPrimaryKeySelective(course);
TKzyRelationClassExample example = new TKzyRelationClassExample(); TKzyRelationClassExample example = new TKzyRelationClassExample();
example.createCriteria().andRelationIdEqualTo(course.getId()).andTypeEqualTo(1); example.createCriteria().andRelationIdEqualTo(course.getId()).andTypeEqualTo(1);
relationClassMapper.deleteByExample(example); relationClassMapper.deleteByExample(example);
......
package com.server.web.common.service.Impl;
import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyCourseMapper;
import com.server.web.common.mapper.TKzyInformationMapper;
import com.server.web.common.mapper.TKzyRelationClassMapper;
import com.server.web.common.model.*;
import com.server.web.common.service.CourseService;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class InformationServiceImpl implements InformationService {
@Autowired
private TKzyInformationMapper informationMapper;
@Autowired
private TKzyRelationClassMapper relationClassMapper;
@Autowired
private TBaseSecondClassMapper secondClassMapper;
@Override
public void insertInformation(TKzyInformation information, String classIds) {
informationMapper.insertSelective(information);
if(!("").equals(classIds)){
String [] id = classIds.split(",");
TKzyRelationClass relationClass = null;
for (int i=0;i<id.length;i++){
TBaseSecondClass secondClass = secondClassMapper.selectByPrimaryKey(Long.valueOf(id[i]));
relationClass = new TKzyRelationClass();
relationClass.setRelationId(information.getId());
relationClass.setFirstClassId(secondClass.getFirstId());
relationClass.setSecondClassId(secondClass.getId());
relationClass.setCreateDt(new Date());
relationClass.setType(2);
relationClassMapper.insertSelective(relationClass);
}
}
}
@Override
public void updateInformation(TKzyInformation information, String classIds) {
informationMapper.updateByPrimaryKeyWithBLOBs(information);
TKzyRelationClassExample example = new TKzyRelationClassExample();
example.createCriteria().andRelationIdEqualTo(information.getId()).andTypeEqualTo(2);
relationClassMapper.deleteByExample(example);
if(!("").equals(classIds)){
String [] id = classIds.split(",");
TKzyRelationClass relationClass = null;
for (int i=0;i<id.length;i++){
TBaseSecondClass secondClass = secondClassMapper.selectByPrimaryKey(Long.valueOf(id[i]));
relationClass = new TKzyRelationClass();
relationClass.setRelationId(information.getId());
relationClass.setFirstClassId(secondClass.getFirstId());
relationClass.setSecondClassId(secondClass.getId());
relationClass.setCreateDt(new Date());
relationClass.setType(2);
relationClassMapper.insertSelective(relationClass);
}
}
}
}
package com.server.web.common.service;
import com.server.web.common.model.TKzyInformation;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by yinbin on 2018/1/15.
*/
public interface InformationService {
@Transactional
void insertInformation(TKzyInformation information, String classIds);
@Transactional
void updateInformation(TKzyInformation information, String classIds);
}
...@@ -275,6 +275,7 @@ public class CourseController extends BaseController { ...@@ -275,6 +275,7 @@ public class CourseController extends BaseController {
try { try {
Map paramMap = new HashMap<>(); Map paramMap = new HashMap<>();
paramMap.put("id",id); paramMap.put("id",id);
paramMap.put("type",1);
Map map = (Map)openSqlRingsService.selectOne_Rings("com.mapping.queryModel.queryCourseZbInfo",paramMap); Map map = (Map)openSqlRingsService.selectOne_Rings("com.mapping.queryModel.queryCourseZbInfo",paramMap);
List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseClass",paramMap); List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseClass",paramMap);
map.put("classList",classList); map.put("classList",classList);
...@@ -297,6 +298,7 @@ public class CourseController extends BaseController { ...@@ -297,6 +298,7 @@ public class CourseController extends BaseController {
try { try {
Map paramMap = new HashMap<>(); Map paramMap = new HashMap<>();
paramMap.put("id",id); paramMap.put("id",id);
paramMap.put("type",1);
Map map = (Map)openSqlRingsService.selectOne_Rings("com.mapping.queryModel.queryCourseLbInfo",paramMap); Map map = (Map)openSqlRingsService.selectOne_Rings("com.mapping.queryModel.queryCourseLbInfo",paramMap);
List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseClass",paramMap); List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseClass",paramMap);
map.put("classList",classList); map.put("classList",classList);
......
package com.server.web.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.server.shiro.persistent.bean.SysUser;
import com.server.utils.DateUtils;
import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyCourseMapper;
import com.server.web.common.mapper.TKzyInformationMapper;
import com.server.web.common.model.PageModel;
import com.server.web.common.model.TBaseSecondClass;
import com.server.web.common.model.TKzyCourse;
import com.server.web.common.model.TKzyInformation;
import com.server.web.common.service.CourseService;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 资讯管理
*/
@RestController
@RequestMapping(BaseController.OSS_NAMESPACE + "/information")
public class InformationController extends BaseController {
@Autowired
private TKzyInformationMapper informationMapper;
@Autowired
private InformationService informationService;
@Autowired
private TBaseSecondClassMapper secondClassMapper;
/**
* 资讯列表
* @param title
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping(path = "/zbList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map zbList(@RequestParam(defaultValue = "") String title
,@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "1") Integer pageSize) {
try {
Map paramMap = new HashMap<>();
if(!("").equals(title)){
paramMap.put("title","%"+title+"%");
}
PageHelper.startPage(pageNo,pageSize,true,false);
List list = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryInformation",paramMap);
PageInfo pageInfo = new PageInfo(list);
PageModel model = new PageModel();
model.setTotal(pageInfo.getTotal());
model.setList(list);
return success(model);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 删除资讯
* @param id
* @return
*/
@ResponseBody
@RequestMapping(path = "/deleteInformation", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map deleteInformation(@RequestParam long id) {
try {
TKzyInformation information = new TKzyInformation();
information.setId(id);
information.setIsDelete(1);
information.setUpdateDt(new Date());
informationMapper.updateByPrimaryKeySelective(information);
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
@ResponseBody
@RequestMapping(path = "/saveInformation", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map saveInformation(@RequestParam(defaultValue = "-1") long id,@RequestParam String title,@RequestParam String author,@RequestParam String content,
@RequestParam String picUrl,@RequestParam String iconUrl,@RequestParam(defaultValue = "") String classIds
) {
try {
String [] ids = classIds.split(",");
boolean flag = true;
for (int i=0;i<ids.length;i++){
TBaseSecondClass secondClass = secondClassMapper.selectByPrimaryKey(Long.valueOf(ids[i]));
if(secondClass.getType()!=1){
flag = false;
break;
}
}
if(!flag){
return error("0","分类类型不匹配","分类类型不匹配");
}
TKzyInformation information = new TKzyInformation();
information.setTitle(title);
information.setPicUrl(picUrl);
information.setAuthor(author);
// information.setContent();
information.setIconUrl(iconUrl);
if(id != -1){ //修改
information.setId(id);
information.setUpdateDt(new Date());
informationService.updateInformation(information,classIds);
}else{ //添加
information.setCreateDt(new Date());
information.setIsDelete(0);
informationService.insertInformation(information,classIds);
}
return success("操作成功");
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
/**
* 资讯详情
* @param id
* @return
*/
@ResponseBody
@RequestMapping(path = "/informationInfo", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
public Map informationInfo(@RequestParam long id) {
try {
Map paramMap = new HashMap<>();
paramMap.put("id",id);
paramMap.put("type",2);
Map map = (Map)openSqlRingsService.selectOne_Rings("com.mapping.queryModel.queryInformationInfo",paramMap);
List classList = openSqlRingsService.selectList_Rings("com.mapping.queryModel.queryCourseClass",paramMap);
map.put("classList",classList);
return success(map);
} catch (Exception e) {
e.printStackTrace();
return error("0","系统异常",null);
}
}
}
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
t_kzy_relation_class t t_kzy_relation_class t
LEFT JOIN t_base_first_class t1 ON t1.id= t.first_class_id LEFT JOIN t_base_first_class t1 ON t1.id= t.first_class_id
LEFT JOIN t_base_second_class t2 ON t2.id = t.second_class_id LEFT JOIN t_base_second_class t2 ON t2.id = t.second_class_id
where t.type =1 where t.type = #{type,jdbcType=INTEGER}
AND t.relation_id = #{id,jdbcType=BIGINT} AND t.relation_id = #{id,jdbcType=BIGINT}
ORDER BY t.create_dt ASC ORDER BY t.create_dt ASC
</select> </select>
...@@ -204,4 +204,37 @@ ...@@ -204,4 +204,37 @@
WHERE c.course_type = 2 WHERE c.course_type = 2
AND c.id = #{id,jdbcType=BIGINT} AND c.id = #{id,jdbcType=BIGINT}
</select> </select>
<select id="queryInformation" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.title,
c.author,
c.pic_url AS picUrl,
c.icon_url AS iconUrl,
date_format(c.create_dt,'%Y-%m-%d %H:%i:%S') createDt
FROM
t_kzy_information c
WHERE c.is_delete = 0
<if test="title != null">
AND c.title LIKE #{title}
</if>
ORDER BY c.create_dt DESC
</select>
<select id="queryInformationInfo" resultType="java.util.HashMap" parameterType="java.util.HashMap">
SELECT
c.id,
c.title,
c.author,
c.pic_url AS picUrl,
c.icon_url AS iconUrl,
c.content
FROM
t_kzy_information c
WHERE c.id = #{id,jdbcType=BIGINT}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!