Commit e117429a authored by lings's avatar lings

删除重复news模块,修改服务大类及news模块

parent 3d225969
package io.hmit.modules.demo.controller;
import io.hmit.common.annotation.LogOperation;
import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result;
import io.hmit.common.validator.AssertUtils;
import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.demo.dto.NewsDTO;
import io.hmit.modules.demo.service.NewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Arrays;
import java.util.Map;
/**
* 新闻
*
* @author zsh 408538940@qq.com
*/
@RestController
@RequestMapping("demo/news")
@Api(tags = "新闻管理")
public class NewsController {
@Autowired
private NewsService newsService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "title", value = "标题", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String")
})
@RequiresPermissions("demo:news:all")
public Result<PageData<NewsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<NewsDTO> page = newsService.page(params);
return new Result<PageData<NewsDTO>>().ok(page);
}
@ApiOperation("信息")
@GetMapping("{id}")
@RequiresPermissions("demo:news:all")
public Result<NewsDTO> info(@PathVariable("id") Long id) {
NewsDTO news = newsService.get(id);
return new Result<NewsDTO>().ok(news);
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
@RequiresPermissions("demo:news:all")
public Result save(NewsDTO dto) {
//校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
newsService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
@RequiresPermissions("demo:news:all")
public Result update(NewsDTO dto) {
//校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
newsService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
@RequiresPermissions("demo:news:all")
public Result delete(@RequestBody Long[] ids) {
//校验数据
AssertUtils.isArrayEmpty(ids, "id");
newsService.deleteBatchIds(Arrays.asList(ids));
return new Result();
}
}
\ No newline at end of file
package io.hmit.modules.demo.dao;
import io.hmit.common.dao.BaseDao;
import io.hmit.modules.demo.entity.NewsEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 新闻
*
* @author zsh 408538940@qq.com
*/
@Mapper
public interface NewsDao extends BaseDao<NewsEntity> {
List<NewsEntity> getList(Map<String, Object> params);
}
package io.hmit.modules.demo.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
/**
* 新闻管理
*
* @author zsh 408538940@qq.com
*/
@Data
@ApiModel(value = "新闻管理")
public class NewsDTO implements Serializable {
@ApiModelProperty(value = "id")
@Null(message = "{id.null}", groups = AddGroup.class)
@NotNull(message = "{id.require}", groups = UpdateGroup.class)
private Long id;
@ApiModelProperty(value = "标题")
@NotBlank(message = "{news.title.require}", groups = DefaultGroup.class)
private String title;
@ApiModelProperty(value = "内容")
@NotBlank(message = "{news.content.require}", groups = DefaultGroup.class)
private String content;
@ApiModelProperty(value = "发布时间")
private Date pubDate;
@ApiModelProperty(value = "创建时间")
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Date createDate;
}
package io.hmit.modules.demo.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.hmit.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 新闻
*
* @author zsh 408538940@qq.com
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_news")
public class NewsEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 发布时间
*/
private Date pubDate;
/**
* 创建者dept_id
*/
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
}
\ No newline at end of file
package io.hmit.modules.demo.service;
import io.hmit.common.page.PageData;
import io.hmit.common.service.BaseService;
import io.hmit.modules.demo.dto.NewsDTO;
import io.hmit.modules.demo.entity.NewsEntity;
import java.util.Map;
/**
* 新闻
*
* @author zsh 408538940@qq.com
*/
public interface NewsService extends BaseService<NewsEntity> {
PageData<NewsDTO> page(Map<String, Object> params);
NewsDTO get(Long id);
void save(NewsDTO dto);
void update(NewsDTO dto);
}
package io.hmit.modules.demo.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.hmit.common.annotation.DataFilter;
import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.BaseServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.modules.demo.dao.NewsDao;
import io.hmit.modules.demo.dto.NewsDTO;
import io.hmit.modules.demo.entity.NewsEntity;
import io.hmit.modules.demo.service.NewsService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implements NewsService {
/**
* mybatis数据权限演示
*/
@Override
@DataFilter
public PageData<NewsDTO> page(Map<String, Object> params) {
paramsToLike(params, "title");
//分页
IPage<NewsEntity> page = getPage(params, Constant.CREATE_DATE, false);
//查询
List<NewsEntity> list = baseDao.getList(params);
return getPageData(list, page.getTotal(), NewsDTO.class);
}
// /**
// * mybatis-plus数据权限演示
// */
// @Override
// @DataFilter
// public PageData<NewsDTO> page(Map<String, Object> params) {
// IPage<NewsEntity> page = baseDao.selectPage(
// getPage(params, Constant.CREATE_DATE, false),
// getWrapper(params)
// );
// return getPageData(page, NewsDTO.class);
// }
//
// private QueryWrapper<NewsEntity> getWrapper(Map<String, Object> params){
// String title = (String)params.get("title");
// String startDate = (String)params.get("startDate");
// String endDate = (String)params.get("endDate");
//
// QueryWrapper<NewsEntity> wrapper = new QueryWrapper<>();
// wrapper.like(StringUtils.isNotBlank(title), "title", title);
// wrapper.ge(StringUtils.isNotBlank(startDate),"pub_date", startDate);
// wrapper.le(StringUtils.isNotBlank(endDate),"pub_date", endDate);
//
// //数据过滤
// wrapper.apply(params.get(Constant.SQL_FILTER) != null, params.get(Constant.SQL_FILTER).toString());
//
// return wrapper;
// }
@Override
public NewsDTO get(Long id) {
NewsEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, NewsDTO.class);
}
@Override
public void save(NewsDTO dto) {
NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class);
insert(entity);
}
@Override
public void update(NewsDTO dto) {
NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class);
updateById(entity);
}
}
......@@ -55,6 +55,18 @@ public class PensionServiceTypeController {
return new Result<PageData<PensionServiceTypeDTO>>().ok(page);
}
@GetMapping("getServiceTypeList")
@ApiOperation("查询")
@ApiImplicitParams({
@ApiImplicitParam(name = "keyword", value = "查询字段,", paramType = "query", dataType="String")
})
public Result<List<PensionServiceTypeDTO>> getServiceTypeList(@ApiIgnore @RequestParam Map<String, Object> params){
List<PensionServiceTypeDTO> pensionServiceTypeDTOList = pensionServiceTypeService.list(params);
return new Result<List<PensionServiceTypeDTO>>().ok(pensionServiceTypeDTOList);
}
@GetMapping("{id}")
@ApiOperation("信息")
@RequiresPermissions("serviceOrder:pensionservicetype:info")
......@@ -113,4 +125,4 @@ public class PensionServiceTypeController {
ExcelUtils.exportExcelToTarget(response, null, list, PensionServiceTypeExcel.class);
}
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@ public class PensionServiceServiceImpl extends CrudServiceImpl<PensionServiceDao
QueryWrapper<PensionServiceEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
wrapper.eq(StringUtils.isNotBlank(serviceType), "service_type_id", serviceType);
wrapper.like(StringUtils.isNotBlank(serviceType), "name", keyword);
wrapper.like(StringUtils.isNotBlank(keyword), "name", keyword);
......
......@@ -23,12 +23,14 @@ public class PensionServiceTypeServiceImpl extends CrudServiceImpl<PensionServic
@Override
public QueryWrapper<PensionServiceTypeEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
String keyword = (String)params.get("keyword");
QueryWrapper<PensionServiceTypeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
wrapper.like(StringUtils.isNotBlank(keyword), "name", keyword);
return wrapper;
}
}
\ No newline at end of file
}
<?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="io.hmit.modules.demo.dao.NewsDao">
<select id="getList" resultType="io.hmit.modules.demo.entity.NewsEntity">
select * from tb_news where 1 = 1
<if test="title != null and title.trim() != ''">
and title like #{title}
</if>
<if test="startDate != null and startDate.trim() != ''">
and pub_date >= #{startDate}
</if>
<if test="endDate != null and endDate.trim() != ''">
<![CDATA[and pub_date <= #{endDate}]]>
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment