Commit 45043c49 by 吴迪

Merge remote-tracking branch 'origin/master'

parents eb6dae5f 8e024710
package io.office.modules.manage.controller; package io.office.modules.manage.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.app.annotation.Login; import io.office.modules.app.annotation.Login;
import io.office.modules.manage.entity.PartnersEntity; import io.office.modules.manage.entity.PartnersEntity;
import io.office.modules.manage.entity.dto.NewsParams;
import io.office.modules.sys.controller.AbstractController;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.CasesEntity; import io.office.modules.manage.entity.CasesEntity;
import io.office.modules.manage.service.CasesService; import io.office.modules.manage.service.CasesService;
...@@ -30,7 +31,8 @@ import io.office.common.utils.R; ...@@ -30,7 +31,8 @@ import io.office.common.utils.R;
*/ */
@RestController @RestController
@RequestMapping("/cases") @RequestMapping("/cases")
public class CasesController { @Slf4j
public class CasesController extends AbstractController {
@Autowired @Autowired
private CasesService casesService; private CasesService casesService;
...@@ -54,10 +56,11 @@ public class CasesController { ...@@ -54,10 +56,11 @@ public class CasesController {
*/ */
@RequestMapping("/list") @RequestMapping("/list")
// @RequiresPermissions("manage:cases:list") // @RequiresPermissions("manage:cases:list")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestBody NewsParams params){
PageUtils page = casesService.queryPage(params); Page<CasesEntity> page = this.casesService.selectCaseList(params,
new Page(params.getPage(), params.getLimit()));
return R.ok().put("page", page); PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
} }
...@@ -68,7 +71,6 @@ public class CasesController { ...@@ -68,7 +71,6 @@ public class CasesController {
// @RequiresPermissions("manage:cases:info") // @RequiresPermissions("manage:cases:info")
public R info(@PathVariable("id") Integer id){ public R info(@PathVariable("id") Integer id){
CasesEntity cases = casesService.getById(id); CasesEntity cases = casesService.getById(id);
return R.ok().put("cases", cases); return R.ok().put("cases", cases);
} }
...@@ -78,9 +80,12 @@ public class CasesController { ...@@ -78,9 +80,12 @@ public class CasesController {
@RequestMapping("/save") @RequestMapping("/save")
// @RequiresPermissions("manage:cases:save") // @RequiresPermissions("manage:cases:save")
public R save(@RequestBody CasesEntity cases){ public R save(@RequestBody CasesEntity cases){
cases.setEditor(getUser().getUsername());
cases.setLasteditor(getUser().getUsername());
cases.setRegisterdate(new Date());
cases.setUpdatedate(new Date());
casesService.save(cases); casesService.save(cases);
return R.ok("新增成功!");
return R.ok();
} }
/** /**
...@@ -89,9 +94,11 @@ public class CasesController { ...@@ -89,9 +94,11 @@ public class CasesController {
@RequestMapping("/update") @RequestMapping("/update")
// @RequiresPermissions("manage:cases:update") // @RequiresPermissions("manage:cases:update")
public R update(@RequestBody CasesEntity cases){ public R update(@RequestBody CasesEntity cases){
cases.setEditor(getUser().getUsername());
cases.setLasteditor(getUser().getUsername());
cases.setUpdatedate(new Date());
casesService.updateById(cases); casesService.updateById(cases);
return R.ok("修改成功!");
return R.ok();
} }
/** /**
...@@ -99,12 +106,29 @@ public class CasesController { ...@@ -99,12 +106,29 @@ public class CasesController {
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("manage:cases:delete") // @RequiresPermissions("manage:cases:delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody List<Long> ids){
casesService.removeByIds(Arrays.asList(ids)); try {
R r = this.casesService.delete(ids, getUser());
return R.ok(); return r;
} catch (Exception e) {
log.error("delete error:", e);
return R.error(e.getMessage());
}
}
/**
* 审核
*/
@PostMapping("/verify")
// @RequiresPermissions("manage:partners:delete")
public R verify(@RequestBody CasesEntity casesEntity){
try {
R r = this.casesService.verify(casesEntity, getUser());
return r;
} catch (Exception e) {
log.error("verifyPartners error:", e);
return R.error(e.getMessage());
}
} }
/** /**
* 信息 * 信息
*/ */
......
...@@ -3,6 +3,7 @@ package io.office.modules.manage.dao; ...@@ -3,6 +3,7 @@ package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.CasesEntity; import io.office.modules.manage.entity.CasesEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.office.modules.manage.entity.dto.NewsParams;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -20,4 +21,6 @@ import java.util.List; ...@@ -20,4 +21,6 @@ import java.util.List;
public interface CasesDao extends BaseMapper<CasesEntity> { public interface CasesDao extends BaseMapper<CasesEntity> {
@Select("select * from Cases where status=#{status} and levels>#{levels} order by id desc") @Select("select * from Cases where status=#{status} and levels>#{levels} order by id desc")
List<CasesEntity> selectByStatusAndLevels(@Param("status") String status,@Param("levels") String levels, Page page); List<CasesEntity> selectByStatusAndLevels(@Param("status") String status,@Param("levels") String levels, Page page);
List<CasesEntity> selectCaseList(@Param("newsParams") NewsParams params, Page page);
} }
...@@ -3,7 +3,11 @@ package io.office.modules.manage.service; ...@@ -3,7 +3,11 @@ package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils; import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.CasesEntity; import io.office.modules.manage.entity.CasesEntity;
import io.office.modules.manage.entity.PartnersEntity;
import io.office.modules.manage.entity.dto.NewsParams;
import io.office.modules.sys.entity.SysUserEntity;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -23,5 +27,10 @@ public interface CasesService extends IService<CasesEntity> { ...@@ -23,5 +27,10 @@ public interface CasesService extends IService<CasesEntity> {
Page<CasesEntity> getPageList(Map<String, Object> params); Page<CasesEntity> getPageList(Map<String, Object> params);
Page<CasesEntity> selectCaseList(NewsParams params, Page page);
R delete(List<Long> ids, SysUserEntity user);
R verify(CasesEntity casesEntity, SysUserEntity user);
} }
...@@ -2,9 +2,16 @@ package io.office.modules.manage.service.impl; ...@@ -2,9 +2,16 @@ package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.R;
import io.office.modules.manage.entity.PartnersEntity;
import io.office.modules.manage.entity.dto.NewsParams;
import io.office.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -53,6 +60,44 @@ public class CasesServiceImpl extends ServiceImpl<CasesDao, CasesEntity> impleme ...@@ -53,6 +60,44 @@ public class CasesServiceImpl extends ServiceImpl<CasesDao, CasesEntity> impleme
return casesDao.selectPage(page, queryWrapper); return casesDao.selectPage(page, queryWrapper);
} }
@Override
public Page<CasesEntity> selectCaseList(NewsParams params, Page page) {
List<CasesEntity> list = this.casesDao.selectCaseList(params,page);
page.setRecords(list);
return page;
}
@Override
public R delete(List<Long> ids, SysUserEntity user) {
CasesEntity casesEntity = new CasesEntity();
casesEntity.setUpdatedate(new Date());
casesEntity.setEditor(user.getUsername());
casesEntity.setLasteditor(user.getUsername());
casesEntity.setLevels(0);
QueryWrapper<CasesEntity> partnersEntityQueryWrapper = new QueryWrapper<>();
partnersEntityQueryWrapper.in("id",ids);
int update = this.baseMapper.update(casesEntity, partnersEntityQueryWrapper);
if(update>0){
return R.ok("删除成功!");
}else{
return R.error("删除失败!");
}
}
@Override
public R verify(CasesEntity casesEntity, SysUserEntity user) {
QueryWrapper<CasesEntity> partnersEntityQueryWrapper = new QueryWrapper<>();
partnersEntityQueryWrapper.in("id",casesEntity.getId());
casesEntity.setAuditor(user.getUsername());
casesEntity.setCheckdate(new Date());
int update = this.baseMapper.update(casesEntity, partnersEntityQueryWrapper);
if(update>0){
return R.ok("审核成功!");
}else{
return R.error("审核失败!");
}
}
/* public List<CasesEntity> frontList() { /* public List<CasesEntity> frontList() {
String status="1";//代表审核状态,编辑从后台提交专题后,默认初始状态为status=0,审核成功status=1,审核失败status=-1 String status="1";//代表审核状态,编辑从后台提交专题后,默认初始状态为status=0,审核成功status=1,审核失败status=-1
String levels="0";//levels代表级别,取值从0到9。其中,0代表隐藏,1级以上可以显示,9级为最高级 String levels="0";//levels代表级别,取值从0到9。其中,0代表隐藏,1级以上可以显示,9级为最高级
......
<?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.office.modules.manage.dao.CasesDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.CasesEntity" id="casesMap">
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="brief" column="brief"/>
<result property="service" column="service"/>
<result property="registerdate" column="registerdate"/>
<result property="updatedate" column="updatedate"/>
<result property="showtime" column="showtime"/>
<result property="editor" column="editor"/>
<result property="lasteditor" column="lasteditor"/>
<result property="levels" column="levels"/>
<result property="status" column="status"/>
<result property="auditor" column="auditor"/>
<result property="checkdate" column="checkdate"/>
</resultMap>
<select id="selectCaseList" resultMap="casesMap">
SELECT * from Cases t
WHERE
1=1
<choose>
<when test="newsParams.levels !=null">
AND t.levels = #{newsParams.levels}
</when>
<otherwise>
AND t.levels > 0
</otherwise>
</choose>
<if test="newsParams.releaseTimeStart !=null and newsParams.releaseTimeEnd !=null">
and t.registerdate BETWEEN #{newsParams.releaseTimeStart} AND #{newsParams.releaseTimeEnd}
</if>
<if test="newsParams.updateTimeStart !=null and newsParams.updateTimeEnd !=null">
and t.updatedate BETWEEN #{newsParams.updateTimeStart} AND #{newsParams.updateTimeEnd}
</if>
<if test="newsParams.title !=null and newsParams.title !=''">
and t.title like concat('%',#{newsParams.title},'%')
</if>
<if test="newsParams.status !=null and newsParams.status !=''">
and t.status =#{newsParams.status}
</if>
<if test="newsParams.editor !=null and newsParams.editor !=''">
and t.editor =#{newsParams.editor}
</if>
<if test="newsParams.service !=null and newsParams.service !=''">
and t.service = #{newsParams.service}
</if>
ORDER BY
t.id DESC
</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