提交 2d6f3226 authored 作者: chaoyanjun's avatar chaoyanjun

--no commit message

上级 243a3044
......@@ -5,7 +5,9 @@ import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -15,15 +17,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
import com.zrqx.bg.sysuser.service.bulletin.BulletinColumnService;
import com.zrqx.bg.sysuser.service.bulletin.BulletinContentService;
import com.zrqx.core.constant.sysuser.SysUserRequestPath;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.sysuser.bg.bulletin.BulletinContentForm;
import com.zrqx.core.form.sysuser.bg.bulletin.BulletinContentStatusForm;
import com.zrqx.core.form.sysuser.bg.bulletin.QueryBulletinContentForm;
import com.zrqx.core.form.sysuser.bg.bulletin.UpdateBulletinContentForm;
import com.zrqx.core.model.sysuser.bulletin.BulletinColumn;
import com.zrqx.core.model.sysuser.bulletin.BulletinContent;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
......@@ -40,12 +46,18 @@ public class BulletinContentController {
@Autowired
private BulletinContentService service;
@Autowired
private BulletinColumnService bulletinColumnService;
@ApiOperation(value = "新增", notes = "新增一个")
@PostMapping(value = SysUserRequestPath.SAVE)
public CallBack<Boolean> saveAdsign(@RequestBody BulletinContent entity) {
entity.setTopStatus(0);
entity.setCreateTime(new Date());
if (!service.insert(entity)) {
public CallBack<Boolean> saveAdsign(@RequestBody BulletinContentForm entity) {
BulletinContent record = new BulletinContent();
record.setTopStatus(0);
record.setCreateTime(new Date());
int columnId = bulletinColumnService.getIdByName(entity.getColumnName());
record.setColumnId(columnId);
BeanUtils.copyProperties(entity, record);
if (!service.insert(record)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
......@@ -89,10 +101,14 @@ public class BulletinContentController {
@ApiOperation(value = "修改", notes = "修改")
@PostMapping(value = SysUserRequestPath.UPDATE)
public CallBack<Boolean> update(@RequestBody BulletinContent entity) {
public CallBack<Boolean> update(@RequestBody BulletinContentForm entity) {
BulletinContent record = new BulletinContent();
BulletinContent old = service.selectByPrimaryKey(entity.getId());
entity.setUpdateTime(new Date());
entity.setCreateTime(old.getCreateTime());
record.setUpdateTime(new Date());
record.setCreateTime(old.getCreateTime());
int columnId = bulletinColumnService.getIdByName(entity.getColumnName());
record.setColumnId(columnId);
BeanUtils.copyProperties(entity, record);
if (!service.updateByPrimaryKey(entity)) {
throw new BusinessValidateException("操作失败");
}
......@@ -122,6 +138,8 @@ public class BulletinContentController {
* CallBack.success(service.queryExample(page));
*/
pageParam.setOrderBy("t.topStatus desc, t.releaseTime desc");
int columnId = bulletinColumnService.getIdByName(form.getColumnName());
form.setColumnId(columnId);
return CallBack.success(service.page(form, pageParam));
}
......
package com.zrqx.bg.sysuser.mapper.bulletin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.sysuser.bulletin.BulletinColumn;
/**
......@@ -7,4 +10,19 @@ import com.zrqx.core.model.sysuser.bulletin.BulletinColumn;
*/
public interface BulletinColumnMapper extends BaseMapper<BulletinColumn> {
/**
* 根据栏目名称查id
* @param name
* @return
* @author chyj
* @date: 2019年5月15日 下午4:36:49
*/
@Select(" <script> "
+ " select id from sys_bulletin_column where 1=1 "
+ " <if test='name != null'> "
+ " and name = #{name} "
+ " </if> "
+ " </script> ")
Integer getIdByName(@Param("name") String name);
}
......@@ -7,4 +7,12 @@ import com.zrqx.core.service.BaseService;
*/
public interface BulletinColumnService extends BaseService<BulletinColumn,Integer> {
/**
* 根据栏目名称查id
* @param name
* @return
* @author chyj
* @date: 2019年5月15日 下午4:35:26
*/
Integer getIdByName(String name);
}
......@@ -21,4 +21,16 @@ public class BulletinColumnServiceImpl extends BaseServiceImpl<BulletinColumn,In
return mapper;
}
/**
* 根据栏目名称查id
* @param name
* @return
* @author chyj
* @date: 2019年5月15日 下午4:35:26
*/
@Override
public Integer getIdByName(String name) {
return mapper.getIdByName(name);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论