Jelajahi Sumber

账号申诉

zdm 6 tahun lalu
induk
melakukan
0f0f92bfd9

+ 12 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java

@ -117,6 +117,18 @@ public class HealthyHouseMapping {
            public static final String DOWNLOAD_BY_PATH="/dfs/downloadByPath";
        }
        //账号申诉
        public static class Appeal {
            public static final String CREATE = "/create/appeals";
            public static final String DELETE = "/delete/appeals";
            public static final String UPDATE = "/update/appeals";
            public static final String PAGE = "/page/appeals";
            public static final String LIST = "/list/appeals";
            public static final String GET_APPEAL_BY_ID = "/getAppealById";
            public static final String GET_APPEALS_BY_FIELD = "/getAppealsByField";
            public static final String UPDATE_APPEAL_BY_ID = "/updateAppealById";
        }
    }

+ 121 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/AppealController.java

@ -0,0 +1,121 @@
package com.yihu.jw.healthyhouse.controller.user;
import com.yihu.jw.healthyhouse.model.user.Appeal;
import com.yihu.jw.healthyhouse.service.user.AppealService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.health.house.HealthyHouseMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
/**
 * 账号申诉
 * Created by zdm on 2018/9/26.
 */
@RestController
@RequestMapping(HealthyHouseMapping.api_healthyHouse_common)
@Api(value = "Appeal", description = "账号申诉管理", tags = {"账号申诉管理"})
public class AppealController extends EnvelopRestEndpoint {
    @Autowired
    private AppealService AppealService;
    @ApiOperation(value = "获取账号申诉列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.PAGE)
    public PageEnvelop<Appeal> getAppeals(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<Appeal> appealList = AppealService.search(fields, filters, sorts, page, size);
        return success(appealList, (null == appealList) ? 0 : appealList.size(), page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)账号申诉")
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.CREATE)
    public ObjEnvelop<Appeal> createAppeal(
            @ApiParam(name = "Appeal", value = "账号申诉JSON结构")
            @RequestBody Appeal appeal) throws IOException {
        if(StringUtils.isEmpty(appeal.getCreateUser())){
            return failed("账号申诉人(createUser)不能为空!",ObjEnvelop.class);
        }
        appeal = AppealService.save(appeal);
        return success(appeal);
    }
    @ApiOperation(value = "获取账号申诉")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.GET_APPEAL_BY_ID)
    public ObjEnvelop<Appeal> getAppeal(
            @ApiParam(name = "id", value = "账号申诉ID", defaultValue = "")
            @RequestParam(value = "id") String id) throws Exception {
        Appeal appeal = AppealService.findById(id);
        if (appeal == null) {
            return failed("账号申诉不存在!", ObjEnvelop.class);
        }
        return success(appeal);
    }
    @ApiOperation(value = "管理员根据id获取/或回复账号申诉,需改变账号申诉回复状态")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.UPDATE_APPEAL_BY_ID)
    public ObjEnvelop<Appeal> getAppealAndUpdate(
            @ApiParam(name = "id", value = "账号申诉ID(必要)", defaultValue = "")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "appealJson", value = "账号申诉Json(非必要,有回复内容,需提供。)", defaultValue = "")
            @RequestParam(value = "appealJson", required = false) String appealJson) throws Exception {
        Appeal appealOld = AppealService.findById(id);
        if (appealOld == null) {
            return failed("账号申诉不存在!", ObjEnvelop.class);
        }
        if (StringUtils.isNotEmpty(appealJson)) {
            Appeal appeal = toEntity(appealJson, Appeal.class);
            appealOld.setFlag(2);
            appealOld.setReplyContent(appeal.getReplyContent());
            appealOld.setUpdateUser(appeal.getUpdateUser());
        } else {
            //根据id获取账号申诉,打开申诉信息
            appealOld.setFlag(1);
        }
        appealOld = AppealService.save(appealOld);
        return success(appealOld);
    }
    @ApiOperation(value = "获取账号申诉:根据日期,根据反馈人等")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.GET_APPEALS_BY_FIELD)
    public ListEnvelop<Appeal> getAppealByField(
            @ApiParam(name = "field", value = "查找字段名", required = true)
            @RequestParam(value = "field") String field,
            @ApiParam(name = "value", value = "检索值")
            @RequestParam(value = "value") String value) throws Exception {
        List<Appeal> appealList = AppealService.findByField(field, value);
        return success(appealList);
    }
    @ApiOperation(value = "删除账号申诉")
    @DeleteMapping(value = HealthyHouseMapping.HealthyHouse.Appeal.DELETE)
    public Envelop deleteAppeal(
            @ApiParam(name = "appealId", value = "账号申诉ID")
            @RequestParam(value = "appealId") String appealId) throws Exception {
        Appeal appeal = AppealService.findById(appealId);
        AppealService.delete(appeal);
        return success("success");
    }
}

