记得上下班打卡 | git大法好,push需谨慎

Commit 652fe33f authored by 胡佳晨's avatar 胡佳晨

admin smile-impl 下线接口提交

parent d94858e1
......@@ -168,6 +168,13 @@ public class SmileVolunteersController extends BaseController {
return volunteersProjectService.updateData(param);
}
@PostMapping("project/status")
@ApiOperation("活动修改状态")
@ResponseBody
public AjaxResult updateProject(String projectId, Integer status) {
return volunteersProjectService.updateStatus(projectId, status);
}
@GetMapping("project/details/{projectId}")
@ApiOperation("活动详情")
@ApiImplicitParams({
......@@ -212,7 +219,7 @@ public class SmileVolunteersController extends BaseController {
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mid", value = "mid"),
})
public String detailsVolunteers(@PathVariable("mid")String mid, ModelMap mmap) {
public String detailsVolunteers(@PathVariable("mid") String mid, ModelMap mmap) {
SmileVolunteersDetailsVo data = volunteersService.details(mid);
mmap.put("smileVolunteersDetailsVo", data);
AjaxResult ajaxResult = volunteersTeamService.getListByProjectId(data.getProjectId());
......
......@@ -86,12 +86,24 @@
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>管理</a> ');
if (row.status == 1) {
actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="f(\'' + row.projectId + '\',0)"><i class="fa fa-remove"></i>下线</a>');
} else {
actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="f(\'' + row.projectId + '\',1)"><i class="fa fa-remove"></i>上线</a>');
}
return actions.join('');
}
}]
};
$.table.init(options);
});
function f(a1, a2) {
$.post(smilePrefix +"/project/status", {projectId: a1, status: a2}, function (res) {
alert(res.msg);
location.reload();
});
}
</script>
</body>
</html>
......@@ -32,4 +32,7 @@ public interface ISmileVolunteersProjectService extends IService<SmileVolunteers
//活动详情
SmileProjectDetailsVo details(String projectId);
//活动状态修改
AjaxResult updateStatus(String projectId,Integer status);
}
......@@ -137,6 +137,20 @@ public class SmileVolunteersProjectServiceImpl extends ServiceImpl<SmileVoluntee
return SmileProjectDetailsVo.getNew().copy(data, smileVolunteersTeamList);
}
@Override
public AjaxResult updateStatus(String projectId, Integer status) {
LambdaQueryWrapper<SmileVolunteersProject> wrappers = Wrappers.lambdaQuery(SmileVolunteersProject.class);
SmileVolunteersProject smileVolunteersProject = SmileVolunteersProject.getNew();
smileVolunteersProject.setStatus(status);
volunteersProjectMapper.update(smileVolunteersProject, wrappers.eq(SmileVolunteersProject::getProjectId, projectId));
if(status==1){
redisUtils.addProjectId(projectId);
}else{
redisUtils.delProjectId(projectId);
}
return AjaxResult.success("修改成功");
}
private SmileVolunteersProject copySmileVolunteersProject(SmileVPParam source, LocalDateTime ct, LocalDateTime ut) {
SmileVolunteersProject smileVolunteersProject = SmileVolunteersProject.getNew();
smileVolunteersProject.setProjectId(source.getProjectId());
......
......@@ -61,6 +61,11 @@ public class SmileVolunteersProject implements Serializable, Cloneable {
*/
private String img;
/**
* 状态[1-上线|0-下线]
*/
private Integer status;
/**
* 补充字段
*/
......
......@@ -41,6 +41,7 @@ CREATE TABLE `smile_volunteers_project`
`address` varchar(256) DEFAULT '' COMMENT '活动地址',
`introduce` varchar(1028) DEFAULT '' COMMENT '活动介绍',
`img` varchar(256) DEFAULT '' COMMENT '封面图',
`status` tinyint(2) DEFAULT 1 COMMENT '状态[1-上线|0-下线]',
`comment` varchar(255) DEFAULT '' COMMENT '补充字段',
`created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
......
......@@ -22,10 +22,7 @@ import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
......@@ -48,10 +45,11 @@ public class SmileVolunteerServerImpl implements SmileVolunteersService {
SmileProjectDetailsVo redisData = smileRedisUtils.getProject(projectId);
ArrayList<String> teamIds = smileRedisUtils.getVolunteers(projectId, uid);
SmileVProjectListVo vo = SmileVProjectListVo.getNew().copy(redisData, teamIds == null ? 0 : 1);
if (LocalDateTime.now().isBefore(LocalDateTime.parse(vo.getTimeEnd(), DTF_YMD_HMS))) {
voList.add(vo);
}
// if (LocalDateTime.now().isBefore(LocalDateTime.parse(vo.getTimeEnd(), DTF_YMD_HMS))) {
voList.add(vo);
// }
}
voList = voList.stream().sorted(Comparator.comparing(SmileVProjectListVo::getTimeStart)).collect(Collectors.toList());
return ResponseDto.success(voList);
}
......
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