| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- package system
- import (
- "dashoo.cn/backend/api/business/baseUser"
- "dashoo.cn/backend/api/business/items"
- "dashoo.cn/backend/api/business/organize"
- "dashoo.cn/backend/api/business/role"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/business2/userRole"
- "dashoo.cn/utils"
- "encoding/json"
- "strings"
- "dashoo.cn/backend/api/business/auditsetting"
- "time"
- )
- type OilAuditSettingController struct {
- BaseController
- }
- // @Title 获取列表
- // @Description get user by token
- // @Success 200 {object} []auditsetting.BaseOilAuditSetting
- // @router /list [get]
- func (this *OilAuditSettingController) GetEntityList() {
- //获取分页信息
- page := this.GetPageInfoForm()
- where := " 1=1 "
- orderby := "Id"
- asc := false
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- OrganizeId := this.GetString("OrganizeId")
- OrganizeName := this.GetString("OrganizeName")
- AuditStepCode := this.GetString("AuditStepCode")
- AuditStepName := this.GetString("AuditStepName")
- RoleId := this.GetString("RoleId")
- RoleName := this.GetString("RoleName")
- WorkFlowCord := this.GetString("WorkFlowCord")
- WorkFlowName := this.GetString("WorkFlowName")
- Remark := this.GetString("Remark")
- CreateOn := this.GetString("CreateOn")
- OrganizeId = this.User.DepartmentId //无权限看所有时,只看当前部门的数据
- if OrganizeId != "" {
- where = where + " and OrganizeId = '" + OrganizeId + "'"
- }
- if OrganizeName != "" {
- where = where + " and OrganizeName like '%" + OrganizeName + "%'"
- }
- if AuditStepCode != "" {
- where = where + " and AuditStepCode like '%" + AuditStepCode + "%'"
- }
- if AuditStepName != "" {
- where = where + " and AuditStepName like '%" + AuditStepName + "%'"
- }
- if RoleId != "" {
- where = where + " and RoleId like '%" + RoleId + "%'"
- }
- if RoleName != "" {
- where = where + " and RoleName like '%" + RoleName + "%'"
- }
- if WorkFlowCord != "" {
- where = where + " and WorkFlowCord like '%" + WorkFlowCord + "%'"
- }
- if WorkFlowName != "" {
- where = where + " and WorkFlowName like '%" + WorkFlowName + "%'"
- }
- if Remark != "" {
- where = where + " and Remark like '%" + Remark + "%'"
- }
- if CreateOn != "" {
- dates := strings.Split(CreateOn, ",")
- if len(dates) == 2 {
- minDate := dates[0]
- maxDate := dates[1]
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
- }
- }
- svc := auditsetting.GetOilAuditSettingService(utils.DBE)
- var list []auditsetting.BaseOilAuditSetting
- total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- datainfo.PageIndex = page.CurrentPage
- datainfo.ItemsPerPage = page.Size
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取字典列表
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *OilAuditSettingController) GetDictList() {
- dictList := make(map[string]interface{})
- dictSvc := items.GetItemsService(utils.DBE)
- userSvc := baseUser.GetBaseUserService(utils.DBE)
- dictList["AuditStep"] = dictSvc.GetKeyValueItems("AuditStep", this.User.AccCode)
- dictList["WorkFlow"] = dictSvc.GetKeyValueItems("WorkFlow", this.User.AccCode)
- var userEntity userRole.Base_User
- userSvc.GetEntityById(this.User.Id, &userEntity)
- dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
- svcRole := role.GetRoleService(utils.DBE)
- var roles []userRole.Base_Role
- where := "IsVisible=1"
- svcRole.GetMyRoleList("CreateOn", utils.ToStr(this.User.Id), &roles, where)
- dictList["RoleList"] = roles
- svcOrgan := organize.GetOrganizeService(utils.DBE)
- dictList["OrganizeId"] = this.User.DepartmentId
- dictList["OrganizeName"] = svcOrgan.GetNameById(this.User.DepartmentId)
- //var dictCustomer []svccustomer.Customer
- //customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
- //dictList["EntrustCorp"] = &dictCustomer
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 获取实体
- // @Description 获取实体
- // @Success 200 {object} auditsetting.BaseOilAuditSetting
- // @router /get/:id [get]
- func (this *OilAuditSettingController) GetEntity() {
- Id := this.Ctx.Input.Param(":id")
- var model auditsetting.BaseOilAuditSetting
- svc := auditsetting.GetOilAuditSettingService(utils.DBE)
- svc.GetEntityByIdBytbl(OilAuditSettingName, Id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 添加
- // @Description 新增
- // @Param body body auditsetting.OilAuditSetting
- // @Success 200 {object} controllers.Request
- // @router /add [post]
- func (this *OilAuditSettingController) AddEntity() {
- var model auditsetting.BaseOilAuditSetting
- var jsonBlob = this.Ctx.Input.RequestBody
- svc := auditsetting.GetOilAuditSettingService(utils.DBE)
- json.Unmarshal(jsonBlob, &model)
- model.CreateOn = time.Now()
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- model.OrganizeId, _ = utils.StrTo(this.User.DepartmentId).Int()
- _, err := svc.InsertEntityBytbl(OilAuditSettingName, &model)
- var errinfo ErrorDataInfo
- if err == nil {
- //新增
- errinfo.Message = "添加成功!"
- errinfo.Code = 0
- errinfo.Item = model.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 修改实体
- // @Description 修改实体
- // @Param body body auditsetting.OilAuditSetting
- // @Success 200 {object} controllers.Request
- // @router /update/:id [post]
- func (this *OilAuditSettingController) UpdateEntity() {
- id := this.Ctx.Input.Param(":id")
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model auditsetting.BaseOilAuditSetting
- svc := auditsetting.GetOilAuditSettingService(utils.DBE)
- var jsonBlob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonBlob, &model)
- model.ModifiedOn = time.Now()
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- cols := []string{
- "Id",
- "OrganizeId",
- "OrganizeName",
- "AuditStepCode",
- "AuditStepName",
- "RoleId",
- "RoleName",
- "WorkFlowCord",
- "WorkFlowName",
- "Remark",
- "IsDelete",
- "CreateOn",
- "CreateUserId",
- "CreateBy",
- "ModifiedOn",
- "ModifiedUserId",
- "ModifiedBy",
- }
- err := svc.UpdateEntityBytbl(OilAuditSettingName, id, &model, cols)
- if err == nil {
- errinfo.Message = "修改成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除单条信息
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /delete/:Id [delete]
- func (this *OilAuditSettingController) DeleteEntity() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model auditsetting.BaseOilAuditSetting
- var entityempty auditsetting.BaseOilAuditSetting
- svc := auditsetting.GetOilAuditSettingService(utils.DBE)
- opdesc := "删除-" + Id
- err := svc.DeleteOperationAndWriteLogBytbl(OilAuditSettingName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "钻井日报")
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
|