+ 16 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/AppealDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.healthyhouse.dao.user;
import com.yihu.jw.healthyhouse.model.user.Appeal;
import org.springframework.data.jpa.repository.JpaRepository;
/**
 * 账号申诉
 * @author zdm
 * @version 1.0
 * @created 2018.09.26
 */
public interface AppealDao extends JpaRepository<Appeal, Long> {
    Appeal findById(String id);
}

+ 106 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/Appeal.java

@ -0,0 +1,106 @@
package com.yihu.jw.healthyhouse.model.user;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import org.hibernate.annotations.Formula;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 账号申诉
 * @author zdm
 * @version 1.0
 * @created 2018.09.26
 */
@Entity
@Table(name = "appeal")
public class Appeal extends UuidIdentityEntityWithOperator {
    //账号申诉类型:0手机号无法使用,1收不到验证码,3其他
    @Column(name = "type")
    private String type;
    //问题和建议
    @Column(name = "content")
    private String content;
    //用户电话号码
    @Column(name = "user_telephone")
    private String userTelephone;
    //图片路径
    @Column(name = "img_path")
    private String imgPath;
    // 处理状态:0未阅,1待处理,2已处理,3废弃
    @Column(name = "flag")
    private Integer flag;
    //处理备注
    @Column(name = "reply_content")
    private String replyContent;
    //账号申诉类型值:0手机号无法使用,1收不到验证码,3其他
    private String typeValue;
    // 处理状态值:0未阅,1待处理,2已处理,3废弃
    private String flagValue;
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getUserTelephone() {
        return userTelephone;
    }
    public void setUserTelephone(String userTelephone) {
        this.userTelephone = userTelephone;
    }
    public String getImgPath() {
        return imgPath;
    }
    public void setImgPath(String imgPath) {
        this.imgPath = imgPath;
    }
    public Integer getFlag() {
        return flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
    public String getReplyContent() {
        return replyContent;
    }
    public void setReplyContent(String replyContent) {
        this.replyContent = replyContent;
    }
    @Formula("( SELECT a.value FROM system_dict_entries a WHERE a.dict_id = 9 AND a.code = type )")
    public String getTypeValue() {
        return typeValue;
    }
    public void setTypeValue(String typeValue) {
        this.typeValue = typeValue;
    }
    @Formula("( SELECT a.value FROM system_dict_entries a WHERE a.dict_id = 10 AND a.code = flag )")
    public String getFlagValue() {
        return flagValue;
    }
    public void setFlagValue(String flagValue) {
        this.flagValue = flagValue;
    }
}

+ 28 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/AppealService.java

@ -0,0 +1,28 @@
package com.yihu.jw.healthyhouse.service.user;
import com.yihu.jw.healthyhouse.dao.user.AppealDao;
import com.yihu.jw.healthyhouse.model.user.Appeal;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * 账号申诉.
 *
 * @author zdm
 * @version 1.0
 * @created 2018.09.26
 */
@Service
@Transactional
public class AppealService extends BaseJpaService<Appeal, AppealDao> {
    @Autowired
    private AppealDao AppealDao;
    public Appeal findById(String id) {
        return  AppealDao.findById(id);
    }
}